diff --git a/src/structure/components/settings/administration/IgnoreChannels.js b/src/structure/components/settings/administration/IgnoreChannels.js index 582724a..d1fc390 100644 --- a/src/structure/components/settings/administration/IgnoreChannels.js +++ b/src/structure/components/settings/administration/IgnoreChannels.js @@ -24,7 +24,8 @@ class IgnoreSetting extends Setting { choices: [ { name: 'channels', value: 'channels' }, { name: 'bypass', value: 'bypass' } - ] + ], + dependsOn: ['method'] }), new CommandOption({ name: 'method', @@ -35,7 +36,8 @@ class IgnoreSetting extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, - ] + ], + dependsOn: ['list'] }) ] }); diff --git a/src/structure/components/settings/administration/Protection.js b/src/structure/components/settings/administration/Protection.js index 334e8b1..1ddc68e 100644 --- a/src/structure/components/settings/administration/Protection.js +++ b/src/structure/components/settings/administration/Protection.js @@ -26,7 +26,8 @@ class ProtectionSetting extends Setting { choices: [ { name: 'role', value: 'role' }, { name: 'position', value: 'position' } - ] + ], + dependsOn: ['method'] }), new CommandOption({ type: 'STRING', @@ -37,7 +38,8 @@ class ProtectionSetting extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, - ] + ], + dependsOn: [ 'type' ] }) ] }); diff --git a/src/structure/components/settings/logging/DmInfraction.js b/src/structure/components/settings/logging/DmInfraction.js new file mode 100644 index 0000000..714a5a8 --- /dev/null +++ b/src/structure/components/settings/logging/DmInfraction.js @@ -0,0 +1,147 @@ +const { Setting, CommandOption } = require("../../../interfaces"); +const Infractions = [ + 'NOTE', + 'WARN', + 'MUTE', + 'UNMUTE', + 'KICK', + 'SOFTBAN', + 'BAN', + 'UNBAN', + 'VCMUTE', + 'VCUNMUTE', + 'VCKICK', + 'VCBAN', + 'VCUNBAN', + 'REMOVEROLE', + 'ADDROLE', + 'NICKNAME' +]; + +class DmInfraction extends Setting { + + constructor(client) { + super(client, { + name: 'dminfraction', + description: 'Configure what the bot DMs users upon moderation if anything', + module: 'logging', + default: { + enabled: false, + infractions: [ + 'WARN', + 'MUTE', + 'UNMUTE', + 'KICK', + 'SOFTBAN', + 'BAN', + 'UNBAN', + 'VCMUTE', + 'VCUNMUTE', + 'VCKICK', + 'VCBAN', + 'VCUNBAN' + ], + messages: { + default: 'You were **{infraction}** {from|on} the server `{server}`, your infraction details are below.' + } + }, + definitions: { + enabled: 'BOOLEAN', + infractions: { ARRAY: Infractions }, + messages: { + OBJECT: { + keys: Infractions, + values: 'STRING' + } + } + }, + commandOptions: [ + new CommandOption({ + name: 'message', + description: 'Set the message for an infraction type, must be used with the `infraction` option', + type: 'STRING', + dependsOn: ['infraction'] + }), + new CommandOption({ + name: 'infraction', + description: 'Choose the infraction for which to modify the message, must be used with the `message` option', + type: 'STRING', + choices: Infractions.map((inf) => { + return { name: inf, value: inf }; + }), + dependsOn: ['message'] + }), + new CommandOption({ + name: 'infractions', + description: 'Modify the list of infractions that are sent', + type: 'STRING', + choices: [ + { name: 'add', value: 'add' }, + { name: 'remove', value: 'remove' }, + { name: 'set', value: 'set' }, + { name: 'reset', value: 'reset' }, + ] + }), + new CommandOption({ + name: 'enable', + description: 'Enable or disable the sending of infractions in DMs', + type: 'BOOLEAN' + }) + ] + }); + } + + async execute(interaction, opts, setting) { + + const { enable, infractions, infraction, message } = opts; + + if (enable) setting.enable = enable.value; + + if (infractions) { + const response = await this._prompt(interaction, { + message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, { + list: 'infractions' + })}\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { + valid: Infractions.join(`, `) + })}` + }); + if (response.error) return response; + + const infs = response.split(' ') + .map((inf) => this.client.resolver.resolveInfraction(inf)) + .filter((inf) => inf !== null); + this[infractions.value](setting.infractions, infs); + } + + if (message && infraction) { + setting.messages[infraction.value] = message.value; + } + + return { error: false, index: 'SETTING_SUCCESS_ALT' }; + + } + + async fields(guild) { + + const setting = guild._settings[this.name]; + return [ + { + name: 'GENERAL_STATUS', + value: guild.format('GENERAL_STATE', { bool: setting.enabled }, { code: true }), + inline: true + }, + { + name: 'GENERAL_INFRACTIONS', + value: setting.infractions.join(', ') + }, + { + name: 'GENERAL_MESSAGES', + value: Object.entries(setting.messages).map(([key, val]) => `**${key}**: ${val}`).join('\n') + } + ]; + + } + +} + +module.exports = DmInfraction; \ No newline at end of file diff --git a/src/structure/components/settings/Logging/MemberLog.js b/src/structure/components/settings/logging/Members.js similarity index 100% rename from src/structure/components/settings/Logging/MemberLog.js rename to src/structure/components/settings/logging/Members.js diff --git a/src/structure/components/settings/Logging/MessageLog.js b/src/structure/components/settings/logging/Messages.js similarity index 97% rename from src/structure/components/settings/Logging/MessageLog.js rename to src/structure/components/settings/logging/Messages.js index 1eeb507..cab5da5 100644 --- a/src/structure/components/settings/Logging/MessageLog.js +++ b/src/structure/components/settings/logging/Messages.js @@ -47,7 +47,8 @@ class MessageLog extends Setting { choices: [ { name: 'bypass', value: 'bypass' }, { name: 'ignore', value: 'ignore' }, - ] + ], + dependsOn: ['method'] }), new CommandOption({ name: 'method', @@ -58,7 +59,8 @@ class MessageLog extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, - ] + ], + dependsOn: ['list'] }), ] }); diff --git a/src/structure/components/settings/logging/Moderation.js b/src/structure/components/settings/logging/Moderation.js new file mode 100644 index 0000000..086db21 --- /dev/null +++ b/src/structure/components/settings/logging/Moderation.js @@ -0,0 +1,113 @@ +const { Infractions } = require("../../../../constants/Constants"); +const { Setting, CommandOption } = require("../../../interfaces"); + +// [ +// 'NOTE', +// 'WARN', +// 'MUTE', +// 'UNMUTE', +// 'LOCKDOWN', +// 'UNLOCKDOWN', +// 'SLOWMODE', +// 'KICK', +// 'SOFTBAN', +// 'BAN', +// 'UNBAN', +// 'VCMUTE', +// 'VCUNMUTE', +// 'VCKICK', +// 'VCBAN', +// 'VCUNBAN', +// 'NICKNAME', +// 'ADDROLE', +// 'REMOVEROLE', +// 'PRUNE' +// ] + +class ModerationLog extends Setting { + + constructor(client) { + super(client, { + name: 'moderation', + description: 'Configure moderation logs', + module: 'logging', + default: { + channel: null, + infractions: Infractions + }, + definitions: { + channel: 'GUILD_TEXT', + infractions: { + ARRAY: Infractions + } + }, + commandOptions: [ + new CommandOption({ + name: 'channel', + description: '', + type: 'TEXT_CHANNEL' + }), + new CommandOption({ + name: 'infractions', + description: 'Modify the list of infractions that are sent', + type: 'STRING', + choices: [ + { name: 'add', value: 'add' }, + { name: 'remove', value: 'remove' }, + { name: 'set', value: 'set' }, + { name: 'reset', value: 'reset' }, + ] + }) + ] + }); + } + + async execute(interaction, opts, setting) { + + const { channel, infractions } = opts; + + if (channel) setting.channel = channel.value.id; + + if (infractions) { + const response = await this._prompt(interaction, { + message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, { + list: 'infractions' + })}\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { + valid: Infractions.join(`, `) + })}` + }); + if (response.error) return response; + + const infs = response.split(' ') + .map((inf) => this.client.resolver.resolveInfraction(inf)) + .filter((inf) => inf !== null); + this[infractions.value](setting.infractions, infs); + } + + return { index: 'SETTING_SUCCESS_ALT' }; + + } + + fields(guild) { + const setting = guild._settings[this.name]; + return [ + { + name: 'GENERAL_STATUS', + value: guild.format('GENERAL_STATE', { bool: Boolean(setting.channel) }, { code: true }), + inline: true + }, + { + name: 'GENERAL_CHANNEL', + value: `<#${setting.channel}>`, + inline: true + }, + { + name: 'GENERAL_INFRACTIONS', + value: setting.infractions.join(', ') + } + ]; + } + +} + +module.exports = ModerationLog; \ No newline at end of file diff --git a/src/structure/components/settings/logging/Nicknames.js b/src/structure/components/settings/logging/Nicknames.js new file mode 100644 index 0000000..ac3c2a0 --- /dev/null +++ b/src/structure/components/settings/logging/Nicknames.js @@ -0,0 +1,51 @@ +const { Setting, CommandOption } = require("../../../interfaces"); + +class Nicknames extends Setting { + + constructor(client) { + super(client, { + name: 'nicknames', + description: 'Configure logging of nicknames', + module: 'logging', + default: { + channel: null + }, + definitions: { + channel: 'GUILD_TEXT' + }, + commandOptions: [ + new CommandOption({ + name: 'channel', + type: 'TEXT_CHANNEL', + description: 'Set the channel for nickname logging' + }) + ] + }); + } + + async execute(interaction, opts, setting) { + + setting.channel = opts.channel.value.id; + return { index: 'SETTING_SUCCESS_ALT' }; + + } + + fields(guild) { + const setting = guild._settings[this.name]; + return [ + { + name: 'GENERAL_STATUS', + value: guild.format('GENERAL_STATE', { bool: Boolean(setting.channel) }, { code: true }), + inline: true + }, + { + name: 'GENERAL_CHANNEL', + value: `<#${setting.channel}>`, + inline: true + } + ]; + } + +} + +module.exports = Nicknames; \ No newline at end of file diff --git a/src/structure/components/settings/logging/Voice.js b/src/structure/components/settings/logging/Voice.js new file mode 100644 index 0000000..a3692f6 --- /dev/null +++ b/src/structure/components/settings/logging/Voice.js @@ -0,0 +1,51 @@ +const { Setting, CommandOption } = require("../../../interfaces"); + +class Voice extends Setting { + + constructor(client) { + super(client, { + name: 'voice', + description: 'Configure logging of joining and leaving voice channels', + module: 'logging', + default: { + channel: null + }, + definitions: { + channel: 'GUILD_TEXT' + }, + commandOptions: [ + new CommandOption({ + name: 'channel', + type: 'TEXT_CHANNEL', + description: 'Set the channel for voice join/leave logging' + }) + ] + }); + } + + async execute(interaction, opts, setting) { + + setting.channel = opts.channel.value.id; + return { index: 'SETTING_SUCCESS_ALT' }; + + } + + fields(guild) { + const setting = guild._settings[this.name]; + return [ + { + name: 'GENERAL_STATUS', + value: guild.format('GENERAL_STATE', { bool: Boolean(setting.channel) }, { code: true }), + inline: true + }, + { + name: 'GENERAL_CHANNEL', + value: `<#${setting.channel}>`, + inline: true + } + ]; + } + +} + +module.exports = Voice; \ No newline at end of file diff --git a/src/structure/components/settings/moderation/MuteSetting.js b/src/structure/components/settings/moderation/Mute.js similarity index 100% rename from src/structure/components/settings/moderation/MuteSetting.js rename to src/structure/components/settings/moderation/Mute.js diff --git a/src/structure/components/settings/moderation/WordFilterSetting.js b/src/structure/components/settings/moderation/WordFilter.js similarity index 98% rename from src/structure/components/settings/moderation/WordFilterSetting.js rename to src/structure/components/settings/moderation/WordFilter.js index 30941a7..9315f12 100644 --- a/src/structure/components/settings/moderation/WordFilterSetting.js +++ b/src/structure/components/settings/moderation/WordFilter.js @@ -55,7 +55,8 @@ class WordFilterSetting extends FilterSetting { { name: 'reset', value: 'reset' }, { name: 'edit', value: 'edit' }, { name: 'list', value: 'list' } - ] + ], + dependsOn: ['list'] }), new CommandOption({ type: 'STRING', @@ -70,7 +71,8 @@ class WordFilterSetting extends FilterSetting { { name: 'bypass', value: 'bypass' }, { name: 'ignore', value: 'ignore' }, { name: 'actions', value: 'actions' }, - ] + ], + dependsOn: ['method'] }), new CommandOption({ type: 'BOOLEAN',