mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
add grenade cheer, minor tnt cheer fix
This commit is contained in:
25
src/cheers/grenade.ts
Normal file
25
src/cheers/grenade.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { redis } from "bun";
|
||||
import { sendMessage } from "../commands";
|
||||
import { timeout } from "../lib/timeout";
|
||||
import { User } from "../user";
|
||||
import { getUserRecord } from "../db/dbUser";
|
||||
import { createTimeoutRecord } from "../db/dbTimeouts";
|
||||
import { Cheer, handleNoTarget } from ".";
|
||||
|
||||
const ITEMNAME = 'grenade';
|
||||
|
||||
export default new Cheer(ITEMNAME, 99, async (msg, user) => {
|
||||
const targets = await redis.keys(`user:*:vulnerable`);
|
||||
if (targets.length === 0) { await sendMessage('No vulnerable chatters to blow up!', msg.messageId); await handleNoTarget(msg, user, ITEMNAME); return; };
|
||||
const selection = targets[Math.floor(Math.random() * targets.length)]!;
|
||||
const target = await User.initUserId(selection.slice(5, -11));
|
||||
|
||||
await getUserRecord(target!); // make sure the user record exist in the database
|
||||
|
||||
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`),
|
||||
createTimeoutRecord(user, target!, ITEMNAME)
|
||||
]);
|
||||
});
|
||||
@@ -11,7 +11,7 @@ const ITEMNAME = 'tnt';
|
||||
|
||||
export default new Cheer('tnt', 1000, async (msg, user) => {
|
||||
const vulntargets = await redis.keys('user:*:vulnerable').then(a => a.map(b => b.slice(5, -11)));
|
||||
if (vulntargets.length === 0) { await sendMessage('No vulnerable chatters to blow up', msg.messageId); handleNoTarget(msg, user, ITEMNAME); return; };
|
||||
if (vulntargets.length === 0) { await sendMessage('No vulnerable chatters to blow up', msg.messageId); await handleNoTarget(msg, user, ITEMNAME); return; };
|
||||
const targets = getTNTTargets(vulntargets);
|
||||
|
||||
await Promise.all(targets.map(async targetid => {
|
||||
|
||||
Reference in New Issue
Block a user