import { SlashCommandBuilder } from "@discordjs/builders"; import { REST } from '@discordjs/rest'; import { Routes } from 'discord-api-types/v9'; import { GuildId, InteractionRoles } from './data'; const commands = [ //roles ====== new SlashCommandBuilder() .setName('roles') .setDescription('displays the role selections') .addIntegerOption((option) => { option .setName('category') .setDescription('the category of roles that will be displayed') .setRequired(true) InteractionRoles.forEach((opt, i) => option.addChoice(opt.message, i)); return option; }) .toJSON(), //rolesall ====== new SlashCommandBuilder() .setName('rolesall') .setDescription('displays the role selections for everyone') .addIntegerOption((option) => { option .setName('category') .setDescription('the category of roles that will be displayed') InteractionRoles.forEach((opt, i) => option.addChoice(opt.message, i)); return option; }) .addChannelOption(option => option .setName('channel') .setDescription('the channel the message(s) will be sent in')) .toJSON(), //updateroles ====== new SlashCommandBuilder() .setName('updateroles') .setDescription('updates the cached role options') .toJSON() ]; const rest = new REST({ version: '9' }).setToken(require('fs').readFileSync('../token').toString()); export default async function refreshCommands(ClientId: string) { try { await rest.put( Routes.applicationGuildCommands(ClientId, GuildId), { body: commands }, ); } catch (error) { console.error(error); } }