Beispiel #1
0
        private static async void Timer_Unban(object sender, ElapsedEventArgs e)
        {
            var bans = await BanDb.ToUnban();

            foreach (var x in bans)
            {
                Console.WriteLine("Unbanning " + x.UserId);
                await BanDb.EndBan(x.UserId, x.ServerId);

                try
                {
                    await Program.GetClient().GetGuild(x.ServerId).RemoveBanAsync(x.UserId);
                }
                catch { }
            }
        }
Beispiel #2
0
        public async Task EndBanroulette()
        {
            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;
            }

            var userIds = BanrouletteDb.GetParticipants(banroulette);

            if (userIds.Count < banroulette.MinParticipants)
            {
                await Context.Channel.SendMessageAsync($"Not enough participants! {userIds.Count}/{banroulette.MinParticipants}");

                return;
            }

            var users = BasicUtil.UserList(Context.Client, userIds);
            var user  = users[new Random().Next(users.Count)];

            var ban = new BannedUser
            {
                Active       = true,
                ServerId     = Context.Guild.Id,
                UserId       = user.Id,
                DateBanStart = DateTime.UtcNow,
                DateBanEnd   = DateTime.UtcNow.AddHours(banroulette.BanLengthHours)
            };

            string msg = $"{user.Mention} won! Bai baaaaaai! See you in {banroulette.BanLengthHours} hours!\n\n";

            users.Remove(user);
            if (users.Count > 0 && banroulette.RewardPool > 0)
            {
                int prize = banroulette.RewardPool / users.Count;
                msg += $"Prize pool of {banroulette.RewardPool} ({prize} each) split between: ";
                foreach (var x in users)
                {
                    await BalanceDb.AddToasties(x.Id, prize, Context.Guild.Id);

                    msg += x.Mention + " ";
                }
            }
            await Context.Channel.SendMessageAsync(msg);

            await user.SendMessageAsync($"You won the ban roulette! You are banned from **{Context.Guild.Name}** for {banroulette.BanLengthHours} hours! Bai baaaai!");

            await BanrouletteDb.EndBanroulette(banroulette.Id);

            if (banroulette.BanLengthHours > 0)
            {
                await BanDb.AddBan(ban);

                try
                {
                    await Context.Guild.AddBanAsync(user, 0, $"Banroulette {banroulette.Id}, {banroulette.BanLengthHours} hours.");
                } catch { }
                {
                    await Context.Channel.SendMessageAsync($"I couldn't ban {user}, they are too powerful. *Wipes off blood.* This usually means that their role is higher than mine.");
                }
            }
        }