feat: add trading system with dedicated modules and centralize embed creation for commands
This commit is contained in:
@@ -3,6 +3,7 @@ import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
|
||||
import { economyService } from "@/modules/economy/economy.service";
|
||||
import { userService } from "@/modules/user/user.service";
|
||||
import { GameConfig } from "@/config/game";
|
||||
import { createErrorEmbed, createWarningEmbed } from "@lib/embeds";
|
||||
|
||||
export const pay = createCommand({
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -28,12 +29,12 @@ export const pay = createCommand({
|
||||
const receiverId = targetUser.id;
|
||||
|
||||
if (amount < GameConfig.economy.transfers.minAmount) {
|
||||
await interaction.editReply({ content: `❌ Amount must be at least ${GameConfig.economy.transfers.minAmount}.` });
|
||||
await interaction.editReply({ embeds: [createWarningEmbed(`Amount must be at least ${GameConfig.economy.transfers.minAmount}.`)] });
|
||||
return;
|
||||
}
|
||||
|
||||
if (senderId === receiverId) {
|
||||
await interaction.editReply({ content: "❌ You cannot pay yourself." });
|
||||
await interaction.editReply({ embeds: [createWarningEmbed("You cannot pay yourself.")] });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,11 +51,11 @@ export const pay = createCommand({
|
||||
|
||||
} catch (error: any) {
|
||||
if (error.message.includes("Insufficient funds")) {
|
||||
await interaction.editReply({ content: "❌ Insufficient funds." });
|
||||
await interaction.editReply({ embeds: [createWarningEmbed("Insufficient funds.")] });
|
||||
return;
|
||||
}
|
||||
console.error(error);
|
||||
await interaction.editReply({ content: "❌ Transfer failed." });
|
||||
await interaction.editReply({ embeds: [createErrorEmbed("Transfer failed.")] });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user