Пример #1
0
 public async Task ChangeNSFWSettings()
 {
     if (Context.DbGuild.Nsfw)
     {
         await _guildRepo.ModifyAsync(Context.DbGuild, x => x.Nsfw = false);
         await ReplyAsync($"You have successfully disabled NSFW commands!");
     }
     else
     {
         await _guildRepo.ModifyAsync(Context.DbGuild, x => x.Nsfw = true);
         await ReplyAsync($"You have successfully enabled NSFW commands!");
     }
 }
Пример #2
0
        public async Task SetRankRoles(int roleNumber = 0, IRole rankRole = null)
        {
            using (var db = new DbContext())
            {
                var guildRepo = new GuildRepository(db);
                var guild     = await guildRepo.FetchGuildAsync(Context.Guild.Id);

                if ((roleNumber != 1 && roleNumber != 2 && roleNumber != 3 && roleNumber != 4) || rankRole == null)
                {
                    throw new Exception($"You are incorrectly using the `{guild.Prefix}SetRankRoles` command.\n" +
                                        $"Follow up this command with the rank role number and the role to set it to.\n" +
                                        $"Example: `{guild.Prefix}SetRankRoles 1 @FirstRole.`");
                }
                if (rankRole.Position >= Context.Guild.CurrentUser.Roles.OrderByDescending(x => x.Position).First().Position)
                {
                    throw new Exception("You may not set a rank role that is higher in hierarchy than DEA's highest role.");
                }
                if (rankRole.Id == guild.Rank1Id || rankRole.Id == guild.Rank2Id || rankRole.Id == guild.Rank3Id || rankRole.Id == guild.Rank4Id)
                {
                    throw new Exception("You may not set multiple ranks to the same role!");
                }
                switch (roleNumber)
                {
                case 1:
                    await guildRepo.ModifyAsync(x => { x.Rank1Id = rankRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);
                    await ReplyAsync($"You have successfully set the first rank role to {rankRole.Mention}!");

                    break;

                case 2:
                    await guildRepo.ModifyAsync(x => { x.Rank2Id = rankRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);
                    await ReplyAsync($"You have successfully set the second rank role to {rankRole.Mention}!");

                    break;

                case 3:
                    await guildRepo.ModifyAsync(x => { x.Rank3Id = rankRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);
                    await ReplyAsync($"You have successfully set the third rank role to {rankRole.Mention}!");

                    break;

                case 4:
                    await guildRepo.ModifyAsync(x => { x.Rank4Id = rankRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);
                    await ReplyAsync($"You have successfully set the fourth rank role to {rankRole.Mention}!");

                    break;
                }
            }
        }
Пример #3
0
        public async Task AddRank(IRole rankRole, double cashRequired)
        {
            var guild = await GuildRepository.FetchGuildAsync(Context.Guild.Id);

            if (rankRole.Position >= Context.Guild.CurrentUser.Roles.OrderByDescending(x => x.Position).First().Position)
            {
                throw new Exception($"DEA must be higher in the heigharhy than {rankRole.Mention}.");
            }
            if (guild.RankRoles.Any(x => x.RoleId == rankRole.Id))
            {
                throw new Exception("This role is already a rank role.");
            }
            if (guild.RankRoles.Any(x => x.CashRequired == cashRequired))
            {
                throw new Exception("There is already a role set to that amount of cash required.");
            }
            await GuildRepository.ModifyAsync(x => { x.RankRoles.Add(new RankRole()
                {
                    RoleId       = rankRole.Id,
                    CashRequired = cashRequired,
                    GuildId      = guild.Id
                }); return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"You have successfully added the {rankRole.Mention} rank!");
        }
Пример #4
0
        public async Task <bool> TryModLogAsync(Guild dbGuild, IGuild guild, string action, Color color, string reason = "", IUser moderator = null, IUser subject = null, string extraInfoType = "", string extraInfo = "")
        {
            var channel = await guild.GetTextChannelAsync(dbGuild.ModLogChannelId);

            if (channel == null)
            {
                return(false);
            }

            var builder = new EmbedBuilder()
                          .WithColor(color)
                          .WithFooter(x =>
            {
                x.IconUrl = "http://i.imgur.com/BQZJAqT.png";
                x.Text    = $"Case #{dbGuild.CaseNumber}";
            })
                          .WithCurrentTimestamp();

            if (moderator != null)
            {
                builder.WithAuthor(x =>
                {
                    x.IconUrl = moderator.GetAvatarUrl();
                    x.Name    = $"{moderator}";
                });
            }

            var description = $"**Action:** {action}\n";

            if (!string.IsNullOrWhiteSpace(extraInfoType))
            {
                description += $"**{extraInfoType}:** {extraInfo}\n";
            }

            if (subject != null)
            {
                description += $"**User:** {subject} ({subject.Id})\n";
            }

            if (!string.IsNullOrWhiteSpace(reason))
            {
                description += $"**Reason:** {reason}\n";
            }

            builder.WithDescription(description);

            try
            {
                await channel.SendMessageAsync(string.Empty, embed : builder);

                await _guildRepo.ModifyAsync(x => x.Id == dbGuild.Id, x => x.CaseNumber++);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #5
0
 public async Task SetGambleChannel(ITextChannel gambleChannel)
 {
     using (var db = new DbContext())
     {
         var guildRepo = new GuildRepository(db);
         await guildRepo.ModifyAsync(x => { x.GambleChannelId = gambleChannel.Id; return(Task.CompletedTask); }, Context.Guild.Id);
         await ReplyAsync($"{Context.User.Mention}, You have successfully set the gamble channel to {gambleChannel.Mention}!");
     }
 }
Пример #6
0
 public async Task SetModRole(IRole modRole)
 {
     using (var db = new DbContext())
     {
         var guildRepo = new GuildRepository(db);
         await guildRepo.ModifyAsync(x => { x.ModRoleId = modRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);
         await ReplyAsync($"{Context.User.Mention}, You have successfully set the moderator role to {modRole.Mention}!");
     }
 }
Пример #7
0
        public async Task SetPrefix(string prefix)
        {
            if (prefix.Length > 3)
            {
                throw new Exception("The maximum character length of a prefix is 3.");
            }
            await GuildRepository.ModifyAsync(x => { x.Prefix = prefix; return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully set the prefix to {prefix}!");
        }
Пример #8
0
        public async Task SetMutedRole(IRole mutedRole)
        {
            if (mutedRole.Position >= Context.Guild.CurrentUser.Roles.OrderByDescending(x => x.Position).First().Position)
            {
                throw new Exception($"DEA must be higher in the heigharhy than {mutedRole.Mention}.");
            }
            await GuildRepository.ModifyAsync(x => { x.MutedRoleId = mutedRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully set the muted role to {mutedRole.Mention}!");
        }
Пример #9
0
        public async Task RemoveModRole(IRole modRole)
        {
            var guild = await GuildRepository.FetchGuildAsync(Context.Guild.Id);

            if (!guild.ModRoles.Any(x => x.RoleId == modRole.Id))
            {
                throw new Exception("This role is not a moderator role!");
            }
            await GuildRepository.ModifyAsync(x => { x.ModRoles.Remove(guild.ModRoles.Find(y => y.RoleId == modRole.Id)); return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully set the moderator role to {modRole.Mention}!");
        }
Пример #10
0
        public async Task ChangeDMSettings()
        {
            using (var db = new DbContext())
            {
                var guildRepo = new GuildRepository(db);
                switch ((await guildRepo.FetchGuildAsync(Context.Guild.Id)).DM)
                {
                case true:
                    await guildRepo.ModifyAsync(x => { x.DM = false; return(Task.CompletedTask); }, Context.Guild.Id);
                    await ReplyAsync($"{Context.User.Mention}, You have successfully disabled DM messages!");

                    break;

                case false:
                    await guildRepo.ModifyAsync(x => { x.DM = true; return(Task.CompletedTask); }, Context.Guild.Id);
                    await ReplyAsync($"{Context.User.Mention}, You have successfully enabled DM messages!");

                    break;
                }
            }
        }
Пример #11
0
 public async Task SetMutedRole(IRole mutedRole)
 {
     if (mutedRole.Position >= Context.Guild.CurrentUser.Roles.OrderByDescending(x => x.Position).First().Position)
     {
         throw new Exception("You may not set a rank role that is higher in hierarchy than DEA's highest role.");
     }
     using (var db = new DbContext())
     {
         var guildRepo = new GuildRepository(db);
         await guildRepo.ModifyAsync(x => { x.MutedRoleId = mutedRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);
         await ReplyAsync($"{Context.User.Mention}, You have successfully set the muted role to {mutedRole.Mention}!");
     }
 }
Пример #12
0
        public async Task SetNSFWChannel(ITextChannel nsfwChannel)
        {
            await GuildRepository.ModifyAsync(x => { x.NsfwId = nsfwChannel.Id; return(Task.CompletedTask); }, Context.Guild.Id);

            var nsfwRole = Context.Guild.GetRole((ulong)(await GuildRepository.FetchGuildAsync(Context.Guild.Id)).NsfwRoleId);

            if (nsfwRole != null && Context.Guild.CurrentUser.GuildPermissions.Administrator)
            {
                await nsfwChannel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, new OverwritePermissions().Modify(null, null, null, PermValue.Deny));

                await nsfwChannel.AddPermissionOverwriteAsync(nsfwRole, new OverwritePermissions().Modify(null, null, null, PermValue.Allow));
            }
            await ReplyAsync($"{Context.User.Mention}, You have successfully set the NSFW channel to {nsfwChannel.Mention}.");
        }
Пример #13
0
        /// <summary>
        /// If the moderation log channel exists, it will log all moderation commands.
        /// </summary>
        /// <param name="context">The context of the command use.</param>
        /// <param name="action">The action that was taken.</param>
        /// <param name="color">The color of the embed.</param>
        /// <param name="reason">The reason for the action.</param>
        /// <param name="subject">The user in question.</param>
        /// <param name="extra">An extra line for more information.</param>
        public async Task ModLogAsync(DEAContext context, string action, Color color, string reason, IUser subject = null, string extra = "")
        {
            var channel = context.Guild.GetTextChannel(context.DbGuild.ModLogChannelId);

            if (channel == null)
            {
                return;
            }

            EmbedFooterBuilder footer = new EmbedFooterBuilder()
            {
                IconUrl = "http://i.imgur.com/BQZJAqT.png",
                Text    = $"Case #{context.DbGuild.CaseNumber}"
            };
            EmbedAuthorBuilder author = new EmbedAuthorBuilder()
            {
                IconUrl = context.User.GetAvatarUrl(),
                Name    = $"{context.User.Username}#{context.User.Discriminator}"
            };

            string userText = string.Empty;

            if (subject != null)
            {
                userText = $"\n**User:** {subject} ({subject.Id})";
            }

            var description = $"**Action:** {action}{extra}{userText}";

            if (reason != null)
            {
                description += $"\n**Reason:** {reason}";
            }

            var builder = new EmbedBuilder()
            {
                Author      = author,
                Color       = color,
                Description = description,
                Footer      = footer
            }.WithCurrentTimestamp();

            try
            {
                await channel.SendMessageAsync(string.Empty, embed : builder);

                await _guildRepo.ModifyAsync(context.DbGuild, x => x.CaseNumber++);
            }
            catch { }
        }
Пример #14
0
        private void Unmute(object stateObj)
        {
            Task.Run(async() =>
            {
                Logger.Log(LogSeverity.Debug, $"Timers", "Auto Unmute");

                foreach (var mute in await _muteRepo.AllAsync())
                {
                    if (DateTime.UtcNow.Subtract(mute.MutedAt).TotalMilliseconds > mute.MuteLength)
                    {
                        var guild = await(_client as IDiscordClient).GetGuildAsync(mute.GuildId);
                        var user  = await guild.GetUserAsync(mute.UserId);
                        if (guild != null && user != null)
                        {
                            var guildData = await _guildRepo.GetGuildAsync(guild.Id);
                            var mutedRole = guild.GetRole(guildData.MutedRoleId);
                            if (mutedRole != null && user.RoleIds.Any(x => x == mutedRole.Id))
                            {
                                var channel = await guild.GetTextChannelAsync(guildData.ModLogChannelId);
                                ChannelPermissions?perms = null;
                                var currentUser          = await guild.GetCurrentUserAsync();
                                if (channel != null)
                                {
                                    perms = currentUser.GetPermissions(channel as SocketTextChannel);
                                }
                                if (channel != null && currentUser.GuildPermissions.EmbedLinks && perms.Value.SendMessages && perms.Value.EmbedLinks)
                                {
                                    await user.RemoveRoleAsync(mutedRole);
                                    var footer = new EmbedFooterBuilder()
                                    {
                                        IconUrl = "http://i.imgur.com/BQZJAqT.png",
                                        Text    = $"Case #{guildData.CaseNumber}"
                                    };
                                    var embedBuilder = new EmbedBuilder()
                                    {
                                        Color       = new Color(12, 255, 129),
                                        Description = $"**Action:** Automatic Unmute\n**User:** {user} ({mute.UserId})",
                                        Footer      = footer
                                    }.WithCurrentTimestamp();
                                    await _guildRepo.ModifyAsync(guildData, x => x.CaseNumber++);
                                    await channel.SendMessageAsync(string.Empty, embed: embedBuilder);
                                }
                            }
                        }
                        await _muteRepo.RemoveMuteAsync(mute.UserId, mute.GuildId);
                    }
                }
            });
        }
Пример #15
0
        public async Task AddModRole(IRole modRole, int permissionLevel = 1)
        {
            if (permissionLevel < 1 || permissionLevel > 3)
            {
                throw new Exception("Permission levels:\nModeration: 1\nAdministration: 2\nServer Owner: 3");
            }
            await GuildRepository.ModifyAsync(x => { x.ModRoles.Add(new ModRole()
                {
                    RoleId          = modRole.Id,
                    GuildId         = Context.Guild.Id,
                    PermissionLevel = permissionLevel
                }); return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully add {modRole.Mention} as a Moderation role with a permission level of {permissionLevel}.");
        }
Пример #16
0
        private async void OnTimedAutoUnmute(object source, ElapsedEventArgs e)
        {
            using (var db = new DbContext())
            {
                var    guildRepo = new GuildRepository(db);
                var    muteRepo  = new MuteRepository(db);
                Mute[] mutes     = muteRepo.GetAll().ToArray();
                foreach (Mute muted in mutes)
                {
                    if (DateTime.Now.Subtract(DateTime.Parse(muted.MutedAt)).TotalMilliseconds > muted.MuteLength)
                    {
                        var guild = _client.GetGuild(muted.GuildId);
                        if (guild != null && guild.GetUser(muted.UserId) != null)
                        {
                            var guildData = await guildRepo.FetchGuildAsync(guild.Id);

                            var mutedRole = guild.GetRole(guildData.MutedRoleId);
                            if (mutedRole != null && guild.GetUser(muted.UserId).Roles.Any(x => x.Id == mutedRole.Id))
                            {
                                var channel = guild.GetTextChannel(guildData.ModLogChannelId);
                                if (channel != null && guild.CurrentUser.GuildPermissions.EmbedLinks &&
                                    (guild.CurrentUser as IGuildUser).GetPermissions(channel as SocketTextChannel).SendMessages &&
                                    (guild.CurrentUser as IGuildUser).GetPermissions(channel as SocketTextChannel).EmbedLinks)
                                {
                                    await guild.GetUser(muted.UserId).RemoveRoleAsync(mutedRole);

                                    var footer = new EmbedFooterBuilder()
                                    {
                                        IconUrl = "http://i.imgur.com/BQZJAqT.png",
                                        Text    = $"Case #{guildData.CaseNumber}"
                                    };
                                    var builder = new EmbedBuilder()
                                    {
                                        Color       = new Color(12, 255, 129),
                                        Description = $"**Action:** Automatic Unmute\n**User:** {guild.GetUser(muted.UserId)} ({guild.GetUser(muted.UserId).Id})",
                                        Footer      = footer
                                    }.WithCurrentTimestamp();
                                    await guildRepo.ModifyAsync(x => { x.CaseNumber++; return(Task.CompletedTask); }, guild.Id);

                                    await channel.SendMessageAsync("", embed : builder);
                                }
                            }
                        }
                        await muteRepo.RemoveMuteAsync(muted.UserId, muted.GuildId);
                    }
                }
            }
        }
Пример #17
0
        public async Task RemoveRank(IRole rankRole)
        {
            var guild = await GuildRepository.FetchGuildAsync(Context.Guild.Id);

            if (!guild.RankRoles.Any(x => x.RoleId == rankRole.Id))
            {
                throw new Exception("This role is not a rank role.");
            }
            await GuildRepository.ModifyAsync(x =>
            {
                x.RankRoles.Remove(guild.RankRoles.Find(y => y.RoleId == rankRole.Id));
                return(Task.CompletedTask);
            }, Context.Guild.Id);

            await ReplyAsync($"You have successfully added the {rankRole.Mention} rank!");
        }
Пример #18
0
        public async Task ChangeNSFWSettings()
        {
            switch ((await GuildRepository.FetchGuildAsync(Context.Guild.Id)).Nsfw)
            {
            case true:
                await GuildRepository.ModifyAsync(x => { x.Nsfw = false; return(Task.CompletedTask); }, Context.Guild.Id);
                await ReplyAsync($"{Context.User.Mention}, You have successfully disabled NSFW commands!");

                break;

            case false:
                await GuildRepository.ModifyAsync(x => { x.Nsfw = true; return(Task.CompletedTask); }, Context.Guild.Id);
                await ReplyAsync($"{Context.User.Mention}, You have successfully enabled NSFW commands!");

                break;
            }
        }
Пример #19
0
        public static async Task DetailedLog(SocketGuild guild, string actionType, string action, string objectType, string objectName, ulong id, Color color, bool incrementCaseNumber = true)
        {
            using (var db = new DbContext())
            {
                var guildRepo = new GuildRepository(db);
                var guildData = await guildRepo.FetchGuildAsync(guild.Id);

                if (guild.GetTextChannel(guildData.DetailedLogsChannelId) != null)
                {
                    var channel = guild.GetTextChannel(guildData.DetailedLogsChannelId);
                    if (guild.CurrentUser.GuildPermissions.EmbedLinks && (guild.CurrentUser as IGuildUser).GetPermissions(channel as SocketTextChannel).SendMessages &&
                        (guild.CurrentUser as IGuildUser).GetPermissions(channel as SocketTextChannel).EmbedLinks)
                    {
                        string caseText = $"Case #{guildData.CaseNumber}";
                        if (!incrementCaseNumber)
                        {
                            caseText = id.ToString();
                        }
                        EmbedFooterBuilder footer = new EmbedFooterBuilder()
                        {
                            IconUrl = "http://i.imgur.com/BQZJAqT.png",
                            Text    = caseText
                        };

                        string idText = null;
                        if (incrementCaseNumber)
                        {
                            idText = $"\n**Id:** {id}";
                        }
                        var builder = new EmbedBuilder()
                        {
                            Color       = color,
                            Description = $"**{actionType}:** {action}\n**{objectType}:** {objectName}{idText}",
                            Footer      = footer
                        }.WithCurrentTimestamp();

                        await guild.GetTextChannel(guildData.DetailedLogsChannelId).SendMessageAsync("", embed: builder);

                        if (incrementCaseNumber)
                        {
                            await guildRepo.ModifyAsync(x => { x.CaseNumber++; return(Task.CompletedTask); }, guild.Id);
                        }
                    }
                }
            }
        }
Пример #20
0
        public async Task ModLogAsync(Guild dbGuild, IGuild guild, string action, Color color, string reason, IGuildUser moderator, IGuildUser user)
        {
            var logChannel = await guild.GetTextChannelAsync(dbGuild.ModLogChannelId);

            if (logChannel == null)
            {
                return;
            }

            var builder = new EmbedBuilder()
                          .WithColor(color)
                          .WithFooter(x => {
                x.Text = $"Case #{dbGuild.CaseNumber}";
            })
                          .WithCurrentTimestamp();

            if (moderator != null)
            {
                builder.WithAuthor(x => {
                    x.Name = $"{moderator}";
                });
            }

            var description = $"**Action:** {action}\n";

            if (user != null)
            {
                description += $"**User:** {user}\n";
            }

            if (!string.IsNullOrWhiteSpace(reason))
            {
                description += $"**Reason:** {reason}\n";
            }

            builder.WithDescription(description);

            try
            {
                await logChannel.SendMessageAsync(string.Empty, embed : builder.Build());

                await _guildRepository.ModifyAsync(x => x.Id == dbGuild.Id, x => x.CaseNumber++);
            }
            catch {}
        }
Пример #21
0
        public async Task SetNSFWRole(IRole nsfwRole)
        {
            if (nsfwRole.Position > Context.Guild.CurrentUser.Roles.OrderByDescending(x => x.Position).First().Position)
            {
                throw new Exception("You may not set the NSFW role to a role that is higher in hierarchy than DEA's highest role.");
            }
            await GuildRepository.ModifyAsync(x => { x.NsfwRoleId = nsfwRole.Id; return(Task.CompletedTask); }, Context.Guild.Id);

            var nsfwChannel = Context.Guild.GetChannel((ulong)(await GuildRepository.FetchGuildAsync(Context.Guild.Id)).NsfwId);

            if (nsfwChannel != null && Context.Guild.CurrentUser.GuildPermissions.Administrator)
            {
                await nsfwChannel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, new OverwritePermissions().Modify(null, null, null, PermValue.Deny));

                await nsfwChannel.AddPermissionOverwriteAsync(nsfwRole, new OverwritePermissions().Modify(null, null, null, PermValue.Allow));
            }
            await ReplyAsync($"{Context.User.Mention}, You have successfully set the NSFW role to {nsfwRole.Mention}.");
        }
Пример #22
0
 public async Task ChangeAutoTriviaSettings()
 {
     if (Context.DbGuild.AutoTrivia)
     {
         await _guildRepo.ModifyAsync(Context.DbGuild, x => x.AutoTrivia = false);
         await ReplyAsync($"You have successfully disabled auto trivia!");
     }
     else
     {
         await _guildRepo.ModifyAsync(Context.DbGuild, x => x.AutoTrivia = true);
         await ReplyAsync($"You have successfully enabled auto trivia!");
     }
 }
Пример #23
0
        public static async Task ModLog(SocketCommandContext context, string action, Color color, string reason, IUser subject = null, string extra = "")
        {
            using (var db = new DbContext())
            {
                var guildRepo = new GuildRepository(db);
                var guild     = await guildRepo.FetchGuildAsync(context.Guild.Id);

                EmbedFooterBuilder footer = new EmbedFooterBuilder()
                {
                    IconUrl = "http://i.imgur.com/BQZJAqT.png",
                    Text    = $"Case #{guild.CaseNumber}"
                };
                EmbedAuthorBuilder author = new EmbedAuthorBuilder()
                {
                    IconUrl = context.User.GetAvatarUrl(),
                    Name    = $"{context.User.Username}#{context.User.Discriminator}"
                };

                string userText = null;
                if (subject != null)
                {
                    userText = $"\n** User:** { subject} ({ subject.Id})";
                }
                var builder = new EmbedBuilder()
                {
                    Author      = author,
                    Color       = color,
                    Description = $"**Action:** {action}{extra}{userText}\n**Reason:** {reason}",
                    Footer      = footer
                }.WithCurrentTimestamp();

                if (context.Guild.GetTextChannel(guild.ModLogChannelId) != null)
                {
                    await context.Guild.GetTextChannel(guild.ModLogChannelId).SendMessageAsync("", embed: builder);

                    await guildRepo.ModifyAsync(x => { x.CaseNumber++; return(Task.CompletedTask); }, context.Guild.Id);
                }
            }
        }
Пример #24
0
        public async Task AddModRole(IRole modRole, int permissionLevel = 1)
        {
            if (permissionLevel < 1 || permissionLevel > 3)
            {
                ReplyError("Permission levels:\nModeration: 1\nAdministration: 2\nServer Owner: 3");
            }

            if (Context.DbGuild.ModRoles.ElementCount == 0)
            {
                await _guildRepo.ModifyAsync(Context.DbGuild, x => x.ModRoles.Add(modRole.Id.ToString(), permissionLevel));
            }
            else
            {
                if (Context.DbGuild.ModRoles.Any(x => x.Name == modRole.Id.ToString()))
                {
                    ReplyError("You have already set this mod role.");
                }

                await _guildRepo.ModifyAsync(Context.DbGuild, x => x.ModRoles.Add(modRole.Id.ToString(), permissionLevel));
            }

            await ReplyAsync($"You have successfully added {modRole.Mention} as a moderation role with a permission level of {permissionLevel}.");
        }
Пример #25
0
        public async Task SetModLogChannel(ITextChannel modLogChannel)
        {
            await GuildRepository.ModifyAsync(x => { x.ModLogId = modLogChannel.Id; return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully set the moderator log channel to {modLogChannel.Mention}!");
        }
Пример #26
0
        public async Task SetDetailedLogsChannel(ITextChannel detailedLogsChannel)
        {
            await GuildRepository.ModifyAsync(x => { x.DetailedLogsId = detailedLogsChannel.Id; return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully set the detailed logs channel to {detailedLogsChannel.Mention}!");
        }
Пример #27
0
        public async Task SetPrefix([Summary("!")] string prefix)
        {
            if (prefix.Length > 3)
            {
                ReplyError("The maximum character length of a prefix is 3.");
            }

            await _guildRepo.ModifyAsync(Context.DbGuild, x => x.Prefix = prefix);

            await ReplyAsync($"You have successfully set the prefix to {prefix}.");
        }
Пример #28
0
        public async Task SetGambleChannel(ITextChannel gambleChannel)
        {
            await GuildRepository.ModifyAsync(x => { x.GambleId = gambleChannel.Id; return(Task.CompletedTask); }, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully set the gamble channel to {gambleChannel.Mention}!");
        }