diff --git a/src/structure/components/settings/administration/IgnoreChannels.js b/src/structure/components/settings/administration/IgnoreChannels.js index 565ee0a..eae203a 100644 --- a/src/structure/components/settings/administration/IgnoreChannels.js +++ b/src/structure/components/settings/administration/IgnoreChannels.js @@ -38,6 +38,7 @@ class IgnoreSetting extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, + { name: 'list', value: 'list' } ], dependsOn: ['list']//, valueAsAlias: true, flag: true } @@ -50,6 +51,8 @@ class IgnoreSetting extends Setting { const { list, method } = opts; + if (method.value === 'list') return this.list(setting[list.value], interaction, list.value); + const response = await this._prompt(interaction, { index: `SETTING_PROMPT_${method.value.toUpperCase()}`, params: { list: list.value } diff --git a/src/structure/components/settings/administration/Protection.js b/src/structure/components/settings/administration/Protection.js index 01f4859..4947d41 100644 --- a/src/structure/components/settings/administration/Protection.js +++ b/src/structure/components/settings/administration/Protection.js @@ -40,6 +40,7 @@ class ProtectionSetting extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, + { name: 'list', value: 'list' } ], dependsOn: [] }, @@ -62,6 +63,8 @@ class ProtectionSetting extends Setting { if (type) setting.type = type.value; if (enabled) setting.enabled = enabled.value; + if (roles.value === 'list') return this.list(setting.roles, interaction, 'roles'); + if (roles) { const response = await this._prompt(interaction, { diff --git a/src/structure/components/settings/logging/Messages.js b/src/structure/components/settings/logging/Messages.js index 31e7949..06ac517 100644 --- a/src/structure/components/settings/logging/Messages.js +++ b/src/structure/components/settings/logging/Messages.js @@ -60,6 +60,7 @@ class MessageLog extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, + { name: 'list', value: 'list' } ], dependsOn: ['list'] }, @@ -107,6 +108,8 @@ class MessageLog extends Setting { if (method && list) { + if (method === 'list') return this.list(setting[list], interaction, list); + const time = 120; const content = await this._prompt(interaction, { message: guild.format(`SETTING_PROMPT_${method.toUpperCase()}`, @@ -114,7 +117,7 @@ class MessageLog extends Setting { time }); if (content.error) return content; - if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + if (method === 'reset' && !this.client.resolver.resolveBoolean(content)) { return { index: 'SETTING_NO_CHANGE' }; } diff --git a/src/structure/components/settings/moderation/Grantable.js b/src/structure/components/settings/moderation/Grantable.js index 42cabea..e60ab62 100644 --- a/src/structure/components/settings/moderation/Grantable.js +++ b/src/structure/components/settings/moderation/Grantable.js @@ -32,6 +32,7 @@ class Grantable extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, + { name: 'list', value: 'list' } ] } ] @@ -45,6 +46,9 @@ class Grantable extends Setting { let index = 'SETTING_SUCCESS_ALT'; if (enabled) setting.enabled = enabled.value; + + if (roles.value === 'list') return this.list(setting.roles, interaction, 'roles'); + if (roles) { const response = await this._prompt(interaction, { diff --git a/src/structure/components/settings/moderation/InviteFilter.js b/src/structure/components/settings/moderation/InviteFilter.js index 08c79e5..a615ddc 100644 --- a/src/structure/components/settings/moderation/InviteFilter.js +++ b/src/structure/components/settings/moderation/InviteFilter.js @@ -97,7 +97,7 @@ class InviteFilterSetting extends FilterSetting { if (method && list) { if (list === 'actions') return this._action(interaction, method, setting[list]); - else if (method === 'list') return { error: false, message: setting[list].join(', ') }; + else if (method === 'list') return this.list(setting[list], interaction, list); //{ error: false, message: setting[list].join(', ') }; const { guild } = interaction; const time = 120; @@ -168,17 +168,17 @@ class InviteFilterSetting extends FilterSetting { }, { name: 'GENERAL_IGNORED', - value: setting.ignore?.map((channel) => `<#${channel}>`).join(', ') || '**N/A**', + value: setting.ignore.map((channel) => `<#${channel}>`).join(', ') || '**N/A**', inline: true }, { name: 'GENERAL_BYPASS', - value: setting.bypass?.map((role) => `<@&${role}>`).join(', ') || '**N/A**', + value: setting.bypass.map((role) => `<@&${role}>`).join(', ') || '**N/A**', inline: true }, { name: 'SETTING_FILTER_ACTIONS', - value: setting.actions?.reduce((acc, val) => { + value: setting.actions.reduce((acc, val) => { let str = `**${val.type}**`; if (val.points) str += ` (${val.points} points)`; if (val.duration) str += ` for ${Util.humanise(val.duration)}`; diff --git a/src/structure/components/settings/moderation/LinkFilter.js b/src/structure/components/settings/moderation/LinkFilter.js index 7a65a32..c543349 100644 --- a/src/structure/components/settings/moderation/LinkFilter.js +++ b/src/structure/components/settings/moderation/LinkFilter.js @@ -115,7 +115,7 @@ class LinkFilterSetting extends FilterSetting { if (method && list) { if (list === 'actions') return this._action(interaction, method, setting[list]); - else if (method === 'list') return { error: false, message: setting[list].join(', ') }; + else if (method === 'list') return this.list(setting[list], interaction, list); //{ error: false, message: setting[list].join(', ') }; const { guild } = interaction; const time = 120; diff --git a/src/structure/components/settings/moderation/MentionFilter.js b/src/structure/components/settings/moderation/MentionFilter.js index f1b353e..7cf5e9c 100644 --- a/src/structure/components/settings/moderation/MentionFilter.js +++ b/src/structure/components/settings/moderation/MentionFilter.js @@ -91,7 +91,7 @@ class MentionFilter extends FilterSetting { if (method && list) { if (list.value === 'actions') return this._action(interaction, method.value, setting[list.value]); - else if (method.value === 'list') return { message: setting[list.value].join(', ') }; + else if (method.value === 'list') return this.list(setting[list.value], interaction, list.value); //{ message: setting[list.value].join(', ') }; const { guild } = interaction; const time = 120; diff --git a/src/structure/components/settings/moderation/Raidprotection.js b/src/structure/components/settings/moderation/Raidprotection.js new file mode 100644 index 0000000..727fd30 --- /dev/null +++ b/src/structure/components/settings/moderation/Raidprotection.js @@ -0,0 +1,42 @@ +const { Setting } = require("../../../interfaces"); + +class RaidprotectionSetting extends Setting { + + constructor(client) { + + super(client, { + name: 'raidprotection', + display: 'Raid Protection', + description: 'Prevent users meeting certain criteria from joining', + module: 'moderation', + default: { + enabled: false, + age: 0, + pfpCheck: false + }, + commandOptions: [ + { + type: 'BOOLEAN', flag: true, valueOptional: true, defaultValue: true, + name: 'enabled', + description: 'Toggle enable state' + }, { + type: 'BOOLEAN', flag: true, valueOptional: true, defaultValue: true, + name: 'pfpcheck', + description: 'Whether to check for a default profile picture' + }, { + type: 'TIME', + name: 'age', + description: 'Threshold for the account age' + } + ] + }); + + } + + async execute(invoker, { enabled, pfpcheck, age }, settings) { + + } + +} + +module.exports = RaidprotectionSetting; \ No newline at end of file diff --git a/src/structure/components/settings/moderation/WordFilter.js b/src/structure/components/settings/moderation/WordFilter.js index 3b044d8..e35b694 100644 --- a/src/structure/components/settings/moderation/WordFilter.js +++ b/src/structure/components/settings/moderation/WordFilter.js @@ -106,7 +106,7 @@ class WordFilterSetting extends FilterSetting { if (method && list) { if (list === 'actions') return this._action(interaction, method, setting[list]); - else if (method === 'list') return { error: false, message: setting[list].join(', ') }; + else if (method === 'list') return this.list(setting[list], interaction, list); //{ error: false, message: setting[list].join(', ') }; const { guild } = interaction; const time = 120; diff --git a/src/structure/components/settings/moderation/WordWatcher.js b/src/structure/components/settings/moderation/WordWatcher.js index 192a39c..f449a5a 100644 --- a/src/structure/components/settings/moderation/WordWatcher.js +++ b/src/structure/components/settings/moderation/WordWatcher.js @@ -70,7 +70,7 @@ class WordWatcher extends FilterSetting { if (method && list) { if (list.value === 'actions') return this._action(interaction, method.value, setting[list.value], { _wordWatcher: true }); - else if (method.value === 'list') return { error: false, content: setting[list.value].join(', ') }; + else if (method.value === 'list') return this.list(setting[list.value], interaction, list.value); //{ error: false, content: setting[list.value].join(', ') }; const { guild } = interaction; const time = 120; diff --git a/src/structure/components/settings/utility/Autorole.js b/src/structure/components/settings/utility/Autorole.js index 8b3d20e..9f6e5b6 100644 --- a/src/structure/components/settings/utility/Autorole.js +++ b/src/structure/components/settings/utility/Autorole.js @@ -47,6 +47,8 @@ class Autorole extends Setting { if (typeof enabled === 'boolean') setting.enabled = enabled; + if (method === 'list') return this.list(setting.roles, interaction, 'roles'); + if (method) { const { guild } = interaction; const time = 120; diff --git a/src/structure/components/settings/utility/Selfrole.js b/src/structure/components/settings/utility/Selfrole.js index a11e74e..396aef7 100644 --- a/src/structure/components/settings/utility/Selfrole.js +++ b/src/structure/components/settings/utility/Selfrole.js @@ -25,6 +25,7 @@ class SelfroleSetting extends Setting { { name: 'remove', value: 'remove' }, { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, + { name: 'list', value: 'list' } ], }, { name: 'channel', @@ -41,7 +42,9 @@ class SelfroleSetting extends Setting { if (!roles && !channel && !text) return { error: true, index: 'SETTING_MISSING_ARG' }; const { guild } = invoker; - + + if (roles.value === 'list') return this.list(setting.roles, invoker, 'roles'); + if (roles) { const response = await this._prompt(invoker, { index: `SETTING_PROMPT_${roles.value.toUpperCase()}`, diff --git a/src/structure/components/settings/utility/StickyRole.js b/src/structure/components/settings/utility/StickyRole.js index 3b149e2..a2608d1 100644 --- a/src/structure/components/settings/utility/StickyRole.js +++ b/src/structure/components/settings/utility/StickyRole.js @@ -47,6 +47,8 @@ class Autorole extends Setting { const method = opts.roles?.value; if (typeof enabled === 'boolean') setting.enabled = enabled; + if (method === 'list') return this.list(setting.roles, interaction, 'roles'); + if (method) { const { guild } = interaction; const time = 120; diff --git a/src/structure/interfaces/Setting.js b/src/structure/interfaces/Setting.js index ec2984d..c2dceed 100644 --- a/src/structure/interfaces/Setting.js +++ b/src/structure/interfaces/Setting.js @@ -244,6 +244,49 @@ class Setting extends Component { return { list, modified }; } + async list(items, invoker, type = 'text') { + + items = items.map((i) => i.toString()); + const strings = []; + let string = ''; + + const { resolver } = this.client; + const resolvers = { + bypass: resolver.resolveRole.bind(resolver), + roles: resolver.resolveRole.bind(resolver), + ignore: resolver.resolveChannel.bind(resolver), + channels: resolver.resolveChannel.bind(resolver) + }; + + for (let item of items) { + + if (resolvers[type]) { + const resolved = await resolvers[type](item, true, invoker.guild); + if(resolved) item = resolved.toString(); + } + + if (string.length + item.length > 2000 && string.length) { + strings.push(string); + string = ''; + } + + string += `${item}, `; + + } + + if(string.length) strings.push(string.substring(0, string.length -2)); + + // await invoker.reply({ content: `Ok.`, emoji: 'success' }); + + for (const str of strings) { + if(!invoker.replied) await invoker.reply(str); + else await invoker.channel.send(str); + } + + return null; + + } + // Functions for message component based settings /** * Abstract components method, should be overridden by the implementing class and called, returns the select menu component.