refactor: Remove interaction deferrals, use direct replies, and make error/warning messages ephemeral in economy commands.

This commit is contained in:
syntaxbullet
2025-12-13 12:46:38 +01:00
parent 421bb26ceb
commit 86cbe827a2
3 changed files with 14 additions and 13 deletions

View File

@@ -21,20 +21,18 @@ export const pay = createCommand({
.setRequired(true)
),
execute: async (interaction) => {
await interaction.deferReply();
const targetUser = await userService.getOrCreateUser(interaction.options.getUser("user", true).id, interaction.options.getUser("user", true).username);
const amount = BigInt(interaction.options.getInteger("amount", true));
const senderId = interaction.user.id;
const receiverId = targetUser.id;
if (amount < GameConfig.economy.transfers.minAmount) {
await interaction.editReply({ embeds: [createWarningEmbed(`Amount must be at least ${GameConfig.economy.transfers.minAmount}.`)] });
await interaction.reply({ embeds: [createWarningEmbed(`Amount must be at least ${GameConfig.economy.transfers.minAmount}.`)], ephemeral: true });
return;
}
if (senderId === receiverId) {
await interaction.editReply({ embeds: [createWarningEmbed("You cannot pay yourself.")] });
await interaction.reply({ embeds: [createWarningEmbed("You cannot pay yourself.")], ephemeral: true });
return;
}
@@ -47,15 +45,15 @@ export const pay = createCommand({
.setColor("Green")
.setTimestamp();
await interaction.editReply({ embeds: [embed] });
await interaction.reply({ embeds: [embed] });
} catch (error: any) {
if (error.message.includes("Insufficient funds")) {
await interaction.editReply({ embeds: [createWarningEmbed("Insufficient funds.")] });
await interaction.reply({ embeds: [createWarningEmbed("Insufficient funds.")], ephemeral: true });
return;
}
console.error(error);
await interaction.editReply({ embeds: [createErrorEmbed("Transfer failed.")] });
await interaction.reply({ embeds: [createErrorEmbed("Transfer failed.")], ephemeral: true });
}
}
});