forked from Galactic/galactic-bot
modtimers command
This commit is contained in:
parent
71fed41529
commit
6aaa2f4658
@ -120,4 +120,21 @@ No grantable roles.
|
||||
[COMMAND_GRANTABLE_ROLES]
|
||||
{emoji_success} **Grantable roles**
|
||||
|
||||
**{roles}**
|
||||
**{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:** <t:{issued}:f>, <t:{issued}:R>
|
||||
**Ends:** <t:{ends}:f>, <t:{ends}:R>
|
||||
**Reason:** {reason}
|
||||
|
||||
[COMMAND_MODTIMERS_NONE]
|
||||
No active timed infractions.
|
55
src/structure/components/commands/moderation/Modtimers.js
Normal file
55
src/structure/components/commands/moderation/Modtimers.js
Normal file
@ -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;
|
Loading…
Reference in New Issue
Block a user