Beispiel #1
0
        public async Task Banroulette()
        {
            var banroulette = BanrouletteDb.GetBanroulette(Context.Channel.Id);

            if (banroulette == null)
            {
                await Context.Channel.SendMessageAsync($"There is no running Ban Roulette in this channel. `{Program.GetPrefix(Context)}nbr` to start a new one.");

                return;
            }

            var    users        = BasicUtil.UserList(Context.Client, BanrouletteDb.GetParticipants(banroulette));
            var    role         = Context.Guild.GetRole(banroulette.RoleReqId);
            string participants = users.Count > 0 ? $"\n\nParticipants:\n{BanrouletteUtil.BanrouletteParticipants(users)}" : "";
            await Context.Channel.SendMessageAsync($"{BanrouletteUtil.BanrouletteDetails(banroulette, role, users.Count)}" + participants);
        }
Beispiel #2
0
        public async Task JoinBanroulette()
        {
            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;
            }

            if (banroulette.RoleReqId != 0)
            {
                var user = Context.User as SocketGuildUser;
                if (!user.Roles.Any(x => x.Id == banroulette.RoleReqId))
                {
                    await Context.Channel.SendMessageAsync(":x: You do not have the required role to join!");

                    return;
                }
            }


            var userIds = BanrouletteDb.GetParticipants(banroulette);

            if (userIds.Count >= banroulette.MaxParticipants - 1 && banroulette.MaxParticipants != 0)
            {
                await Context.Channel.SendMessageAsync("Ban Roulette is full!");

                return;
            }

            bool joined = await BanrouletteDb.AddParticipant(Context.User.Id, banroulette);

            if (!joined)
            {
                await Context.Channel.SendMessageAsync("You are already participating! Eager to get smoked, aren't you?");

                return;
            }

            var users = BasicUtil.UserList(Context.Client, userIds);

            users.Add(Context.User);
            string response = "You joined the Ban Roulette. *Heh.*" + (users.Count > 10 ? "" : "\n\nList of Participants:\n" + BanrouletteUtil.BanrouletteParticipants(users));
            await Context.Channel.SendMessageAsync(response);
        }
Beispiel #3
0
        public async Task NewBanroulette(int hours, [Remainder] string roleName = "")
        {
            if (hours < 0)
            {
                throw new IndexOutOfRangeException();
            }

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

            if (banroulette != null)
            {
                await Context.Channel.SendMessageAsync(":x: There is already a running Ban Roulette in this channel. Type `!ebr` to end it.");

                return;
            }

            SocketRole role = null;

            if (roleName != "")
            {
                role = await this.SelectRole(roleName);

                if (role == null)
                {
                    return;
                }
            }

            banroulette = new Banroulette
            {
                Active          = true,
                BanLengthHours  = hours,
                ChannelId       = Context.Channel.Id,
                MaxParticipants = 0,
                MinParticipants = 0,
                RewardPool      = 0,
                ServerId        = Context.Guild.Id,
                RoleReqId       = role == null ? 0 : role.Id
            };

            string prefix = Program.GetPrefix(Context);
            await BanrouletteDb.NewBanroulette(banroulette);

            await Context.Channel.SendMessageAsync("Started a new game of Ban Roulette! It's on.\n\n" + BanrouletteUtil.BanrouletteDetails(banroulette, role) +
                                                   $"\n\n**More settings:**" +
                                                   $"\n`{prefix}sbrrp` - set reward pool" +
                                                   $"\n`{prefix}sbrmin` - minimum participants" +
                                                   $"\n`{prefix}sbrmax` - maximum participants" +
                                                   $"\n\n*Type `{prefix}jbr` to join the game.*");
        }