Exemplo n.º 1
0
        internal async Task <bool> AddBan(DiscordClient Client, ulong id, DiscordGuild Guild)
        {
            try
            {
                List <ulong> BannedIds = await discordUrie.Config.GetChatBanIdList(Guild);

                if (BannedIds.Any(xr => xr == id))
                {
                    return(false);
                }

                BannedIds.Add(id);
                DiscordUrieGuild GuildSettings = await discordUrie.Config.FindGuildSettings(Guild);

                discordUrie.Config.GuildSettings.Remove(GuildSettings);
                GuildSettings.BannedIds = BannedIds;
                discordUrie.Config.GuildSettings.Add(GuildSettings);
                await GuildSettings.SaveGuild(discordUrie.SQLConn);

                return(true);
            }
            catch (Exception exc)
            {
                Client.Logger.Log(LogLevel.Error, exc, "Error adding ban to list.");
                throw exc;
            }
        }
Exemplo n.º 2
0
        internal async Task <bool> RemoveBan(DiscordClient Client, ulong id, DiscordGuild Guild)
        {
            try
            {
                List <ulong> BannedIds = await discordUrie.Config.GetChatBanIdList(Guild);

                bool removed = BannedIds.Remove(id);


                if (removed)
                {
                    DiscordUrieGuild GuildSettings = await discordUrie.Config.FindGuildSettings(Guild);

                    discordUrie.Config.GuildSettings.Remove(GuildSettings);
                    GuildSettings.BannedIds = BannedIds;
                    discordUrie.Config.GuildSettings.Add(GuildSettings);
                    await GuildSettings.SaveGuild(discordUrie.SQLConn);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exc)
            {
                Client.Logger.Log(LogLevel.Error, $"Error removing chat ban. {exc.Message}");
                throw exc;
            }
        }
Exemplo n.º 3
0
        public async Task <DiscordUrieGuild> FindGuildSettings(DiscordGuild SearchForGuild)
        {
            if (GuildSettings.Any(xr => xr.Id == SearchForGuild.Id))
            {
                return(GuildSettings.First(xr => xr.Id == SearchForGuild.Id));
            }
            else
            {
                DiscordUrieGuild NewDefaultServer = await this.SettingsInstance.CreateGuildDefaultSettings(SearchForGuild);

                GuildSettings.Add(NewDefaultServer);
                await NewDefaultServer.SaveGuild(this.SQLConn);

                return(NewDefaultServer);
            }
        }