diff --git a/src/Bot.ts b/src/Bot.ts index b484670..e4043f7 100644 --- a/src/Bot.ts +++ b/src/Bot.ts @@ -113,9 +113,12 @@ export class Bot extends EventEmitter { ); const guilds: any = {}; this.commands.list - .filter((c) => !!c.guilds) + .filter((c) => Array.isArray(c.guilds) && c.guilds.length > 0) .map((c) => { c.guilds?.map(async (g) => { + if (!(await this.client.guilds.fetch(g))) { + throw new Error(`"${g}" for "${c.name}" command is not a valid guild ID`); + } if (guilds[g]) { guilds[g].push(c.toCommandObject()); } else { diff --git a/src/Command.ts b/src/Command.ts index f9c1d98..2d0a248 100644 --- a/src/Command.ts +++ b/src/Command.ts @@ -84,6 +84,12 @@ export class Command { : memberPermissions.any(this.permissions as PermissionResolvable, true) : false) ) { + if (this.guilds && !this.guilds.find((g) => g == interaction?.guild?.id)) { + throw new Error("This command is not available here"); + } + if (!this.slash && interaction instanceof CommandInteraction) { + throw new Error("This command is not available as a slash command"); + } if (interaction instanceof CommandInteraction) { await interaction.deferReply(); }