mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
fix fractional items and qbucks
This commit is contained in:
@@ -15,7 +15,7 @@ export default new Command({
|
|||||||
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
|
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
|
||||||
const userRecord = await getUserRecord(target);
|
const userRecord = await getUserRecord(target);
|
||||||
if (!args[1]) { await sendMessage('Please specify the amount qweribucks you want to give', msg.messageId); return; };
|
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 (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; };
|
if (await target.itemLock()) { await sendMessage('Cannot give qweribucks: item lock is set', msg.messageId); return; };
|
||||||
await target.setLock();
|
await target.setLock();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default new Command({
|
|||||||
const item = items.get(args[1].toLowerCase());
|
const item = items.get(args[1].toLowerCase());
|
||||||
if (!item) { await sendMessage(`Item ${args[1]} doesn't exist`, msg.messageId); return; };
|
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; };
|
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 (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; };
|
if (await target.itemLock()) { await sendMessage('Cannot give item: item lock is set', msg.messageId); return; };
|
||||||
await target.setLock();
|
await target.setLock();
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export default new Command({
|
|||||||
if (target.username === user.username) { await sendMessage("You can't give yourself qweribucks", msg.messageId); return; };
|
if (target.username === user.username) { await sendMessage("You can't give yourself qweribucks", msg.messageId); return; };
|
||||||
const targetRecord = await getUserRecord(target);
|
const targetRecord = await getUserRecord(target);
|
||||||
if (!args[1]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; };
|
if (!args[1]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; };
|
||||||
const amount = Number(args[1]);
|
const amount = parseInt(args[1]);
|
||||||
if (isNaN(amount) || amount < 0) { await sendMessage(`${args[1]} is not a valid amount`); return; };
|
if (isNaN(amount) || amount < 1) { await sendMessage(`${args[1]} is not a valid amount`); return; };
|
||||||
|
|
||||||
const userRecord = await getUserRecord(user);
|
const userRecord = await getUserRecord(user);
|
||||||
if (userRecord.balance < amount) { await sendMessage(`You can't give qweribucks you don't have!`, msg.messageId); return; };
|
if (userRecord.balance < amount) { await sendMessage(`You can't give qweribucks you don't have!`, msg.messageId); return; };
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ export default new Command({
|
|||||||
const item = items.get(args[1].toLowerCase());
|
const item = items.get(args[1].toLowerCase());
|
||||||
if (!item) { await sendMessage(`Item ${args[1]} doesn't exist`, msg.messageId); return; };
|
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; };
|
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) || amount < 0) { await sendMessage(`${args[2]} is not a valid amount`); return; };
|
if (isNaN(amount) || amount < 1) { await sendMessage(`${args[2]} is not a valid amount`); return; };
|
||||||
|
|
||||||
const userRecord = await getUserRecord(user);
|
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; };
|
if (userRecord.inventory[item.name]! < amount) { await sendMessage(`You can't give items you don't have!`, msg.messageId); return; };
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default new Command({
|
|||||||
execution: async (msg, user) => {
|
execution: async (msg, user) => {
|
||||||
const args = parseCommandArgs(msg.messageText);
|
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 (!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.
|
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);
|
await handleCheer(msg, bits, user);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user