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);
            }
        }
Exemplo n.º 4
0
        private async Task ChatBansEventCall(MessageCreateEventArgs e)
        {
            if (e.Channel.IsPrivate || e.Message.Author.IsBot)
            {
                return;
            }

            DiscordUrieGuild GuildSettings = await this.Config.FindGuildSettings(e.Guild);

            if (GuildSettings.BansEnabled)
            {
                ulong id = e.Author.Id;

                if (GuildSettings.BannedIds.Any(xr => xr == id))
                {
                    await e.Message.DeleteAsync("Chat ban deletion");
                }
            }
        }
Exemplo n.º 5
0
        public async Task <bool> UserAuth(DiscordMember Member)
        {
            if (await UserAuthHigh(Member))
            {
                return(true);
            }

            if ((Member.PermissionsIn(Member.Guild.GetDefaultChannel()) & Permissions.Administrator) == Permissions.Administrator)
            {
                return(true);
            }

            List <ulong>     ServerAdmins  = new List <ulong>();
            DiscordUrieGuild GuildSettings = await discordUrie.Config.FindGuildSettings(Member.Guild);

            ServerAdmins.AddRange(GuildSettings.Admins);

            if (ServerAdmins.Any(xr => xr == Member.Id))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public async Task <List <DiscordUrieTag> > GetTags(DiscordGuild guild)
        {
            DiscordUrieGuild GuildSettings = await FindGuildSettings(guild);

            return(GuildSettings.Tags);
        }
Exemplo n.º 7
0
        public async Task <List <ulong> > GetChatBanIdList(DiscordGuild Guild)
        {
            DiscordUrieGuild GuildSettings = await FindGuildSettings(Guild);

            return(GuildSettings.BannedIds);
        }