diff --git a/language/languages/en_us/settings/en_us_moderation.lang b/language/languages/en_us/settings/en_us_moderation.lang new file mode 100644 index 0000000..6e5f75e --- /dev/null +++ b/language/languages/en_us/settings/en_us_moderation.lang @@ -0,0 +1,86 @@ +//modlogs setting + +[S_MODLOGS_DESCRIPTION] +Define the channel to which moderation logs are sent. The setting also allows you to exclude types of actions from being logged in the channel. + +[S_MODLOGS_CHANNEL404] +{val} does not resolve into a channel. + +[S_MODLOGS_CHANNEL_SUCCESS] +Successfully set the modlogs channel to {channel}. + +[S_MODLOGS_EXCLUDE404] +Missing arguments. + +//mute Setting + +[S_MUTE_DESCRIPTION] +Assign or create a muted role and choose mute functionality for your guild. +__Mute Types__ +**`0`:** Mutes only add/remove the muted role. *(default)* +**`1`:** Mutes remove all roles except for the muted role. +**`2`:** Mutes remove all roles, does not require a muted role. + +[S_MUTE_TYPENAN] +The argument provided is not a number! The available types are: `0`, `1`, or `2`. +View `{prefix}setting mute` for more help. + +[S_MUTE_TYPEINVALID] +The argument provided is not a valid type! The available types are: `0`, `1`, or `2`. +View `{prefix}setting mute` for more help. + +[S_MUTE_TYPESUCCESS] +Successfully set the **mute type** to `{type}`. + +[S_MUTE_TYPESWITCH] +switch({type}) { + case 0: + "Mutes will now *only add/remove* the muted role."; + break; + case 1: + "Mutes will now *remove all roles except for the muted role*, and then add them back once done."; + break; + case 2: + "Mutes will now *remove all roles* and then add them back once done."; + break; +} + +[S_MUTE_ROLEMISSINGPERMISSION] +The bot *must have* the `MANAGE_ROLES` permission to create a new mute role. + +[S_MUTE_ROLEPROMPT] +Found an existing role named **{name}** `({id})`, would you like to use it and update these roles permissions? +Answering no will create a new role with updated permissions. *(__y__es, __n__o)* +This prompt will time out in __30 seconds__. + +[S_MUTE_ROLEPROMPTERROR] +You provided an invalid input, please try again. + +[S_MUTE_ROLECREATEERROR] +The bot encountered an issue while creating a role for the guild. + +[S_MUTE_ROLEMISSING] +Cannot find a specified role with those arguments. +To create a new role, try `{prefix}setting createmute Muted` + +[S_MUTE_ROLESUCCESS] +Successfully {type} the **mute role** to `{role}`. + +[S_MUTE_GENERATEDPERMISSIONS] +**Permissions have been applied to all possible channels.** + +[S_MUTE_UNGENERATEDPERMISSIONS] +**None of the permissions have been changed.** + + +[S_MUTEDROLE_MISSINGPERMISSION] +The bot must have the `MANAGE_ROLES` permission to create a new muted role in the guild. + +[S_MUTEDROLE_ERRORCREATE] +There was an issue creating the muted role for your guild. + +[S_MUTEDROLE_CANNOTFIND] +I cannot find a role name with those arguments. If you would like to create a new one, use the command `{prefix}settings mute create`. + +[S_MUTEDROLE_SUCCESS] +Successfully set the muted role to `{role}`. \ No newline at end of file diff --git a/language/languages/en_us/settings/en_us_utility.lang b/language/languages/en_us/settings/en_us_utility.lang index c529f98..1864f0f 100644 --- a/language/languages/en_us/settings/en_us_utility.lang +++ b/language/languages/en_us/settings/en_us_utility.lang @@ -18,93 +18,7 @@ The guild prefix cannot include spaces. [S_GUILDPREFIX_RESET] Successfully reset the guild prefix to `{prefix}`. -//mute Setting -[S_MUTE_DESCRIPTION] -Assign or create a muted role and choose mute functionality for your guild. -__Mute Types__ -**`0`:** Mutes only add/remove the muted role. *(default)* -**`1`:** Mutes remove all roles except for the muted role. -**`2`:** Mutes remove all roles, does not require a muted role. - -[S_MUTE_TYPENAN] -The argument provided is not a number! The available types are: `0`, `1`, or `2`. -View `{prefix}setting mute` for more help. - -[S_MUTE_TYPEINVALID] -The argument provided is not a valid type! The available types are: `0`, `1`, or `2`. -View `{prefix}setting mute` for more help. - -[S_MUTE_TYPESUCCESS] -Successfully set the **mute type** to `{type}`. - -[S_MUTE_TYPESWITCH] -switch({type}) { - case 0: - "Mutes will now *only add/remove* the muted role."; - break; - case 1: - "Mutes will now *remove all roles except for the muted role*, and then add them back once done."; - break; - case 2: - "Mutes will now *remove all roles* and then add them back once done."; - break; -} - -[S_MUTE_ROLEMISSINGPERMISSION] -The bot *must have* the `MANAGE_ROLES` permission to create a new mute role. - -[S_MUTE_ROLEPROMPT] -Found an existing role named **{name}** `({id})`, would you like to use it and update these roles permissions? -Answering no will create a new role with updated permissions. *(__y__es, __n__o)* -This prompt will time out in __30 seconds__. - -[S_MUTE_ROLEPROMPTERROR] -You provided an invalid input, please try again. - -[S_MUTE_ROLECREATEERROR] -The bot encountered an issue while creating a role for the guild. - -[S_MUTE_ROLEMISSING] -Cannot find a specified role with those arguments. -To create a new role, try `{prefix}setting createmute Muted` - -[S_MUTE_ROLESUCCESS] -Successfully {type} the **mute role** to `{role}`. - -[S_MUTE_GENERATEDPERMISSIONS] -**Permissions have been applied to all possible channels.** - -[S_MUTE_UNGENERATEDPERMISSIONS] -**None of the permissions have been changed.** - - - - - - - - - - - - - - - - - -[S_MUTEDROLE_MISSINGPERMISSION] -The bot must have the `MANAGE_ROLES` permission to create a new muted role in the guild. - -[S_MUTEDROLE_ERRORCREATE] -There was an issue creating the muted role for your guild. - -[S_MUTEDROLE_CANNOTFIND] -I cannot find a role name with those arguments. If you would like to create a new one, use the command `{prefix}settings mute create`. - -[S_MUTEDROLE_SUCCESS] -Successfully set the muted role to `{role}`. //User Settings \ No newline at end of file diff --git a/storage/providers/Mongodb.js b/storage/providers/Mongodb.js index 9275404..53fb89e 100644 --- a/storage/providers/Mongodb.js +++ b/storage/providers/Mongodb.js @@ -42,7 +42,7 @@ class MongoDBProvider extends Provider { if (!this._initialized) return { error: true, message: 'MongoDB not connected' }; if (!this[request.type]) return { error: true, message: `Invalid request type, got '${request.type}'` }; - if (!request.collection && request.type !== 'stats') return { error: true, message: `You must specify a collection to query!` }; + if (!request.collection && request.type !== 'stats') return { error: true, message: 'You must specify a collection to query!' }; return this[request.type](request); diff --git a/structure/client/Resolver.js b/structure/client/Resolver.js index 50d5128..27f8720 100644 --- a/structure/client/Resolver.js +++ b/structure/client/Resolver.js @@ -141,8 +141,11 @@ class Resolver { } async resolveUser(resolveable, strict) { + + if (!resolveable) return false; const result = await this.resolveUsers([ resolveable ], strict); return result ? result[0] : false; + } /** @@ -211,6 +214,7 @@ class Resolver { async resolveMember(resolveable, guild, strict) { + if (!resolveable) return false; const result = await this.resolveMembers([ resolveable ], guild, strict); return result ? result[0] : false; @@ -274,6 +278,7 @@ class Resolver { resolveChannel(resolveable, guild, strict) { + if (!resolveable) return false; const result = this.resolveChannels([resolveable], guild, strict); return result ? result[0] : false; @@ -327,6 +332,7 @@ class Resolver { async resolveRole(resolveable, guild, strict) { + if (!resolveable) return false; const result = await this.resolveRoles([resolveable], guild, strict); return result ? result[0] : false; diff --git a/structure/client/components/commands/developer/Evaluate.js b/structure/client/components/commands/developer/Evaluate.js index f2b2301..0718a69 100644 --- a/structure/client/components/commands/developer/Evaluate.js +++ b/structure/client/components/commands/developer/Evaluate.js @@ -23,13 +23,13 @@ class Evaluate extends Command { name: 'log', type: 'BOOLEAN', types: ['FLAG'], - description: "Logs the output in the console." + description: 'Logs the output in the console.' }, { name: 'hide', type: 'BOOLEAN', types: ['FLAG'], - description: "Hides the output from the channel." + description: 'Hides the output from the channel.' } ], showUsage: true diff --git a/structure/client/components/commands/information/Help.js b/structure/client/components/commands/information/Help.js index 9c359d8..6329282 100644 --- a/structure/client/components/commands/information/Help.js +++ b/structure/client/components/commands/information/Help.js @@ -31,7 +31,7 @@ class HelpCommand extends Command { description: message.format('C_HELP_TEMPLATE', { desc: message.format(result.description), component: result.name.toUpperCase(), - text: message.format(result.example) + text: result.examples.map(ex => `\`{prefix}${result.name} ${ex}\``).join('\n') })//, // fields: [ // { diff --git a/structure/client/components/commands/utility/Settings.js b/structure/client/components/commands/utility/Settings.js index cfce326..40e3bcb 100644 --- a/structure/client/components/commands/utility/Settings.js +++ b/structure/client/components/commands/utility/Settings.js @@ -1,4 +1,4 @@ -const { Command } = require('../../../../interfaces/'); +const { Command } = require('../../../../interfaces'); const { stripIndents } = require('common-tags'); @@ -28,7 +28,11 @@ class SettingsCommand extends Command { default: true } ], - showUsage: true + showUsage: true, + examples: [ + 'prefix !', + 'modlogs #channel' + ] }); this.client = client; @@ -134,13 +138,13 @@ class SettingsCommand extends Command { async _showSetting(message, setting) { const prefix = message.guild.prefix; - let description = stripIndents`\`${prefix}setting ${setting.name}${setting.usage ? ` ${setting.usage}` : ''}\` ${setting.resolve === 'GUILD' ? ' *(guild-only)*' : '*(user-only)*'} + let description = stripIndents`\`${prefix}settings ${setting.name}${setting.usage ? ` ${setting.usage}` : ''}\` ${setting.resolve === 'GUILD' ? ' *(guild-only)*' : '*(user-only)*'} ${message.format(setting.description)}`; if(setting.examples.length > 0) { description += `\n\n**${message.format('GENERAL_EXAMPLES')}**`; for(let example of setting.examples) { - description += `\n\`${prefix}setting ${example}\``; + description += `\n\`${prefix}settings ${example}\``; } } diff --git a/structure/client/components/commands/utility/User.js b/structure/client/components/commands/utility/User.js index 59d9fec..a6bfdd9 100644 --- a/structure/client/components/commands/utility/User.js +++ b/structure/client/components/commands/utility/User.js @@ -8,7 +8,7 @@ class UserCommand extends Command { super(client, { name: 'user', module: 'utility', - description: "Display information about user.", + description: 'Display information about user.', guildOnly: true, arguments: [ { diff --git a/structure/client/components/inhibitors/Throttle.js b/structure/client/components/inhibitors/Throttle.js index 84b40ad..d67bfe3 100644 --- a/structure/client/components/inhibitors/Throttle.js +++ b/structure/client/components/inhibitors/Throttle.js @@ -1,7 +1,7 @@ const { Inhibitor } = require('../../../interfaces/'); const { stripIndents } = require('common-tags'); -class GuildOnly extends Inhibitor { +class Throttle extends Inhibitor { constructor(client) { @@ -47,4 +47,4 @@ class GuildOnly extends Inhibitor { } -module.exports = GuildOnly; \ No newline at end of file +module.exports = Throttle; \ No newline at end of file diff --git a/structure/client/components/observers/CommandHandler.js b/structure/client/components/observers/CommandHandler.js index 278c67f..877470a 100644 --- a/structure/client/components/observers/CommandHandler.js +++ b/structure/client/components/observers/CommandHandler.js @@ -154,7 +154,7 @@ class CommandHandler extends Observer { } - async _parseArguments(args = [], passedArguments = [], guild = null) { //Only need guild parameter if using a resolver type in your arguments e.g. channel, user, member, role + async _parseArguments(args = [], passedArguments = [], guild = null, debug = false) { //Only need guild parameter if using a resolver type in your arguments e.g. channel, user, member, role args = this._getWords(args.join(' ')).map(w=>w[0]); @@ -167,6 +167,10 @@ class CommandHandler extends Observer { let currentArgument = null; for(let i=0; i`${a.name} - ${a.value}`)); + let setting = message.guild._settings.modlogs || { }; + + if (parsedArguments.exclude) { + if (!parsedArguments.exclude.value.length) return { + msg: message.format('S_MODLOGS_EXCLUDE404'), + error: true + } + + } else { + + let [channel] = params; + if (channel === 'reset') { + + setting = {}; + await message.guild._updateSettings({ [this.index]: setting }); + return { + msg: message.format('S_MODLOGS_RESET'), + error: false + }; + + } else { + + channel = message.guild.resolveChannel(channel); + if (!channel) return { + msg: message.format('S_MODLOGS_CHANNEL404', { val: params[0] }), + error: true + }; + + setting.channel = channel.id; + await message.guild._updateSettings({ [this.index]: setting }); return { + msg: message.format('S_MODLOGS_CHANNEL_SUCCESS', { channel: channel.name }), + error: false + }; + + } + + + } + + } + + data(guild) { + return `**Prefix:** \`${guild.prefix}\``; + } + + fields(guild) { + return [ + { + name: 'Channel', + value: guild.resolveChannel(guild._settings[this.index]?.channel) || 'N/A', + inline: true + }, + { + name: 'Excluded types', + value: guild._settings[this.index]?.exclude.join(', ') || 'N/A', + inline: true + } + ]; + } + +} + +module.exports = Modlogs; \ No newline at end of file diff --git a/structure/client/components/settings/moderation/Mute.js b/structure/client/components/settings/moderation/Mute.js index b6922a1..3da571f 100644 --- a/structure/client/components/settings/moderation/Mute.js +++ b/structure/client/components/settings/moderation/Mute.js @@ -30,7 +30,7 @@ class MuteSetting extends Setting { default: true } ], - usage: "[test] ", + usage: '[test] ', examples: [ 'muterole Muted', 'mutetype 1', @@ -165,13 +165,13 @@ class MuteSetting extends Setting { fields(guild) { return [ { - name: "》Muted Role", - value: guild._settings[this.index].role ? `<@&${guild._settings[this.index].role}>` : '`N/A`', + name: '》Muted Role', + value: guild._settings[this.index]?.role ? `<@&${guild._settings[this.index].role}>` : '`N/A`', inline: true }, { - name: "》Mute Type", - value: `\`${guild._settings[this.index].type}\``, + name: '》Mute Type', + value: `\`${guild._settings[this.index]?.type || 0}\``, inline: true } ]; diff --git a/structure/client/components/settings/utility/GuildPrefix.js b/structure/client/components/settings/utility/GuildPrefix.js index ed71a41..481a533 100644 --- a/structure/client/components/settings/utility/GuildPrefix.js +++ b/structure/client/components/settings/utility/GuildPrefix.js @@ -39,9 +39,11 @@ class GuildPrefixSetting extends Setting { error: true }; + if (prefix === 'reset') prefix = this.default.prefix; + await message.guild._updateSettings({ [this.index]: prefix }); return { - msg: message.format(`S_GUILDPREFIX_SUCCESS`, { prefix }), + msg: message.format('S_GUILDPREFIX_SUCCESS', { prefix }), error: false }; diff --git a/structure/client/components/settings/utility/PermissionType.js b/structure/client/components/settings/utility/PermissionType.js index d277daf..6af23d2 100644 --- a/structure/client/components/settings/utility/PermissionType.js +++ b/structure/client/components/settings/utility/PermissionType.js @@ -37,7 +37,7 @@ class PermissionTypeSetting extends Setting { await message.guild._updateSettings({ [this.index]: prefix }); return { - msg: message.format(`S_GUILDPREFIX_SUCCESS`, { prefix }), + msg: message.format('S_GUILDPREFIX_SUCCESS', { prefix }), error: false }; @@ -46,7 +46,7 @@ class PermissionTypeSetting extends Setting { fields(guild) { return [ { - name: "》Prefix", + name: '》Prefix', value: `\`${guild.prefix}\`` } ]; diff --git a/structure/extensions/Guild.js b/structure/extensions/Guild.js index fc3bf85..0573475 100644 --- a/structure/extensions/Guild.js +++ b/structure/extensions/Guild.js @@ -127,34 +127,31 @@ const Guild = Structures.extend('Guild', (Guild) => { async resolveMember(member, strict) { - const [ result ] = await this.resolveMembers([ member ], strict); - return result; + return await this.client.resolver.resolveMembers(member, this, strict); } - async resolveChannels(channels, strict = false) { + resolveChannels(channels, strict = false) { return this.client.resolver.resolveChannels(channels, this, strict); } - async resolveChannel(channel, strict) { + resolveChannel(channel, strict) { - const [ result ] = await this.resolveMembers([ channel ], strict); - return result; + return this.client.resolver.resolveChannel(channel, this, strict); } async resolveRoles(roles, strict = false) { - return this.client.resolver.resolveRoles(roles, this, strict); + return await this.client.resolver.resolveRoles(roles, this, strict); } async resolveRole(role, strict) { - - const [ result ] = await this.resolveRoles([ role ], strict); - return result; + + return await this.client.resolver.resolveRole(role, this, strict); }