diff --git a/src/structure/components/commands/moderation/Staff.js b/src/structure/components/commands/moderation/Staff.js new file mode 100644 index 0000000..1bdd142 --- /dev/null +++ b/src/structure/components/commands/moderation/Staff.js @@ -0,0 +1,39 @@ +const { SlashCommand } = require("../../../interfaces"); + +class StaffCommand extends SlashCommand { + + constructor(client) { + super(client, { + name: 'staff', + description: 'Summon staff', + module: 'moderation', + guildOnly: true, + clientPermissions: ['MENTION_EVERYONE'] + }); + } + + async execute(invoker) { + + const { guild, author, channel } = invoker; + const { staff } = await guild.settings(); + if (!staff.role || !staff.enabled) return { index: 'COMMAND_STAFF_NOT_SET', emoji: 'failure', ephemeral: true }; + + const message = await invoker.reply({ embed: { description: guild.format('COMMAND_STAFF_CONFIRM', { rule: staff.rule || '' }) } }); + let reactions = message.awaitReactions({ filter: (reaction, user) => reaction.emoji.name === '👍' && user.id === author.id, time: 30_000, max: 1 }); + await message.react('👍'); + reactions = await reactions; + if (!reactions.size) return invoker.editReply({ index: 'COMMAND_STAFF_TIMEOUT', emoji: 'failure' }); + + // const role = await guild.resolveRole(staff.role); + // if(!role) return invoker.editReply({ index: 'COMMAND_STAFF_ERROR', emoji: 'failure' }); + + await channel.send({ + content: guild.format('COMMAND_STAFF_SUMMON', { author: author.tag, role: staff.role }), + allowedMentions: { parse: ['roles'] } // roles: [staff.role], + }); + + } + +} + +module.exports = StaffCommand; \ No newline at end of file diff --git a/src/structure/components/settings/moderation/Staff.js b/src/structure/components/settings/moderation/Staff.js new file mode 100644 index 0000000..c3bbd60 --- /dev/null +++ b/src/structure/components/settings/moderation/Staff.js @@ -0,0 +1,63 @@ +const { Setting } = require("../../../interfaces"); + +class StaffSetting extends Setting { + + constructor(client) { + super(client, { + name: 'staff', + description: 'Configure the role that is used for the staff commmand', + module: 'moderation', + display: 'Staff', + default: { + rule: null, + role: null, + enabled: false + }, + commandOptions: [{ + name: 'role', + description: 'The role used to mention staff', + type: 'ROLE' + }, { + name: 'rule', + description: 'The text displayed in the staff command to inform of proper use, use "long" to give a longer text' + }, { + name: 'enabled', + description: 'Whether the staff command is in use', + type: 'BOOLEAN' + }] + }); + } + + async execute(invoker, { rule, role, enabled }, setting) { + + if (role) setting.role = role.value.id; + if (enabled) setting.enabled = enabled.value; + + if (rule) { + let txt = rule.value; + if (txt.toLowerCase() === 'long') { + const message = await invoker.promptMessage({ index: 'SETTING_STAFF_PROMPT', time: 30_000 }); + if (!message) return { index: 'SETTING_STAFF_TIMEOUT', emoji: 'failure' }; + txt = message.content; + } + setting.rule = txt; + } + + return { index: 'SETTING_SUCCESS_ALT' }; + + } + + fields(guild) { + const setting = guild._settings[this.name]; + return [{ + name: guild.format('GENERAL_ROLE'), + value: setting.role ? `<@&${setting.role}>` : '**N/A**' + }, { + name: guild.format('SETTING_STAFF_RULE_FIELD'), + value: setting.rule || '**N/A**' + }]; + } + +} + +module.exports = StaffSetting; \ No newline at end of file