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

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

                return;
            }

            var    reqRole      = Context.Guild.GetRole(banroyale.RoleReqId);
            var    role         = Context.Guild.GetRole(banroyale.ParticipantRoleId);
            var    users        = role.Members.ToList();
            string participants = users.Count > 0 ? $"\n\nParticipants:\n{BanroyaleUtil.BanroyaleParticipants(users.Select(x => x.Username).ToList())}" : "";
            await Context.Channel.SendMessageAsync(embed : BanroyaleUtil.BanroyaleDetailsEmbed(banroyale, Context.Guild.GetRole(banroyale.ParticipantRoleId), Context.Guild.GetRole(banroyale.RoleReqId), users.Count).Build());
        }
Exemple #2
0
        public async Task NewBanroyale([Remainder] string roleName = "")
        {
            var banroyale = await BanroyaleDb.GetBanroyale(Context.Channel.Id);

            if (banroyale != null)
            {
                await Context.Channel.SendMessageAsync($":x: There is already a running Ban Royale in this channel. Type `{Program.GetPrefix(Context)}cbrl` to cancel it.");

                return;
            }

            SocketRole role = null;

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

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

            var roleId = await BanroyaleDb.GetRoleId(Context.Guild.Id);

            if (roleId != 0)
            {
                try
                {
                    roleId = Context.Guild.GetRole(roleId).Id;
                } catch
                {
                    roleId = 0;
                }
            }

            if (roleId == 0)
            {
                var newRole = await Context.Guild.CreateRoleAsync("Namiko-Banroyale", null, Color.Red, false, false, null);

                roleId = newRole.Id;
                await ReplyAsync($"Creating a role - {newRole.Mention}. It will be used to track the Ban Royale participants automatically by assigning/removing the role to/from them.\n" +
                                 $"You can change the name and the color of the role. But make sure it is lower in the role list than my bot role, Senpai.");
            }

            banroyale = new Banroyale
            {
                Active            = true,
                BanLengthHours    = 0,
                ChannelId         = Context.Channel.Id,
                MaxParticipants   = 0,
                MinParticipants   = 0,
                RewardPool        = 0,
                GuildId           = Context.Guild.Id,
                RoleReqId         = role == null ? 0 : role.Id,
                Kick              = false,
                WinnerAmount      = 1,
                ParticipantRoleId = roleId,
                MinFrequency      = 10,
                MaxFrequency      = 20
            };

            string prefix = Program.GetPrefix(Context);
            await BanroyaleDb.AddBanroyale(banroyale);

            await Context.Channel.SendMessageAsync("Setting up a new game of Ban Royale! It's on." +
                                                   $"\n\n**More settings:**" +
                                                   $"\n`{prefix}sbrlrp` - set reward pool" +
                                                   $"\n`{prefix}sbrlw` - set amount of winners" +
                                                   $"\n`{prefix}sbrlminp` - minimum participants" +
                                                   $"\n`{prefix}sbrlmaxp` - maximum participants" +
                                                   $"\n`{prefix}sbrlban` - set loser ban duration" +
                                                   $"\n`{prefix}sbrlkick` - set loser kick" +
                                                   $"\n`{prefix}sbrlminf` - set min message frequency in seconds" +
                                                   $"\n`{prefix}sbrlmaxf` - set max message frequency in seconds" +
                                                   $"\n\n*Type `{prefix}jbrl` to join the game.*" +
                                                   $"\n*Type `{prefix}startbrl` to start the game after some players join.*" +
                                                   $"\n*Type `{prefix}brl` to view current settings.*",
                                                   embed : BanroyaleUtil.BanroyaleDetailsEmbed(banroyale, Context.Guild.GetRole(banroyale.ParticipantRoleId), Context.Guild.GetRole(banroyale.RoleReqId)).Build());
        }