feat: add trading system with dedicated modules and centralize embed creation for commands

This commit is contained in:
syntaxbullet
2025-12-13 12:43:27 +01:00
parent 5f4efd372f
commit 421bb26ceb
13 changed files with 667 additions and 41 deletions

View File

@@ -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.")] });
}
}
});