예제 #1
0
        public Task blacklistAdd(params string[] words)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            d.blacklistedWords.AddRange(words);
            MongoUtil.updateGuildData(d);
            return(Task.CompletedTask);
        }
예제 #2
0
        public Task setCmdPrefix(string p)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            d.prefix = p;
            MongoUtil.updateGuildData(d);
            Context.Guild.CurrentUser.ModifyAsync(c => c.Nickname = $"OpenUtil ({p})");
            Context.Channel.SendMessageAsync($"Set prefix to {p}");
            return(Task.CompletedTask);
        }
예제 #3
0
        public Task blacklistRemove(params string[] words)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            foreach (string word in words)
            {
                d.blacklistedWords.Remove(word);
            }
            MongoUtil.updateGuildData(d);
            return(Task.CompletedTask);
        }
예제 #4
0
        public Task setMutedRole(ulong RoleId = 0)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            if (Context.Guild.GetRole(RoleId) == null)
            {
                Context.Channel.SendMessageAsync("Role not found.");
                return(Task.CompletedTask);
            }
            d.mutedRole = RoleId;
            MongoUtil.updateGuildData(d);
            return(Task.CompletedTask);
        }
예제 #5
0
        public Task ignorechAdd(IMessageChannel channel = null)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            if (channel == null)
            {
                d.ignoredChannelIds.Add(Context.Channel.Id);
            }
            else
            {
                d.ignoredChannelIds.Add(channel.Id);
            }
            MongoUtil.updateGuildData(d);
            return(Task.CompletedTask);
        }
예제 #6
0
        public Task ignorechRemove(IMessageChannel channel = null)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            if (channel == null)
            {
                d.ignoredChannelIds.Remove(Context.Channel.Id);
            }
            else
            {
                //No need to check validity
                d.ignoredChannelIds.Remove(channel.Id);
            }
            MongoUtil.updateGuildData(d);
            return(Task.CompletedTask);
        }
예제 #7
0
        public Task clearWarnings(SocketUser user)
        {
            guildData data = MongoUtil.getGuildData(Context.Guild.Id);

            if (!data.manualModEnabled)
            {
                Context.Channel.SendMessageAsync("Please enable the moderation module to use this command.");
                return(Task.CompletedTask);
            }
            if (data.warnings.ContainsKey(user.Id))
            {
                data.warnings.Remove(user.Id);
            }
            MongoUtil.updateGuildData(data);
            Context.Channel.SendMessageAsync($"Cleared user {user.Username}#{user.Discriminator} of all warnings/infractions.");
            return(Task.CompletedTask);
        }
예제 #8
0
        public Task setAutomod(bool enable)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            d.automodEnabled = enable;
            MongoUtil.updateGuildData(d);
            if (enable)
            {
                Context.Channel.SendMessageAsync($"Automod enabled.\n" +
                                                 $"Add/Remove blacklisted words with `{d.prefix}blacklist-add` and `{d.prefix}blacklist-remove`\n" +
                                                 $"Add/Remove channels that automod should ignore with `{d.prefix}ignorech-add` and `{d.prefix}ignorech-remove`");
            }
            else
            {
                Context.Channel.SendMessageAsync("Automod disabled.");
            }
            return(Task.CompletedTask);
        }
예제 #9
0
        public Task setAutorole(
            [Summary("Id of the role to automatically assign. If left blank it will disable autorole")] ulong roleId  = 0,
            [Summary("Whether the bot should make sure all users have the role, or only give it once")] bool maintain = false)
        {
            guildData d = MongoUtil.getGuildData(Context.Guild.Id);

            if (roleId == 0)
            {
                d.autoRole = null;
                Context.Channel.SendMessageAsync("Autorole disabled");
                return(Task.CompletedTask);
            }
            d.autoRole     = Context.Guild.GetRole(roleId);
            d.maintainRole = maintain;
            MongoUtil.updateGuildData(d);
            Context.Channel.SendMessageAsync($"Set autorole to **{d.autoRole.Name}**");
            return(Task.CompletedTask);
        }
예제 #10
0
        public Task warnUser(SocketUser user)
        {
            guildData data = MongoUtil.getGuildData(Context.Guild.Id);

            if (!data.manualModEnabled)
            {
                Context.Channel.SendMessageAsync("Please enable the moderation module to use this command.");
                return(Task.CompletedTask);
            }
            if (data.warnings.ContainsKey(user.Id))
            {
                data.warnings[user.Id]++;
            }
            else
            {
                data.warnings.Add(user.Id, 1);
            }
            MongoUtil.updateGuildData(data);
            Context.Channel.SendMessageAsync($"Warned user {user.Username}#{user.Discriminator}.\nThey now have {data.warnings[user.Id]} warnings.");
            return(Task.CompletedTask);
        }
예제 #11
0
        public Task addRoleCmd(string cmd, ulong roleId)
        {
            guildData find = MongoUtil.getGuildData(Context.Guild.Id);

            if (find.roleCmds.ContainsKey(cmd))
            {
                Context.Channel.SendMessageAsync("There is already a role command attatched to that. Please try a different one.");
            }
            else   //Allow multiple commands to point to one role
            {
                IRole r = Context.Guild.GetRole(roleId);
                if (r == null)
                {
                    Context.Channel.SendMessageAsync("Role not found!");
                    return(Task.CompletedTask);
                }
                find.roleCmds.Add(cmd, r);
            }
            MongoUtil.updateGuildData(find);
            return(Task.CompletedTask);
        }