muse/src/utils/register-commands-on-guild.ts
Son e0dfd8c9fd
Fix ERR_MODULE_NOT_FOUND for constants file (#1023)
Co-authored-by: Max Isom <hi@maxisom.me>
2024-04-28 18:11:38 -05:00

19 lines
578 B
TypeScript

import {REST} from '@discordjs/rest';
import {Routes} from 'discord-api-types/v10';
import Command from '../commands/index.js';
interface RegisterCommandsOnGuildOptions {
rest: REST;
applicationId: string;
guildId: string;
commands: Array<Command['slashCommand']>;
}
const registerCommandsOnGuild = async ({rest, applicationId, guildId, commands}: RegisterCommandsOnGuildOptions) => {
await rest.put(
Routes.applicationGuildCommands(applicationId, guildId),
{body: commands.map(command => command.toJSON())},
);
};
export default registerCommandsOnGuild;