Beispiel #1
0
        public async Task CancelBanroyale([Remainder] string str = "")
        {
            var banroyale = await BanroyaleDb.GetBanroyale(Context.Channel.Id);

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

                return;
            }

            await BanroyaleDb.EndBanroyale(banroyale.Id);

            await Context.Channel.SendMessageAsync("*Tch...* Cancelling ban royale.");
        }
Beispiel #2
0
        private static async Task <bool> EndBanroyale(BanroyaleGame br, IEnumerable <SocketGuildUser> users)
        {
            if (users.Count() <= br.Banroyale.WinnerAmount)
            {
                br.Timer.Stop();
                br.Timer.Close();
                await BanroyaleDb.EndBanroyale(br.Banroyale.Id);

                string desc  = "Winners: ";
                int    split = 0;
                if (br.Role.Members.Count() == 0)
                {
                    desc += "Everyone lost! Well done guys, I'm proud of you.";
                }
                else
                {
                    split = br.Banroyale.RewardPool / users.Count();
                    foreach (var user in users)
                    {
                        _     = BalanceDb.AddToasties(user.Id, split, br.Banroyale.GuildId);
                        _     = user.RemoveRoleAsync(br.Role);
                        desc += user.Mention + " ";
                    }
                }
                if (split > 0)
                {
                    desc += $"\nSplitting **{br.Banroyale.RewardPool}** toasties from the reward pool! ({split} each)";
                }

                await br.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(desc).WithTitle("Ban Royale Over!")
                                                  .WithColor(Color.Gold)
                                                  .Build());

                return(true);
            }
            return(false);
        }