Пример #1
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!");
                    }
                }
            }
        }
Пример #2
0
        private bool IsInvalidChannelsInDict(Dictionary<string, RestrictionData> dict, Server server,
            out ulong invalidId)
        {
            foreach (var pair in dict)
            {
                foreach (ulong channelId in pair.Value.ChannelRestrictions)
                {
                    if (server.GetChannel(channelId) == null)
                    {
                        invalidId = channelId;
                        return true;
                    }
                }
            }

            invalidId = ulong.MinValue;
            return false;
        }