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:
@@ -9,8 +9,6 @@ export const daily = createCommand({
|
|||||||
.setName("daily")
|
.setName("daily")
|
||||||
.setDescription("Claim your daily reward"),
|
.setDescription("Claim your daily reward"),
|
||||||
execute: async (interaction) => {
|
execute: async (interaction) => {
|
||||||
await interaction.deferReply();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await economyService.claimDaily(interaction.user.id);
|
const result = await economyService.claimDaily(interaction.user.id);
|
||||||
|
|
||||||
@@ -24,16 +22,16 @@ export const daily = createCommand({
|
|||||||
.setColor("Gold")
|
.setColor("Gold")
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
await interaction.editReply({ embeds: [embed] });
|
await interaction.reply({ embeds: [embed] });
|
||||||
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.message.includes("Daily already claimed")) {
|
if (error.message.includes("Daily already claimed")) {
|
||||||
await interaction.editReply({ embeds: [createWarningEmbed(error.message, "Cooldown")] });
|
await interaction.reply({ embeds: [createWarningEmbed(error.message, "Cooldown")], ephemeral: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
await interaction.editReply({ embeds: [createErrorEmbed("An error occurred while claiming your daily reward.")] });
|
await interaction.reply({ embeds: [createErrorEmbed("An error occurred while claiming your daily reward.")], ephemeral: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,20 +21,18 @@ export const pay = createCommand({
|
|||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
),
|
),
|
||||||
execute: async (interaction) => {
|
execute: async (interaction) => {
|
||||||
await interaction.deferReply();
|
|
||||||
|
|
||||||
const targetUser = await userService.getOrCreateUser(interaction.options.getUser("user", true).id, interaction.options.getUser("user", true).username);
|
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 amount = BigInt(interaction.options.getInteger("amount", true));
|
||||||
const senderId = interaction.user.id;
|
const senderId = interaction.user.id;
|
||||||
const receiverId = targetUser.id;
|
const receiverId = targetUser.id;
|
||||||
|
|
||||||
if (amount < GameConfig.economy.transfers.minAmount) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (senderId === receiverId) {
|
if (senderId === receiverId) {
|
||||||
await interaction.editReply({ embeds: [createWarningEmbed("You cannot pay yourself.")] });
|
await interaction.reply({ embeds: [createWarningEmbed("You cannot pay yourself.")], ephemeral: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,15 +45,15 @@ export const pay = createCommand({
|
|||||||
.setColor("Green")
|
.setColor("Green")
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
await interaction.editReply({ embeds: [embed] });
|
await interaction.reply({ embeds: [embed] });
|
||||||
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.message.includes("Insufficient funds")) {
|
if (error.message.includes("Insufficient funds")) {
|
||||||
await interaction.editReply({ embeds: [createWarningEmbed("Insufficient funds.")] });
|
await interaction.reply({ embeds: [createWarningEmbed("Insufficient funds.")], ephemeral: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.error(error);
|
console.error(error);
|
||||||
await interaction.editReply({ embeds: [createErrorEmbed("Transfer failed.")] });
|
await interaction.reply({ embeds: [createErrorEmbed("Transfer failed.")], ephemeral: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -49,7 +49,12 @@ export const trade = createCommand({
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Fallback if message threads fail, try channel threads (private preferred)
|
// Fallback if message threads fail, try channel threads (private preferred)
|
||||||
// But startThread on message is usually easiest.
|
// But startThread on message is usually easiest.
|
||||||
await interaction.editReply({ content: "", embeds: [createErrorEmbed("Failed to create trade thread. Check permissions.")] });
|
try {
|
||||||
|
await message.delete();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to delete setup message", err);
|
||||||
|
}
|
||||||
|
await interaction.followUp({ embeds: [createErrorEmbed("Failed to create trade thread. Check permissions.")], ephemeral: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user