mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-20 05:51:39 +01:00
add inventory, give and admingive commands. Handle user records in database and minor bugfixes
This commit is contained in:
@@ -1,22 +1,31 @@
|
||||
import { redis } from "bun";
|
||||
import { sendMessage } from "../commands";
|
||||
import { timeout } from "../lib/timeout";
|
||||
import { Item } from ".";
|
||||
import { changeItemCount, Item } from ".";
|
||||
import { User } from "../user";
|
||||
import { getUserRecord } from "../db/dbUser";
|
||||
|
||||
export default new Item('grenade', 'Grenade', 's',
|
||||
const ITEMNAME = 'grenade';
|
||||
|
||||
export default new Item(ITEMNAME, 'Grenade', 's',
|
||||
'Give a random chatter a 60s timeout',
|
||||
['grenade'],
|
||||
['moderator:manage:banned_users'],
|
||||
async (msg, user) => {
|
||||
const userObj = await getUserRecord(user);
|
||||
if (userObj.inventory[ITEMNAME]! < 1) { await sendMessage(`You don't have any grenades!`, msg.messageId); return; };
|
||||
const targets = await redis.keys('vulnchatters:*');
|
||||
if (targets.length === 0) { await sendMessage('No vulnerable chatters to blow up', msg.messageId); return; };
|
||||
const selection = targets[Math.floor(Math.random() * targets.length)]!;
|
||||
const target = await User.initUserId(selection.split(':')[1]!);
|
||||
if (await user.itemLock()) { await sendMessage('Can\'t use two items at once pepeW', msg.messageId); return; };
|
||||
await user.setLock();
|
||||
await Promise.all([
|
||||
timeout(target!, `You got hit by ${user.displayName}'s grenade!`, 60),
|
||||
redis.del(selection),
|
||||
sendMessage(`wybuh ${target?.displayName} got hit by ${user.displayName}'s grenade wybuh`)
|
||||
sendMessage(`wybuh ${target?.displayName} got hit by ${user.displayName}'s grenade wybuh`),
|
||||
changeItemCount(user, userObj, ITEMNAME)
|
||||
]);
|
||||
await user.clearLock();
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user