aboutsummaryrefslogtreecommitdiff
path: root/src/commands/fun/coinflip.ts
blob: 83de5baf93d19f340077b0861c26ef82f63ec77b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';

export default class CoinFlipCommand extends BushCommand {
	public constructor() {
		super('coinflip', {
			aliases: ['coinflip', 'cf'],
			category: 'fun',
			description: {
				content: 'Flip a virtual coin.',
				usage: ['coinflip'],
				examples: ['coinflip']
			},
			clientPermissions: (m) => util.clientSendAndPermCheck(m),
			userPermissions: [],
			slash: true
		});
	}

	public override async exec(message: BushMessage | BushSlashMessage) {
		const random = Math.random();
		let result: string;
		const fall = message.author.id === '322862723090219008' ? 0.1 : 0.001; //dw about it
		if (random < fall) result = 'The coin fell off the table :(';
		else if (random <= 0.5 + fall / 2) result = 'Heads';
		else result = 'Tails';
		await message.util.reply(result);
	}
}