mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-18 21:11:39 +01:00
add roulette command
This commit is contained in:
@@ -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
|
||||
|
||||
20
src/commands/roulette.ts
Normal file
20
src/commands/roulette.ts
Normal file
@@ -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)
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user