diff --git a/src/localization/en_gb/commands/en_gb_utility.lang b/src/localization/en_gb/commands/en_gb_utility.lang index 94191f4..5575bd9 100644 --- a/src/localization/en_gb/commands/en_gb_utility.lang +++ b/src/localization/en_gb/commands/en_gb_utility.lang @@ -120,4 +120,21 @@ No grantable roles. [COMMAND_GRANTABLE_ROLES] {emoji_success} **Grantable roles** -**{roles}** \ No newline at end of file +**{roles}** + +// Modtimers +[COMMAND_MODTIMERS_HELP] +List currently active timed infractions, e.g. mutes & bans. + +[COMMAND_MODTIMERS_TITLE] +Currently active timed infractions + +[COMMAND_MODTIMERS_DESC] +**User:** {target} +**Moderator:** {moderator} +**Issued:** , +**Ends:** , +**Reason:** {reason} + +[COMMAND_MODTIMERS_NONE] +No active timed infractions. \ No newline at end of file diff --git a/src/structure/components/commands/moderation/Modtimers.js b/src/structure/components/commands/moderation/Modtimers.js new file mode 100644 index 0000000..dfaf850 --- /dev/null +++ b/src/structure/components/commands/moderation/Modtimers.js @@ -0,0 +1,55 @@ +const { SlashCommand } = require("../../../interfaces"); + +class ModtimersCommand extends SlashCommand { + + constructor(client) { + super(client, { + name: 'modtimers', + description: 'List active timed infractions', + module: 'moderation', + memberPermissions: ['MANAGE_MESSAGES'], + guildOnly: true + }); + } + + async execute(invoker) { + + const { guild } = invoker; + const { moderation } = this.client; + const callbacks = moderation.callbacks.filter((cb) => cb.infraction.guild === guild.id); + if(!callbacks.size) return { emoji: 'failure', index: 'COMMAND_MODTIMERS_NONE' }; + + const fields = []; + for (const { infraction } of callbacks.values()) { + const user = await guild.resolveUser(infraction.target); + const moderator = await guild.resolveUser(infraction.executor); + fields.push({ + name: `Case ${infraction.case}`, + value: guild.format('COMMAND_MODTIMERS_DESC', { + target: `${user.tag} (${user.id})`, + moderator: `${moderator.tag} (${moderator.id})`, + issued: Math.floor(infraction.timestamp / 1000), + ends: Math.floor((infraction.timestamp + infraction.duration) / 1000), + reason: infraction.reason + }) + }); + if (fields.length === 25) { + break; + } + } + + const embed = { + title: guild.format('COMMAND_MODTIMERS_TITLE'), + fields, + footer: { + text: `• ${callbacks.size} infraction${callbacks.size > 1 ? 's' : ''}` + } + }; + + return { embed }; + + } + +} + +module.exports = ModtimersCommand; \ No newline at end of file