added itemlock command, added TNT item, minor bugfixes

This commit is contained in:
2025-07-02 18:10:28 +02:00
parent ac3f81857f
commit a698cb25d5
11 changed files with 82 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ export default new Command('admindonate', ['admindonate'], 'admin', async msg =>
if (!args[1]) { await sendMessage('Please specify the amount qweribucks you want to give', msg.messageId); return; };
const amount = Number(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 transaction in progress', msg.messageId); return; };
if (await target.itemLock()) { await sendMessage('Cannot give qweribucks: item lock is set', msg.messageId); return; };
await target.setLock();
const data = await changeBalance(target, userRecord, amount);
if (!data) {

View File

@@ -16,7 +16,7 @@ export default new Command('admingive', ['admingive'], 'admin', async msg => {
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)) { await sendMessage(`${args[2]} is not a valid amount`); return; };
if (await target.itemLock()) { await sendMessage('Cannot give item: item transaction in progress', msg.messageId); return; };
if (await target.itemLock()) { await sendMessage('Cannot give item: item lock is set', msg.messageId); return; };
await target.setLock();
const data = await changeItemCount(target, userRecord, item.name, amount);
if (data) {

View File

@@ -10,6 +10,7 @@ export default new Command('donate', ['donate'], 'chatter', async (msg, user) =>
if (!args[0]) { await sendMessage('Please specify a user', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
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]);
@@ -18,7 +19,7 @@ export default new Command('donate', ['donate'], 'chatter', async (msg, 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 (await user.itemLock() || await target.itemLock()) { await sendMessage('Cannot give qweribucks. Please try again!', msg.messageId); return; };
if (await user.itemLock() || await target.itemLock()) { await sendMessage('Cannot give qweribucks', msg.messageId); return; };
await Promise.all([
user.setLock(),

View File

@@ -10,6 +10,7 @@ export default new Command('give', ['give'], 'chatter', async (msg, user) => {
if (!args[0]) { await sendMessage('Please specify a user', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
if (target.username === user.username) { await sendMessage("You can't give yourself items", msg.messageId); return; };
const targetRecord = await getUserRecord(target);
if (!args[1]) { await sendMessage('Please specify an item to give', msg.messageId); return; };
const item = items.get(args[1].toLowerCase());
@@ -21,7 +22,7 @@ export default new Command('give', ['give'], 'chatter', async (msg, 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 (await user.itemLock() || await target.itemLock()) { await sendMessage('Cannot give item. Please try again!', msg.messageId); return; };
if (await user.itemLock() || await target.itemLock()) { await sendMessage('Cannot give item', msg.messageId); return; };
await Promise.all([
user.setLock(),

13
bot/commands/itemlock.ts Normal file
View File

@@ -0,0 +1,13 @@
import { Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('itemlock', ['itemlock'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a chatter to toggle the lock for', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage('Targeted user does not exist', msg.messageId); return; };
const status = await target.itemLock();
status ? await target.clearLock() : await target.setLock();
await sendMessage(`Successfully ${status ? 'cleared' : 'set'} the item lock on ${target.displayName}`, msg.messageId);
}, false);