예제 #1
0
        public BanroyaleGame(Banroyale banroyale, ISocketMessageChannel channel, SocketRole role)
        {
            Banroyale = banroyale;
            Channel   = channel;
            Role      = role;
            Waiting   = false;

            double interval = new Random().Next(Banroyale.MaxFrequency - Banroyale.MinFrequency) + Banroyale.MinFrequency;

            Timer           = new Timer(interval * 1000);
            Timer.Elapsed  += Timer_SendNextMessageEvent;
            Timer.AutoReset = false;
            Timer.Start();
        }
예제 #2
0
        public static EmbedBuilder BanroyaleDetailsEmbed(Banroyale banroyale, SocketRole role, SocketRole reqRole, int userCount = 0)
        {
            string desc = "";

            if (banroyale.BanLengthHours > 0)
            {
                desc += $":calendar_spiral: Ban Length: *{banroyale.BanLengthHours} hours.*\n";
            }
            if (banroyale.Kick)
            {
                desc += $":hiking_boot: Losers kicked.\n";
            }
            if (banroyale.RewardPool > 0)
            {
                desc += $"<:toastie3:454441133876183060> Reward Pool: **{banroyale.RewardPool}**\n";
            }
            if (banroyale.RoleReqId != 0)
            {
                desc += $":star: Required Role: **{reqRole.Mention}**\n";
            }
            desc += $":star: Participant Role: **{role.Mention}**\n";

            desc += $":hammer: Participants:  ";
            if (banroyale.MinParticipants > 0)
            {
                desc += $"`Min: {banroyale.MinParticipants}`  ";
            }
            if (banroyale.MaxParticipants > 0)
            {
                desc += $"`Max: {banroyale.MaxParticipants}`  ";
            }
            desc += $"`Current: {userCount}`\n";
            desc += $":star2: Number of winners: **{banroyale.WinnerAmount}**\n";

            desc += $"\n:timer: Message frequency: **{banroyale.MinFrequency} - {banroyale.MaxFrequency} seconds**";

            var eb = new EmbedBuilderPrepared(desc)
                     .WithTitle("Ban Royale");

            return(eb);
        }
예제 #3
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());
        }