diff options
Diffstat (limited to 'src/lib/extensions')
-rw-r--r-- | src/lib/extensions/BushClient.ts | 3 | ||||
-rw-r--r-- | src/lib/extensions/BushCommandHandler.ts | 2 | ||||
-rw-r--r-- | src/lib/extensions/BushTaskHandler.ts | 2 | ||||
-rw-r--r-- | src/lib/extensions/Util.ts | 73 |
4 files changed, 6 insertions, 74 deletions
diff --git a/src/lib/extensions/BushClient.ts b/src/lib/extensions/BushClient.ts index e2e889b..a173804 100644 --- a/src/lib/extensions/BushClient.ts +++ b/src/lib/extensions/BushClient.ts @@ -80,7 +80,8 @@ export class BushClient extends AkairoClient { }, ignorePermissions: this.config.owners, ignoreCooldown: this.config.owners, - automateCategories: true + automateCategories: true, + autoRegisterSlashCommands: true }); this.util = new BushUtil(this); diff --git a/src/lib/extensions/BushCommandHandler.ts b/src/lib/extensions/BushCommandHandler.ts index 6ef44d7..52e4665 100644 --- a/src/lib/extensions/BushCommandHandler.ts +++ b/src/lib/extensions/BushCommandHandler.ts @@ -3,7 +3,7 @@ import { Collection } from 'discord.js'; import { BushClient } from './BushClient'; import { BushCommand } from './BushCommand'; -export interface BushCommandHandlerOptions extends CommandHandlerOptions {} +export type BushCommandHandlerOptions = CommandHandlerOptions; export class BushCommandHandler extends CommandHandler { public constructor(client: BushClient, options: BushCommandHandlerOptions) { diff --git a/src/lib/extensions/BushTaskHandler.ts b/src/lib/extensions/BushTaskHandler.ts index f783eb3..923e42b 100644 --- a/src/lib/extensions/BushTaskHandler.ts +++ b/src/lib/extensions/BushTaskHandler.ts @@ -1,7 +1,7 @@ import { AkairoHandlerOptions, TaskHandler } from 'discord-akairo'; import { BushClient } from './BushClient'; -export interface BushTaskHandlerOptions extends AkairoHandlerOptions {} +export type BushTaskHandlerOptions = AkairoHandlerOptions; export class BushTaskHandler extends TaskHandler { public constructor(client: BushClient, options: BushTaskHandlerOptions) { diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts index 3913437..4a4ccef 100644 --- a/src/lib/extensions/Util.ts +++ b/src/lib/extensions/Util.ts @@ -1,6 +1,5 @@ -import chalk from 'chalk'; import { exec } from 'child_process'; -import { ClientUtil, Command } from 'discord-akairo'; +import { ClientUtil } from 'discord-akairo'; import { APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, @@ -11,7 +10,6 @@ import { ButtonInteraction, CommandInteractionOption, Constants, - Guild, GuildChannel, GuildMember, MessageActionRow, @@ -260,73 +258,6 @@ export class BushUtil extends ClientUtil { return apiRes.uuid.replace(/-/g, ''); } - public async syncSlashCommands(force = false, guild?: Snowflake): Promise<void> { - let fetchedGuild: Guild; - if (guild) fetchedGuild = this.client.guilds.cache.get(guild); - try { - const registered = - guild === undefined ? await this.client.application.commands.fetch() : await fetchedGuild.commands.fetch(); - for (const [, registeredCommand] of registered) { - if (!this.client.commandHandler.modules.find((cmd) => cmd.id == registeredCommand.name)?.execSlash || force) { - guild === undefined - ? await this.client.application.commands.delete(registeredCommand.id) - : await fetchedGuild.commands.delete(registeredCommand.id); - this.client.logger.verbose( - chalk`{red Deleted slash command ${registeredCommand.name}${ - guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' - }}` - ); - } - } - - for (const [, botCommand] of this.client.commandHandler.modules) { - if (botCommand.execSlash) { - const found = registered.find((i) => i.name == botCommand.id); - Command; - const slashdata = { - name: botCommand.id, - description: botCommand.description.content, - options: botCommand.options.slashCommandOptions - }; - botCommand; - - if (found?.id && !force) { - if (slashdata.description !== found.description) { - guild === undefined - ? await this.client.application.commands.edit(found.id, slashdata) - : fetchedGuild.commands.edit(found.id, slashdata); - this.client.logger.verbose( - chalk`{yellow Edited slash command ${botCommand.id}${ - guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' - }}` - ); - } - } else { - guild === undefined - ? await this.client.application.commands.create(slashdata) - : fetchedGuild.commands.create(slashdata); - this.client.logger.verbose( - chalk`{green Created slash command ${botCommand.id}${ - guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' - }}` - ); - } - } - } - - return this.client.logger.log( - chalk.green(`Slash commands registered${guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''}`) - ); - } catch (e) { - console.log(chalk.red(e.stack)); - return this.client.logger.error( - chalk`{red Slash commands not registered${ - guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' - }, see above error.}` - ); - } - } - public moulberryBushRoleMap = [ { name: '*', id: '792453550768390194' }, { name: 'Admin Perms', id: '746541309853958186' }, @@ -424,7 +355,7 @@ export class BushUtil extends ClientUtil { }); collector.on('end', async () => { - await msg.edit({ content: text, embeds: [embeds[curPage]], components: [getPaginationRow(true)] }).catch(() => {}); + await msg.edit({ content: text, embeds: [embeds[curPage]], components: [getPaginationRow(true)] }).catch(() => undefined); }); async function edit(interaction: MessageComponentInteraction): Promise<void> { |