Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions apps/idlebiz/src/lib/CommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,26 @@ export async function registerGlobalCommands(
await rest.put(Routes.applicationCommands(applicationId), {
body: commands,
});
console.log(`Successfully registered ${commands.length} application commands`);
console.log(`Successfully registered ${commands.length} global commands.`);
} catch (e) {
console.error(e);
process.exit(1);
}
Comment thread
nsylke marked this conversation as resolved.
}

export async function registerGuildCommands(
token: string,
applicationId: string,
guildId: string,
commands: ApplicationCommandData[]
) {
const rest = new REST().setToken(token);

try {
await rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
body: commands,
});
console.log(`Successfully registered ${commands.length} guild commands.`);
} catch (e) {
console.error(e);
process.exit(1);
Expand All @@ -99,7 +118,30 @@ export async function unregisterGlobalCommands(token: string, applicationId: str
await rest.delete(Routes.applicationCommand(applicationId, command.id));
}

console.log(`Successfully deleted ${commands.length} application commands`);
console.log(`Successfully deleted ${commands.length} global commands.`);
} catch (e) {
console.error(e);
process.exit(1);
}
Comment thread
nsylke marked this conversation as resolved.
}

export async function unregisterGuildCommands(
token: string,
applicationId: string,
guildId: string
) {
const rest = new REST().setToken(token);

try {
const commands = (await rest.get(
Routes.applicationGuildCommands(applicationId, guildId)
)) as ApplicationCommand[];

for (const command of commands) {
await rest.delete(Routes.applicationCommand(applicationId, command.id));
}

console.log(`Successfully deleted ${commands.length} guild commands.`);
} catch (e) {
console.error(e);
process.exit(1);
Expand Down