Ejemplo n.º 1
0
        public async Task Give(IUser recipient, string sAmount, [Remainder] string str = "")
        {
            int amount = ToastieUtil.ParseAmount(sAmount, (SocketGuildUser)Context.User);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(Context.User.Id, -amount, Context.Guild.Id);
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync(ex.Message);

                return;
            }

            await BalanceDb.AddToasties(recipient.Id, amount, Context.Guild.Id);

            await Context.Channel.SendMessageAsync("", false, ToastieUtil.GiveEmbed(Context.User, recipient, amount).Build());
        }
Ejemplo n.º 2
0
        public async Task BlackjackCommand(string sAmount, [Remainder] string str = "")
        {
            var user = (SocketGuildUser)Context.User;
            var ch   = (SocketTextChannel)Context.Channel;

            if (Blackjack.games.ContainsKey(Context.User))
            {
                await Context.Channel.SendMessageAsync("You are already in a game of blackjack. #" + Blackjack.games[user].Channel.Name);

                return;
            }

            int amount = ToastieUtil.ParseAmount(sAmount, user);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(user.Id, -amount, Context.Guild.Id);
            }
            catch (Exception e)
            {
                await ch.SendMessageAsync(e.Message);

                return;
            }

            if (BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id) < amount)
            {
                string prefix = Program.GetPrefix(Context);
                await Context.Channel.SendMessageAsync("Tch, I don't have enough toasties... I will recover eventually by stealing toasties from all of you. :fox:" +
                                                       $"But if you want to speed up the process you can give me some using the `{prefix}give` or `{prefix}at` commands.");

                await BalanceDb.AddToasties(user.Id, amount, Context.Guild.Id);

                return;
            }

            BlackjackGame game = new BlackjackGame(amount, ch);

            Blackjack.games[user] = game;
            await Blackjack.GameContinue(Context, game);
        }
Ejemplo n.º 3
0
        public async Task BRRewardPool(string amountStr)
        {
            int amount = ToastieUtil.ParseAmount(amountStr, (SocketGuildUser)Context.User);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            var banroulette = BanrouletteDb.GetBanroulette(Context.Channel.Id);

            if (banroulette == null)
            {
                await Context.Channel.SendMessageAsync(":x: There is no running Ban Roulette in this channel.");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(Context.User.Id, -amount, Context.Guild.Id);
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync(ex.Message);

                return;
            }

            banroulette.RewardPool += amount;
            await BanrouletteDb.UpdateBanroulette(banroulette);

            await Context.Channel.SendMessageAsync($"Added {amount} to the reward pool!");
        }
Ejemplo n.º 4
0
        public async Task Flip(string sAmount, string side = "t", [Remainder] string str = "")
        {
            var user = (SocketGuildUser)Context.User;
            var rnd  = new Random();

            side = side.ToLower();

            if (!(side.Equals("t") || side.Equals("h") || side.Equals("tails") || side.Equals("heads")))
            {
                await Context.Channel.SendMessageAsync("Pick heads or tails!");

                return;
            }

            int amount = ToastieUtil.ParseAmount(sAmount, user);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(user.Id, -amount, Context.Guild.Id);
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync(ex.Message);

                return;
            }

            if (BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id) < amount)
            {
                string prefix = Program.GetPrefix(Context);
                await Context.Channel.SendMessageAsync("Tch, I don't have enough toasties... I will recover eventually by stealing toasties from all of you. :fox:" +
                                                       $"But if you want to speed up the process you can give me some using the `{prefix}give` or `{prefix}at` commands.");

                await BalanceDb.AddToasties(user.Id, amount, Context.Guild.Id);

                return;
            }

            if (ToastieUtil.FiftyFifty())
            {
                await BalanceDb.AddToasties(user.Id, amount * 2, Context.Guild.Id);

                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, -amount, Context.Guild.Id);

                string resp = "";
                if (amount >= 50000 && rnd.Next(5) == 1)
                {
                    resp = "Tch... I'll get you next time.";
                }
                await Context.Channel.SendMessageAsync(resp, false, ToastieUtil.FlipWinEmbed(user, amount).Build());
            }
            else
            {
                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, amount, Context.Guild.Id);

                string resp = "";
                if (amount >= 50000 && rnd.Next(5) == 1)
                {
                    resp = "I'll take those.";
                }
                await Context.Channel.SendMessageAsync(resp, false, ToastieUtil.FlipLoseEmbed(user, amount).Build());
            }
        }