From 77a75a1eb9889269acbc2c07c6732f664d63eafa Mon Sep 17 00:00:00 2001 From: qwerinope Date: Sun, 20 Jul 2025 00:41:20 +0100 Subject: [PATCH] add roulette command --- README.md | 1 + src/commands/roulette.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/commands/roulette.ts diff --git a/README.md b/README.md index 0007ad3..05771e3 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ COMMAND|FUNCTION|USER|ALIASES|DISABLEABLE `ping`|Testing command|anyone|`ping`|:white_check_mark: `yabai`|Random number|anyone|`yabai` `goon`|:white_check_mark: `seiso`|Random number|anyone|`seiso`|:white_check_mark: +`roulette`|Play russian roulette for a 5 minute timeout|anyone|`roulette`|:white_check_mark: `timeout {target}`|Times targeted user out for 60 seconds (costs 100 qweribucks)|anyone|`timeout`|:white_check_mark: ### Qweribucks commands diff --git a/src/commands/roulette.ts b/src/commands/roulette.ts new file mode 100644 index 0000000..0298e8e --- /dev/null +++ b/src/commands/roulette.ts @@ -0,0 +1,20 @@ +import { Command, sendMessage } from "."; +import { redis } from "bun"; +import { timeout } from "../lib/timeout"; + +const barrelCount = 6; + +export default new Command('roulette', ['roulette'], 'chatter', async (msg, user) => { + if (!await redis.exists('rouletteCount')) await redis.set('rouletteCount', "0"); + const currentChamber = Number(await redis.get('rouletteCount')); + const shot = Math.random() < 1 / (barrelCount - currentChamber); + if (!shot) await Promise.all([ + redis.incr('rouletteCount'), + sendMessage("SWEAT Click SWEAT", msg.messageId) + ]); + else await Promise.all([ + redis.set('rouletteCount', "0"), + sendMessage("wybuh BANG!! wybuh"), + timeout(user, "You lost at russian roulette!", 5 * 60) + ]); +});