예제 #1
0
        public async void LeaveQueue(Discord.User user)
        {
            SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());

            foreach (Discord.Server server in BotUser.Servers)
            {
                if (settingsRepo.lfgStatus(server.Id))
                {
                    var  channel = server.GetChannel(settingsRepo.GetLfgChannel(server.Id));
                    bool found   = false;
                    foreach (var message in channel.Messages)
                    {
                        if (message.Text.Contains(user.ToString()))
                        {
                            await message.Delete();
                        }
                    }
                }
            }
        }
예제 #2
0
        public async void QueuePerson(Summoner summoner, Discord.User user, Discord.Server currentserver, string queue)
        {
            SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());
            string       queuemessage = "***" + user + " from " + currentserver.Name + " queued up for " + queue + " as: ***\n";

            queuemessage += new User.SummonerInfo(commands).GetInfoShort(summoner);
            foreach (Discord.Server server in BotUser.Servers)
            {
                if (settingsRepo.lfgStatus(server.Id))
                {
                    var  channel = server.GetChannel(settingsRepo.GetLfgChannel(server.Id));
                    bool found   = false;
                    foreach (var message in channel.DownloadMessages(100).Result)
                    {
                        if (message.Text.Contains(user.ToString()))
                        {
                            found = true;
                        }
                    }
                    if (found == false)
                    {
                        await channel.SendMessage(queuemessage);
                    }
                }
                else if (server.Id == DiscordIds.AtlasId)
                {
                    foreach (var channel in server.TextChannels)
                    {
                        if (channel.Name.ToLower().Contains(summoner.Region.ToString().ToLower()) && channel.Name.ToLower().Contains("queue"))
                        {
                            await channel.SendMessage(queuemessage);
                        }
                    }
                }
            }
        }
예제 #3
0
        public async void RemoveMessages(Discord.Server server)
        {
            if (server.Id != DiscordIds.AtlasId)
            {
                SettingsRepo      settingsRepo = new SettingsRepo(new SettingsContext());
                Discord.Channel   channel      = server.GetChannel(settingsRepo.GetLfgChannel(server.Id));
                Discord.Message[] temp         = await channel.DownloadMessages(100);

                bool found = false;
                try
                {
                    while (temp.Length > 1 && temp.Last().Text != "queue has been cleared!")
                    {
                        await channel.DeleteMessages(temp);

                        found = true;
                        temp  = await channel.DownloadMessages(100);
                    }
                }
                catch
                {
                    found = true;
                }
                if (found == true)
                {
                    await channel.SendMessage("Queue has been cleared!");
                }
            }
            else if (server.Id == DiscordIds.AtlasId)
            {
                List <Channel> channels = new List <Channel>();
                foreach (var channel in server.TextChannels)
                {
                    if (channel.Name.Contains("queue"))
                    {
                        channels.Add(channel);
                    }
                }
                foreach (var channel in channels)
                {
                    Discord.Message[] temp = await channel.DownloadMessages();

                    bool found = false;
                    try
                    {
                        while (temp.Length > 1 && temp.Last().Text != "queue has been cleared!")
                        {
                            await channel.DeleteMessages(temp);

                            found = true;
                            temp  = await channel.DownloadMessages();
                        }
                    }
                    catch
                    {
                        found = true;
                    }
                    if (found)
                    {
                        await channel.SendMessage("Queue has been cleared!");
                    }
                }
            }
        }