<commit_before>const { Command } = require('discord.js-commando');
const stripIndents = require('common-tags').stripIndents;

const Currency = require('../../currency/Currency');
const Roulette = require('../../games/Roulette');

const currency = new Currency();

colors = {
	'red': 0xBE1931,
	'black': 0x0C0C0C
};

module.exports = class RouletteCommand extends Command {
	constructor(client) {
		super(client, {
			name: 'roulette',
			aliases: ['roulette', 'bet'],
			group: 'games',
			memberName: 'roulette',
			description: 'Play a game of roulette for donuts!',
			details: 'Play a game of roulette for donuts.',
			throttling: {
				duration: 60,
				usages: 1
			},
			args: [
				{
					key: 'donuts',
					prompt: 'How many donuts do you want to bet?',
					type: 'integer'
				},
				{
					key: 'space',
					prompt: 'On what space do you want to bet?',
					type: 'string'
				}
			]
		});
	}

	async run(msg, args) {
		const bet = args.donuts;
		const space = args.space.toLowerCase();

		const balance = await currency.getBalance(msg.author.id);
		let roulette = Roulette.findGame(msg.guild.id);

		if (balance < 100) return msg.reply(`you need at least 100 🍩s to bet, but your current account balance is ${balance} 🍩s.`);
		if (![100, 200, 300, 400, 500].includes(bet)) return msg.say('you need to bet either 100, 200, 300, 400 or 500 donuts. Anything else does not work.');

		if (roulette) {
			if (!roulette.hasSpace(space)) return msg.reply('that is not a valid betting space. Use `roulette-info` for more information');
			if (roulette.hasPlayer(msg.author.id)) return msg.reply('you have already put a bet in this game of roulette.');

			roulette.join(msg.author, bet, space);
			currency.removeBalance(msg.author.id, bet);

			return msg.reply(`you have successfully placed your bet of ${bet} on ${space}.`);
		}

		roulette = new Roulette(msg.guild.id);
		roulette.join(msg.author, bet, space);
		currency.removeBalance(msg.author.id, bet);

		return msg.say(stripIndents`
			A new game of roulette has been initiated!
			Use \`roulette <donuts> <space>\` in the next 15 seconds to place your bet.
		`)
			.then(async () => {
				setTimeout(() => msg.say('10 seconds left for you to bet'), 5000);
				setTimeout(() => msg.say('5 more seconds for new people to bet'), 10000);
				setTimeout(() => msg.say('The roulette starts spinning!'), 14500);

				const winners = await roulette.awaitPlayers(20000).filter(player => player.winnings !== 0);

				winners.forEach(winner => {
					currency.addBalance(winner.user.id, winner.winnings)
				});

				return msg.embed({<commit_msg>Add higher buy-in and lower cooldown<commit_after>const { Command } = require('discord.js-commando');
const stripIndents = require('common-tags').stripIndents;

const Currency = require('../../currency/Currency');
const Roulette = require('../../games/Roulette');

const currency = new Currency();

colors = {
	'red': 0xBE1931,
	'black': 0x0C0C0C
};

module.exports = class RouletteCommand extends Command {
	constructor(client) {
		super(client, {
			name: 'roulette',
			aliases: ['roulette', 'bet'],
			group: 'games',
			memberName: 'roulette',
			description: 'Play a game of roulette for donuts!',
			details: 'Play a game of roulette for donuts.',
			throttling: {
				duration: 30,
				usages: 1
			},
			args: [
				{
					key: 'donuts',
					prompt: 'How many donuts do you want to bet?',
					type: 'integer'
				},
				{
					key: 'space',
					prompt: 'On what space do you want to bet?',
					type: 'string'
				}
			]
		});
	}

	async run(msg, args) {
		const bet = args.donuts;
		const space = args.space.toLowerCase();

		const balance = await currency.getBalance(msg.author.id);
		let roulette = Roulette.findGame(msg.guild.id);

		if (balance < 100) return msg.reply(`you need at least 100 🍩s to bet, but your current account balance is ${balance} 🍩s.`);
		if (![100, 200, 300, 400, 500, 1000, 2000, 5000].includes(bet)) return msg.say('you need to bet either 100 - 5000 donuts. Anything else does not work.');

		if (roulette) {
			if (!roulette.hasSpace(space)) return msg.reply('that is not a valid betting space. Use `roulette-info` for more information');
			if (roulette.hasPlayer(msg.author.id)) return msg.reply('you have already put a bet in this game of roulette.');

			roulette.join(msg.author, bet, space);
			currency.removeBalance(msg.author.id, bet);

			return msg.reply(`you have successfully placed your bet of ${bet} on ${space}.`);
		}

		roulette = new Roulette(msg.guild.id);
		roulette.join(msg.author, bet, space);
		currency.removeBalance(msg.author.id, bet);

		return msg.say(stripIndents`
			A new game of roulette has been initiated!
			Use \`roulette <donuts> <space>\` in the next 15 seconds to place your bet.
		`)
			.then(async () => {
				setTimeout(() => msg.say('10 seconds left for you to bet'), 5000);
				setTimeout(() => msg.say('5 more seconds for new people to bet'), 10000);
				setTimeout(() => msg.say('The roulette starts spinning!'), 14500);

				const winners = await roulette.awaitPlayers(16000).filter(player => player.winnings !== 0);

				winners.forEach(winner => {
					currency.addBalance(winner.user.id, winner.winnings)
				});

				return msg.embed({
{'fraction_non_alphanumeric': 0.14793577981651376, 'fraction_numerical': 0.028669724770642203, 'mean_word_length': 3.5504347826086957, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6687777', 'n_tokens_mistral': 2070, 'n_tokens_neox': 1689, 'n_words': 523}