コード例 #1
0
        public async Task CreatePredefinedCmd()
        {
            try
            {
                await service.CreateExistingCommands();

                await Context.Channel.SendMessageAsync("Succes");
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #2
0
        public async Task UpdateCmd([Remainder] string input)
        {
            try
            {
                await service.Update(input);

                await Context.Channel.SendMessageAsync("Succes");
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #3
0
ファイル: RaidModule.cs プロジェクト: nillertron/DiscordBot
        //[RequireUserPermission(Discord.GuildPermission.ManageChannels)]
        public async Task CreateRaid([Remainder] string input)
        {
            try
            {
                var raid  = service.Create(input, Context.Message.Author.Id.ToString(), Context.Guild.Id.ToString());
                var embed = Helpers.GetEmbed(raid.RaidTitle, "ID:", raid.Id.ToString()).AddField("Date: ", raid.RaidDay.ToString("dd-MM HH:mm"));
                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message + "Use format: !createraid RAID TITLE - MM/DD/YYYY HH:MM");

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #4
0
ファイル: RaidModule.cs プロジェクト: nillertron/DiscordBot
        public async Task EditRaid([Remainder] string input)
        {
            try
            {
                var raid  = service.Edit(input, Context.Guild.Id.ToString());
                var embed = Helpers.GetEmbed(raid.RaidTitle, "ID:", raid.Id.ToString()).AddField("Date: ", raid.RaidDay.ToString("dd-MM HH:mm"));
                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message + "Use format: !EditRaid RAID TITLE - RaidId - (DD/MM/YYYY HH:MM) date can be left out if no changes are to be made.");

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #5
0
        public async Task UserJoined(SocketGuildUser user)
        {
            try
            {
                var channel = await user.GetOrCreateDMChannelAsync();

                var emb = new EmbedBuilder();
                emb.WithTitle("Welcome amigo!").AddField(user.Username, "Welcome to the guild amigo. I am in charge of making heroics raids. Go to the bot channel to get started or DM me !CMD for help. Have a nice day");
                await channel.SendMessageAsync("", false, emb.Build());
            }
            catch (Exception e)
            {
                var ms = new LogMessageService();
                await ms.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #6
0
        public async Task RemoveRole([Remainder] string input)
        {
            var channel = await Context.User.GetOrCreateDMChannelAsync();

            try
            {
                service.RemoveRole(input, Context.Message.Author.ToString(), Context.Guild.Id.ToString());
                await Context.Channel.SendMessageAsync("Removed role(s) for you!");
            }
            catch (Exception e)
            {
                await channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #7
0
        public async Task AddRoles()
        {
            var channel = await Context.User.GetOrCreateDMChannelAsync();

            try
            {
                service.AddRoles();
                await channel.SendMessageAsync("Done!");
            }
            catch (Exception e)
            {
                await channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #8
0
        public async Task DeleteSignUp(int raidId)
        {
            try
            {
                service.DeleteSignup(raidId, Context.Message.Author.ToString());
                var msg = (RestUserMessage)await Context.Channel.GetMessageAsync(Context.Message.Id);

                await Helpers.ReactToMessage(msg, DefinedEmojis.Stars);
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #9
0
        public async Task SplitGroups(int raidId)
        {
            try
            {
                var channel = await Context.User.GetOrCreateDMChannelAsync();

                var embedList   = new List <EmbedBuilder>();
                int count       = 1;
                int embedCount  = -1;
                int playerCount = 1;
                var avgList     = new List <int>();
                var list        = new List <List <SignUp> >();
                await Task.Run(() =>
                {
                    list = service.SplitGroups(raidId, ref avgList, Context.Guild.Id.ToString());
                });

                list.ForEach(o =>
                {
                    embedList.Add(new EmbedBuilder().WithTitle("Raid group " + count + " Avg ilvl: " + avgList[count - 1] + " Player count: " + list[count - 1].Count));
                    embedCount++;
                    playerCount = 1;
                    o.ForEach(x =>
                    {
                        var player = playerService.GetSpecificPlayer(x.PlayerId);
                        if (playerCount % 25 == 0)
                        {
                            embedList.Add(new EmbedBuilder());
                            embedCount++;
                        }
                        embedList[embedCount].AddField(player.IngameName, player.PClass + " - " + Helpers.GetRoleFromList(player.Roles));
                        playerCount++;
                    });
                    count++;
                });
                embedList.ForEach(async o => await channel.SendMessageAsync("", false, o.Build()));
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #10
0
        public async Task RegisterPlayer([Remainder] string input)
        {
            var channel = await Context.User.GetOrCreateDMChannelAsync();

            try
            {
                var player = await service.RegisterPlayer(input, Context.Message.Author.ToString(), Context.Message.Author.Id.ToString(), Context.Guild.Id.ToString());

                await channel.SendMessageAsync($"Created {player.IngameName} with {player.Ilvl} ilvl, Cloak Level {player.CloakLevel} & mythic + score of {player.MythicScore} with the role {Helpers.GetRoleFromList(player.Roles)} - Class {player.PClass.ToString().Replace('_', ' ')} for Discord User {player.DiscordName}");
            }
            catch (Exception EE)
            {
                await channel.SendMessageAsync(EE.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(EE.Message, EE.StackTrace);
            }
        }
コード例 #11
0
ファイル: RaidModule.cs プロジェクト: nillertron/DiscordBot
        public async Task CreateRaid(int id)
        {
            try
            {
                var raid  = service.DeleteRaid(id, Context.Guild.Id.ToString());
                var embed = Helpers.GetEmbed(raid.RaidTitle, "ID:", raid.Id.ToString()).AddField("Date: ", raid.RaidDay.ToString("dd-MM HH:mm"));
                await Context.Channel.SendMessageAsync("", false, embed.Build());

                await Context.Channel.SendMessageAsync("Raid set inactive");
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message + "Use format: !deleteraid RaidId");

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #12
0
        public async Task UpdatePlayerGuildAndIds()
        {
            var guildid  = Context.Guild.Id;
            var userList = Context.Guild.Users;

            try
            {
                await service.UpdatePlayerGuildAndIds(userList);

                await Context.Channel.SendMessageAsync("Done");
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #13
0
ファイル: RaidModule.cs プロジェクト: nillertron/DiscordBot
        public async Task GetAllInactiveRaids()
        {
            try
            {
                var raidList = service.GetAllInactive(Context.Guild.Id.ToString());
                raidList.ForEach(async o =>
                {
                    var embed = Helpers.GetEmbed(o.RaidTitle, "ID:", o.Id.ToString()).AddField("Date: ", o.RaidDay.ToString("dd-MM HH:mm")).AddField("Sign Ups: ", service.GetRaidSignupCount(o.Id).ToString());
                    await Context.Channel.SendMessageAsync("", false, embed.Build());
                });
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #14
0
        public async Task SignUp([Remainder] string input)
        {
            try
            {
                var signup = service.SignUp(input, Context.Message.Author.ToString(), Context.Guild.Id.ToString());
                var emb    = Helpers.GetEmbed("Signup registred", raidService.GetSpecificRaid(signup.RaidId, Context.Guild.Id.ToString()).RaidTitle, playerService.GetSpecificPlayer(signup.PlayerId).IngameName);
                var msg    = (RestUserMessage)await Context.Channel.GetMessageAsync(Context.Message.Id);

                await Helpers.ReactToMessage(msg, DefinedEmojis.Stars);

                await Context.Channel.SendMessageAsync("", false, emb.Build());
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #15
0
        public async Task GetMyCharacters()
        {
            try
            {
                var liste = service.GetMyCharacters(Context.Message.Author.Id.ToString(), Context.Guild.Id.ToString());
                var emb   = new EmbedBuilder().WithTitle(liste[0].DiscordName + " Characters ");
                liste.ForEach(o =>
                {
                    var s1 = " - This is your main - ";
                    var s2 = "";
                    emb.AddField(o.IngameName + " - " + o.Ilvl.ToString(), "Id: " + o.Id + (o.Main?s1:s2) + " " + Helpers.GetRoleFromList(o.Roles) + " - Cloak level:" + o.CloakLevel + " - M+ Score:" + o.MythicScore);
                });
                await Context.Channel.SendMessageAsync("", false, emb.Build());
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #16
0
        public async Task UnSubscribeRaidChannel()
        {
            var user = Context.Message.Author.ToString();

            if (user != "Nillertron#5220")
            {
                return;
            }
            try
            {
                var ch = Context.Channel;
                await service.UnSubscribeChannel(ch.Id);

                await Context.Channel.SendMessageAsync("Done");
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: nillertron/DiscordBot
        private async Task Startup()
        {
            DBHelper db = new DBHelper();
            var      PM = new PlayerModule();
            var      RS = new RaidService();

            PM.UpdateAll();
            var list = db.GetAllSubscribedChannels();
            var ss   = new SubscribedChannelService();

            if (list.Count != 0)
            {
                list = list.Where(x => x.Type == SubscribeType.Raid).ToList();
                list.ForEach(async o => await ss.Attach(o));
            }
            ss.ObserveRaids();
            RS.ObserveThread();
            var player     = db.GetAll <Player>().Where(o => o.DiscordName == "Nillertron#5220").FirstOrDefault();
            var msgService = new LogMessageService();
            await msgService.Attach(player);

            var guildService = new GuildService();
        }
コード例 #18
0
ファイル: KeyModule.cs プロジェクト: nillertron/DiscordBot
        public async Task GetKeys()
        {
            try
            {
                var channel = await Context.User.GetOrCreateDMChannelAsync();

                var KeyList = ks.GetAllKeys();


                var eb = new EmbedBuilder().WithTitle("Keys:");
                KeyList.ForEach(o =>
                {
                    eb.AddField(o.UserName, o.Key + " " + o.KeyLevel).WithCurrentTimestamp();
                });
                await channel.SendMessageAsync("", false, eb.Build());
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }
コード例 #19
0
        public async Task SplitFromThreadGroups(List <List <SignUp> > list, string RaidOwnerDiscordId, List <int> avgList)
        {
            try
            {
                var channel = await Program.Client.GetUser(Convert.ToUInt64(RaidOwnerDiscordId)).GetOrCreateDMChannelAsync();

                var embedList     = new List <EmbedBuilder>();
                int count         = 1;
                int embedCount    = -1;
                int playerCount   = 1;
                var RaidLeaderDic = new Dictionary <int, Player>();
                list.ForEach(o =>
                {
                    embedList.Add(new EmbedBuilder().WithTitle("Raid group " + count + " Avg ilvl: " + avgList[count - 1] + " Player count: " + list[count - 1].Count));
                    embedCount++;
                    playerCount = 1;
                    o.ForEach(x =>
                    {
                        var player = playerService.GetSpecificPlayer(x.PlayerId);
                        if (player.Roles.Contains(Role.RaidLeader))
                        {
                            RaidLeaderDic.Add(count, player);
                        }
                        if (playerCount % 25 == 0)
                        {
                            embedList.Add(new EmbedBuilder());
                            embedCount++;
                        }
                        embedList[embedCount].AddField(player.IngameName, player.PClass + " - " + Helpers.GetRoleFromList(player.Roles));
                        playerCount++;
                    });
                    count++;
                });
                int lastKey  = 0;
                var RLString = "";
                foreach (var player in RaidLeaderDic)
                {
                    if (player.Key == lastKey)
                    {
                        continue;
                    }
                    else
                    {
                        var ch = await Program.Client.GetUser(Convert.ToUInt64(player.Value.UserId)).GetOrCreateDMChannelAsync();

                        await ch.SendMessageAsync("Beep boop, you are assigned raid leader for group " + player.Key + " here is a list of players for you to invite");

                        await ch.SendMessageAsync("", false, embedList[player.Key - 1].Build());

                        lastKey   = player.Key;
                        RLString += "Group: " + player.Key + " - " + player.Value.IngameName + "\n";
                    }
                }
                await channel.SendMessageAsync("Your raid leaders today are:\n" + RLString);

                embedList.ForEach(async o => await channel.SendMessageAsync("", false, o.Build()));
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync(e.Message);

                var lm = new LogMessageService();
                await lm.CreateLogEntry(e.Message, e.StackTrace);
            }
        }