From f49a04434020348f562dd9ec4613f6bba1890692 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 26 Oct 2021 23:25:38 +0100 Subject: [PATCH] Revert "Merge remote-tracking branch 'origin/main' into main" This reverts commit feb116b4dfc1ddbcf4798b1a9b132a2611cf91b2. --- package.json | 2 +- src/commands/add.js | 8 ++++---- src/commands/blacklist.js | 12 ++++++------ src/commands/close.js | 16 ++++++++-------- src/commands/help.js | 2 +- src/commands/new.js | 12 ++++++------ src/commands/panel.js | 6 +++--- src/commands/remove.js | 8 ++++---- src/commands/settings.js | 14 +++++++------- src/commands/stats.js | 2 +- src/commands/survey.js | 4 ++-- src/commands/tag.js | 4 ++-- src/commands/topic.js | 4 ++-- src/listeners/interactionCreate.js | 18 +++++++++--------- src/modules/commands/manager.js | 9 ++++----- 15 files changed, 60 insertions(+), 61 deletions(-) diff --git a/package.json b/package.json index 3f61e48..2791873 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eartharoid/discord-tickets", - "version": "3.1.4", + "version": "3.1.2", "private": true, "description": "An open-source Discord bot for ticket management", "main": "src/index.js", diff --git a/src/commands/add.js b/src/commands/add.js index 6060af7..b6afbd0 100644 --- a/src/commands/add.js +++ b/src/commands/add.js @@ -41,7 +41,7 @@ module.exports = class AddCommand extends Command { const t_row = await this.client.tickets.resolve(channel.id, interaction.guild.id); if (!t_row) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -56,7 +56,7 @@ module.exports = class AddCommand extends Command { const member = interaction.options.getMember(default_i18n('commands.add.options.member.name')); if (!member) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -69,7 +69,7 @@ module.exports = class AddCommand extends Command { } if (t_row.creator !== interaction.member.id && !await this.client.utils.isStaff(interaction.member)) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -81,7 +81,7 @@ module.exports = class AddCommand extends Command { }); } - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) diff --git a/src/commands/blacklist.js b/src/commands/blacklist.js index 1aff88f..29c7997 100644 --- a/src/commands/blacklist.js +++ b/src/commands/blacklist.js @@ -65,7 +65,7 @@ module.exports = class BlacklistCommand extends Command { const type = member_or_role instanceof Role ? 'role' : 'member'; if (type === 'member' && await this.client.utils.isStaff(member_or_role)) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -78,7 +78,7 @@ module.exports = class BlacklistCommand extends Command { } blacklist[type + 's'].push(member_or_role.id); - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) @@ -97,7 +97,7 @@ module.exports = class BlacklistCommand extends Command { const index = blacklist[type + 's'].findIndex(element => element === member_or_role.id); if (index === -1) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -110,7 +110,7 @@ module.exports = class BlacklistCommand extends Command { } blacklist[type + 's'].splice(index, 1); - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) @@ -125,7 +125,7 @@ module.exports = class BlacklistCommand extends Command { } case default_i18n('commands.blacklist.options.show.name'): { if (blacklist.members.length === 0 && blacklist.roles.length === 0) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) @@ -138,7 +138,7 @@ module.exports = class BlacklistCommand extends Command { } else { const members = blacklist.members.map(id => `**·** <@${id}>`); const roles = blacklist.roles.map(id => `**·** <@&${id}>`); - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) diff --git a/src/commands/close.js b/src/commands/close.js index 97a78bf..a026cce 100644 --- a/src/commands/close.js +++ b/src/commands/close.js @@ -53,7 +53,7 @@ module.exports = class CloseCommand extends Command { if (time) { if (!await this.client.utils.isStaff(interaction.member)) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -69,7 +69,7 @@ module.exports = class CloseCommand extends Command { try { period = ms(time); } catch { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -89,7 +89,7 @@ module.exports = class CloseCommand extends Command { }); if (tickets.count === 0) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -100,7 +100,7 @@ module.exports = class CloseCommand extends Command { ephemeral: true }); } else { - await interaction.editReply({ + await interaction.reply({ components: [ new MessageActionRow() .addComponents( @@ -193,7 +193,7 @@ module.exports = class CloseCommand extends Command { if (ticket) { t_row = await this.client.tickets.resolve(ticket, interaction.guild.id); if (!t_row) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -207,7 +207,7 @@ module.exports = class CloseCommand extends Command { } else { t_row = await this.client.db.models.Ticket.findOne({ where: { id: interaction.channel.id } }); if (!t_row) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -221,7 +221,7 @@ module.exports = class CloseCommand extends Command { } if (t_row.creator !== interaction.member.id && !await this.client.utils.isStaff(interaction.member)) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -233,7 +233,7 @@ module.exports = class CloseCommand extends Command { }); } - await interaction.editReply({ + await interaction.reply({ components: [ new MessageActionRow() .addComponents( diff --git a/src/commands/help.js b/src/commands/help.js index 6aae2b5..eed7c8a 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -34,7 +34,7 @@ module.exports = class HelpCommand extends Command { : command.description; return `**\`/${command.name}\` ·** ${description}`; }); - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) diff --git a/src/commands/new.js b/src/commands/new.js index 9fde687..8bec13e 100644 --- a/src/commands/new.js +++ b/src/commands/new.js @@ -58,7 +58,7 @@ module.exports = class NewCommand extends Command { ], ephemeral: true }; - await i ? i.editReply(response) : interaction.editReply(response); + await i ? i.editReply(response) : interaction.reply(response); } else { const list = tickets.rows.map(row => { if (row.topic) { @@ -81,7 +81,7 @@ module.exports = class NewCommand extends Command { ], ephemeral: true }; - await i ? i.editReply(response) : interaction.editReply(response); + await i ? i.editReply(response) : interaction.reply(response); } } else { try { @@ -98,7 +98,7 @@ module.exports = class NewCommand extends Command { ], ephemeral: true }; - await i ? i.editReply(response) : interaction.editReply(response); + await i ? i.editReply(response) : interaction.reply(response); } catch (error) { const response = { components: [], @@ -112,7 +112,7 @@ module.exports = class NewCommand extends Command { ], ephemeral: true }; - await i ? i.editReply(response) : interaction.editReply(response); + await i ? i.editReply(response) : interaction.reply(response); } } }; @@ -120,7 +120,7 @@ module.exports = class NewCommand extends Command { const categories = await this.client.db.models.Category.findAndCountAll({ where: { guild: interaction.guild.id } }); if (categories.count === 0) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -133,7 +133,7 @@ module.exports = class NewCommand extends Command { } else if (categories.count === 1) { create(categories.rows[0]); // skip the category selection } else { - await interaction.editReply({ + await interaction.reply({ components: [ new MessageActionRow() .addComponents( diff --git a/src/commands/panel.js b/src/commands/panel.js index 0be0198..03ef9ae 100644 --- a/src/commands/panel.js +++ b/src/commands/panel.js @@ -75,7 +75,7 @@ module.exports = class PanelCommand extends Command { const thumbnail = interaction.options.getString(default_i18n('commands.panel.options.thumbnail.name')); if (just_type && categories.length > 1) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -98,7 +98,7 @@ module.exports = class PanelCommand extends Command { }); if (invalid_category) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -196,7 +196,7 @@ module.exports = class PanelCommand extends Command { } } - interaction.editReply({ + interaction.reply({ content: `✅ ${panel_channel}`, ephemeral: true }); diff --git a/src/commands/remove.js b/src/commands/remove.js index 1660395..85de1da 100644 --- a/src/commands/remove.js +++ b/src/commands/remove.js @@ -41,7 +41,7 @@ module.exports = class RemoveCommand extends Command { const t_row = await this.client.tickets.resolve(channel.id, interaction.guild.id); if (!t_row) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -56,7 +56,7 @@ module.exports = class RemoveCommand extends Command { const member = interaction.options.getMember(default_i18n('commands.remove.options.member.name')); if (!member) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -69,7 +69,7 @@ module.exports = class RemoveCommand extends Command { } if (t_row.creator !== interaction.user.id && !await this.client.utils.isStaff(interaction.member)) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -81,7 +81,7 @@ module.exports = class RemoveCommand extends Command { }); } - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) diff --git a/src/commands/settings.js b/src/commands/settings.js index d226e17..bdb6f81 100644 --- a/src/commands/settings.js +++ b/src/commands/settings.js @@ -233,7 +233,7 @@ module.exports = class SettingsCommand extends Command { roles }); await this.client.commands.updatePermissions(interaction.guild); - interaction.editReply({ + interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) @@ -249,7 +249,7 @@ module.exports = class SettingsCommand extends Command { const channel = this.client.channels.cache.get(interaction.options.getString(default_i18n('commands.settings.options.categories.options.delete.options.id.name'))); if (channel) channel.delete(); await category.destroy(); - interaction.editReply({ + interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) @@ -258,7 +258,7 @@ module.exports = class SettingsCommand extends Command { ephemeral: true }); } else { - interaction.editReply({ + interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -272,7 +272,7 @@ module.exports = class SettingsCommand extends Command { case default_i18n('commands.settings.options.categories.options.edit.name'): { const category = await this.client.db.models.Category.findOne({ where: { id: interaction.options.getString(default_i18n('commands.settings.options.categories.options.delete.options.id.name')) } }); if (!category) { - return interaction.editReply({ + return interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -304,7 +304,7 @@ module.exports = class SettingsCommand extends Command { if (roles !== null) category.set('roles', roles.match(/\d{17,19}/g) ?? []); if (survey !== null) category.set('survey', survey); await category.save(); - interaction.editReply({ + interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) @@ -316,7 +316,7 @@ module.exports = class SettingsCommand extends Command { } case default_i18n('commands.settings.options.categories.options.list.name'): { const categories = await this.client.db.models.Category.findAll({ where: { guild: interaction.guild.id } }); - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) @@ -343,7 +343,7 @@ module.exports = class SettingsCommand extends Command { if (log_messages !== null) settings.set('log_messages', log_messages); if (success_colour !== null) settings.set('success_colour', success_colour.toUpperCase()); await settings.save(); - interaction.editReply({ + interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) diff --git a/src/commands/stats.js b/src/commands/stats.js index a759b73..79a832d 100644 --- a/src/commands/stats.js +++ b/src/commands/stats.js @@ -90,6 +90,6 @@ module.exports = class StatsCommand extends Command { embeds.push(global_embed); } - await interaction.editReply({ embeds }); + await interaction.reply({ embeds }); } }; diff --git a/src/commands/survey.js b/src/commands/survey.js index 3ca0956..86be0a7 100644 --- a/src/commands/survey.js +++ b/src/commands/survey.js @@ -90,7 +90,7 @@ module.exports = class SurveyCommand extends Command { `${survey.name}.html` ); - return await interaction.editReply({ + return await interaction.reply({ ephemeral: true, files: [attachment] }); @@ -98,7 +98,7 @@ module.exports = class SurveyCommand extends Command { const surveys = await this.client.db.models.Survey.findAll({ where: { guild: interaction.guild.id } }); const list = surveys.map(s => `❯ **\`${s.name}\`**`); - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) diff --git a/src/commands/tag.js b/src/commands/tag.js index 6fbec73..7bbf00b 100644 --- a/src/commands/tag.js +++ b/src/commands/tag.js @@ -46,7 +46,7 @@ module.exports = class TagCommand extends Command { const arg = args.find(arg => arg.name === $1); return arg ? arg.value : $; }); - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) @@ -56,7 +56,7 @@ module.exports = class TagCommand extends Command { }); } catch { const list = Object.keys(settings.tags).map(t => `❯ **\`${t}\`**`); - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) diff --git a/src/commands/topic.js b/src/commands/topic.js index e04115f..7fa6139 100644 --- a/src/commands/topic.js +++ b/src/commands/topic.js @@ -36,7 +36,7 @@ module.exports = class TopicCommand extends Command { const t_row = await this.client.db.models.Ticket.findOne({ where: { id: interaction.channel.id } }); if (!t_row) { - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -70,7 +70,7 @@ module.exports = class TopicCommand extends Command { ] }); - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) diff --git a/src/listeners/interactionCreate.js b/src/listeners/interactionCreate.js index 861d7ca..c1449c3 100644 --- a/src/listeners/interactionCreate.js +++ b/src/listeners/interactionCreate.js @@ -23,7 +23,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { const blacklisted = settings.blacklist.members.includes[interaction.user.id] || interaction.member?.roles.cache?.some(role => settings.blacklist.roles.includes(role)); if (blacklisted) { - return interaction.editReply({ + return interaction.reply({ content: i18n('blacklisted'), ephemeral: true }); @@ -34,7 +34,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { if (!cat_row) { this.client.log.warn('Could not find a category with the ID given by a panel interaction'); - return interaction.editReply({ + return interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -55,7 +55,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { if (tickets.count >= cat_row.max_per_member) { if (cat_row.max_per_member === 1) { - return interaction.editReply({ + return interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -76,7 +76,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { return `<#${row.id}>`; } }); - return interaction.editReply({ + return interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -91,7 +91,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { } else { try { const t_row = await this.client.tickets.create(interaction.guild.id, interaction.user.id, id); - return interaction.editReply({ + return interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.success_colour) @@ -104,7 +104,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { }); } catch (error) { this.client.log.error(error); - return interaction.editReply({ + return interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -141,7 +141,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { this.client.log.info(`${interaction.user.tag} has claimed "${interaction.channel.name}" in "${interaction.guild.name}"`); - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) @@ -191,7 +191,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { this.client.log.info(`${interaction.user.tag} has released "${interaction.channel.name}" in "${interaction.guild.name}"`); - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.colour) @@ -228,7 +228,7 @@ module.exports = class InteractionCreateEventListener extends EventListener { } else if (interaction.customId.startsWith('ticket.close')) { // handle ticket close button const t_row = await this.client.db.models.Ticket.findOne({ where: { id: interaction.channel.id } }); - await interaction.editReply({ + await interaction.reply({ components: [ new MessageActionRow() .addComponents( diff --git a/src/modules/commands/manager.js b/src/modules/commands/manager.js index 934b9f8..9bb637f 100644 --- a/src/modules/commands/manager.js +++ b/src/modules/commands/manager.js @@ -148,7 +148,6 @@ module.exports = class CommandManager { */ async handle(interaction) { if (!interaction.guild) return this.client.log.debug('Ignoring non-guild command interaction'); - await interaction.deferReply(); const settings = await this.client.utils.getSettings(interaction.guild.id); const i18n = this.client.i18n.getLocale(settings.locale); @@ -166,7 +165,7 @@ module.exports = class CommandManager { if (!bot_permissions.has(required_bot_permissions)) { const perms = required_bot_permissions.map(p => `\`${p}\``).join(', '); if (bot_permissions.has('EMBED_LINKS')) { - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor('ORANGE') @@ -175,7 +174,7 @@ module.exports = class CommandManager { ] }); } else { - await interaction.editReply({ content: i18n('bot.missing_permissions.description', perms) }); + await interaction.reply({ content: i18n('bot.missing_permissions.description', perms) }); } return; } @@ -183,7 +182,7 @@ module.exports = class CommandManager { const missing_permissions = command.permissions instanceof Array && !interaction.member.permissions.has(command.permissions); if (missing_permissions) { const perms = command.permissions.map(p => `\`${p}\``).join(', '); - return await interaction.editReply({ + return await interaction.reply({ embeds: [ new MessageEmbed() .setColor(settings.error_colour) @@ -200,7 +199,7 @@ module.exports = class CommandManager { } catch (e) { this.client.log.warn(`An error occurred whilst executing the ${command.name} command`); this.client.log.error(e); - await interaction.editReply({ + await interaction.reply({ embeds: [ new MessageEmbed() .setColor('ORANGE')