fix fractional items and qbucks

This commit is contained in:
2025-09-14 21:16:30 +02:00
parent 4048e1b3c3
commit ebdf6264d4
5 changed files with 7 additions and 8 deletions

View File

@@ -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();

View File

@@ -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();

View File

@@ -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; };

View File

@@ -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; };

View File

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