feat: Implement userService.getOrCreateUser and integrate it across commands, remove old utility scripts, and fix daily bonus calculation.

This commit is contained in:
syntaxbullet
2025-12-08 10:29:40 +01:00
parent 29c0a4752d
commit 866cfab03e
12 changed files with 42 additions and 94 deletions

View File

@@ -21,7 +21,7 @@ export const pay = createCommand({
execute: async (interaction) => {
await interaction.deferReply();
const targetUser = interaction.options.getUser("user", true);
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;
@@ -31,12 +31,6 @@ export const pay = createCommand({
return;
}
// Ensure receiver exists
let receiver = await userService.getUserById(receiverId);
if (!receiver) {
receiver = await userService.createUser(receiverId, targetUser.username, undefined);
}
try {
await economyService.transfer(senderId, receiverId, amount);