From eaa970fd010f044ead70a4d70d2dae9652d803af Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 26 Feb 2025 01:44:44 +0000 Subject: [PATCH] fix: `send()` user create button if possible to avoid the "Original message was deleted" text --- src/commands/user/create.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/commands/user/create.js b/src/commands/user/create.js index a4f0926..ab54eb9 100644 --- a/src/commands/user/create.js +++ b/src/commands/user/create.js @@ -35,7 +35,7 @@ module.exports = class CreateUserCommand extends UserCommand { await interaction.deferReply({ flags: 'Ephemeral' }); const settings = await client.prisma.guild.findUnique({ - include: { categories:true }, + include: { categories: true }, where: { id: interaction.guild.id }, }); const getMessage = client.i18n.getLocale(settings.locale); @@ -55,7 +55,7 @@ module.exports = class CreateUserCommand extends UserCommand { } const prompt = async categoryId => { - interaction.followUp({ + const payload = { components: [ new ActionRowBuilder() .addComponents( @@ -81,7 +81,12 @@ module.exports = class CreateUserCommand extends UserCommand { .setTitle(getMessage('commands.user.create.prompt.title')) .setDescription(getMessage('commands.user.create.prompt.description')), ], - }); + }; + try { + await interaction.channel.send(payload); + } catch { + await interaction.followUp(payload); + } }; if (settings.categories.length === 0) { @@ -96,8 +101,6 @@ module.exports = class CreateUserCommand extends UserCommand { }); } else if (settings.categories.length === 1) { const category = settings.categories[0]; - // ! must be awaited, - // ! followUp will act as editReply (on the original ephemeral message) if it arrives first await interaction.editReply({ components: [], embeds: [ @@ -146,8 +149,6 @@ module.exports = class CreateUserCommand extends UserCommand { }) .then(async i => { const category = settings.categories.find(c => c.id === Number(i.values[0])); - // ! must be awaited, - // ! followUp will act as editReply (on the original ephemeral message) if it arrives first await i.update({ components: [], embeds: [ @@ -167,7 +168,7 @@ module.exports = class CreateUserCommand extends UserCommand { }) .catch(async error => { client.log.error(error); - await interaction.reply({ + await interaction.editReply({ components: [], embeds: [ new ExtendedEmbedBuilder({