From ebdf6264d457f3f72a5baca561b434f426e90a5a Mon Sep 17 00:00:00 2001 From: qwerinope Date: Sun, 14 Sep 2025 21:16:30 +0200 Subject: [PATCH] fix fractional items and qbucks --- src/commands/admindonate.ts | 2 +- src/commands/admingive.ts | 2 +- src/commands/donateqbucks.ts | 4 ++-- src/commands/giveitem.ts | 5 ++--- src/commands/testcheer.ts | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/commands/admindonate.ts b/src/commands/admindonate.ts index 0fa4b74..fd11993 100644 --- a/src/commands/admindonate.ts +++ b/src/commands/admindonate.ts @@ -15,7 +15,7 @@ export default new Command({ if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; }; const userRecord = await getUserRecord(target); if (!args[1]) { await sendMessage('Please specify the amount qweribucks you want to give', msg.messageId); return; }; - const amount = Number(args[1]); + const amount = parseInt(args[1]); if (isNaN(amount)) { await sendMessage(`${args[1]} is not a valid amount`); return; }; if (await target.itemLock()) { await sendMessage('Cannot give qweribucks: item lock is set', msg.messageId); return; }; await target.setLock(); diff --git a/src/commands/admingive.ts b/src/commands/admingive.ts index 46fe1ff..0a93a3a 100644 --- a/src/commands/admingive.ts +++ b/src/commands/admingive.ts @@ -18,7 +18,7 @@ export default new Command({ const item = items.get(args[1].toLowerCase()); if (!item) { await sendMessage(`Item ${args[1]} doesn't exist`, msg.messageId); return; }; if (!args[2]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; }; - const amount = Number(args[2]); + const amount = parseInt(args[2]); if (isNaN(amount)) { await sendMessage(`${args[2]} is not a valid amount`); return; }; if (await target.itemLock()) { await sendMessage('Cannot give item: item lock is set', msg.messageId); return; }; await target.setLock(); diff --git a/src/commands/donateqbucks.ts b/src/commands/donateqbucks.ts index 340c4a2..c3dfa8a 100644 --- a/src/commands/donateqbucks.ts +++ b/src/commands/donateqbucks.ts @@ -18,8 +18,8 @@ export default new Command({ if (target.username === user.username) { await sendMessage("You can't give yourself qweribucks", msg.messageId); return; }; const targetRecord = await getUserRecord(target); if (!args[1]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; }; - const amount = Number(args[1]); - if (isNaN(amount) || amount < 0) { await sendMessage(`${args[1]} is not a valid amount`); return; }; + const amount = parseInt(args[1]); + if (isNaN(amount) || amount < 1) { await sendMessage(`${args[1]} is not a valid amount`); return; }; const userRecord = await getUserRecord(user); if (userRecord.balance < amount) { await sendMessage(`You can't give qweribucks you don't have!`, msg.messageId); return; }; diff --git a/src/commands/giveitem.ts b/src/commands/giveitem.ts index 5a6ece3..a7c53a2 100644 --- a/src/commands/giveitem.ts +++ b/src/commands/giveitem.ts @@ -21,9 +21,8 @@ export default new Command({ const item = items.get(args[1].toLowerCase()); if (!item) { await sendMessage(`Item ${args[1]} doesn't exist`, msg.messageId); return; }; if (!args[2]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; }; - const amount = Number(args[2]); - if (isNaN(amount) || amount < 0) { await sendMessage(`${args[2]} is not a valid amount`); return; }; - + const amount = parseInt(args[2]); + if (isNaN(amount) || amount < 1) { await sendMessage(`${args[2]} is not a valid amount`); return; }; const userRecord = await getUserRecord(user); if (userRecord.inventory[item.name]! < amount) { await sendMessage(`You can't give items you don't have!`, msg.messageId); return; }; diff --git a/src/commands/testcheer.ts b/src/commands/testcheer.ts index 2296d76..2cf0449 100644 --- a/src/commands/testcheer.ts +++ b/src/commands/testcheer.ts @@ -10,7 +10,7 @@ export default new Command({ execution: async (msg, user) => { const args = parseCommandArgs(msg.messageText); if (!args[0]) { await sendMessage('Please specify the amount of fake bits you want to send', msg.messageId); return; }; - if (isNaN(Number(args[0]))) { await sendMessage(`${args[0]} is not a valid amout of bits`); return; }; + if (isNaN(parseInt(args[0]))) { await sendMessage(`${args[0]} is not a valid amout of bits`); return; }; const bits = Number(args.shift()); // we shift it so the amount of bits isn't part of the handleCheer message, we already know that args[0] can be parsed as a number so this is fine. await handleCheer(msg, bits, user); }