diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/extensions/BushClientUtil.ts | 85 |
1 files changed, 9 insertions, 76 deletions
diff --git a/src/lib/extensions/BushClientUtil.ts b/src/lib/extensions/BushClientUtil.ts index 9b87efd..2836983 100644 --- a/src/lib/extensions/BushClientUtil.ts +++ b/src/lib/extensions/BushClientUtil.ts @@ -268,73 +268,6 @@ export class BushClientUtil 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( - 'syncSlashCommands', - `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( - 'syncSlashCommands', - `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( - 'syncSlashCommands', - `Created slash command <<${botCommand.id}>>${guild !== undefined ? ` in guild <<${fetchedGuild?.name}>>` : ''}}` - ); - } - } - } - - return this.client.logger.log( - 'syncSlashCommands', - `Slash commands registered${guild !== undefined ? ` in guild <<${fetchedGuild?.name}>>` : ''}` - ); - } catch (e) { - return this.client.logger.error( - 'syncSlashCommands', - `Slash commands not registered${ - guild !== undefined ? ` in guild <<${fetchedGuild?.name}>>` : '' - }, with the following error:\n${e?.stack}` - ); - } - } - public moulberryBushRoleMap = [ { name: '*', id: '792453550768390194' }, { name: 'Admin Perms', id: '746541309853958186' }, @@ -402,14 +335,14 @@ export class BushClientUtil extends ClientUtil { } case 'paginate_stop': { if (deleteOnExit) { - await interaction.deferUpdate().catch(() => {}); + await interaction.deferUpdate().catch(() => undefined); if (msg.deletable && !msg.deleted) { await msg.delete(); } } else { await interaction ?.update({ content: `${text ? text + '\n' : ''}Command closed by user.`, embeds: [], components: [] }) - .catch(() => {}); + .catch(() => undefined); } return; } @@ -425,18 +358,18 @@ export class BushClientUtil extends ClientUtil { } } } else { - return await interaction?.deferUpdate().catch(() => {}); + return await interaction?.deferUpdate().catch(() => undefined); } }); 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> { return await interaction ?.update({ content: text, embeds: [embeds[curPage]], components: [getPaginationRow()] }) - .catch(() => {}); + .catch(() => undefined); } const paginateEmojis = this.paginateEmojis; function getPaginationRow(disableAll = false): MessageActionRow { @@ -478,19 +411,19 @@ export class BushClientUtil extends ClientUtil { const collector = msg.createMessageComponentInteractionCollector(filter, { time: 300000 }); collector.on('collect', async (interaction: MessageComponentInteraction) => { if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) { - await interaction.deferUpdate().catch(() => {}); + await interaction.deferUpdate().catch(() => undefined); if (msg.deletable && !msg.deleted) { await msg.delete(); } return; } else { - return await interaction?.deferUpdate().catch(() => {}); + return await interaction?.deferUpdate().catch(() => undefined); } }); collector.on('end', async () => { updateOptions(true, true); - await msg.edit(options as MessageEditOptions).catch(() => {}); + await msg.edit(options as MessageEditOptions).catch(() => undefined); }); const paginateEmojis = this.paginateEmojis; @@ -547,7 +480,7 @@ export class BushClientUtil extends ClientUtil { return (await interaction.editReply(newResponseOptions)) as APIMessage; } else { await interaction.reply(newResponseOptions); - return await interaction.fetchReply().catch(() => {}); + return await interaction.fetchReply().catch(() => undefined); } } |