forked from syntaxbullet/AuroraBot-discord
refactor: Remove interaction deferrals, use direct replies, and make error/warning messages ephemeral in economy commands.
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user