1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 16:30:59 -04:00
Daggerbot-TS/src/commands/unpunish.ts

30 lines
2.0 KiB
TypeScript
Raw Normal View History

2023-05-23 01:14:17 -04:00
import Discord from 'discord.js';
2023-04-14 06:47:58 -04:00
import TClient from '../client.js';
import Logger from '../helpers/Logger.js';
2023-10-06 01:54:27 -04:00
import MessageTool from '../helpers/MessageTool.js';
2023-12-24 10:21:40 -05:00
export default class Unpunish {
static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
2024-01-16 06:41:30 -05:00
if (!MessageTool.isModerator(interaction.member as Discord.GuildMember)) return MessageTool.youNeedRole(interaction, 'dcmod');
2023-12-24 10:21:40 -05:00
const punishment = await client.punishments.findCase(interaction.options.getInteger('case_id', true));
if (!punishment) return interaction.reply({content: 'Case ID is not found in database.', ephemeral: true});
if (['unban', 'unmute', 'punishmentOverride'].includes(punishment.dataValues.type)) return interaction.reply({content: 'This case ID is immutable. (Informative case)', ephemeral: true});
2024-02-03 21:09:33 -05:00
if (punishment.dataValues.expired) return interaction.reply({content: 'This case ID is already expired.', ephemeral: true});
2023-02-24 19:55:11 -05:00
const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
2023-12-24 10:21:40 -05:00
await client.punishments.punishmentRemove(punishment.dataValues.case_id, interaction.user.id, reason, interaction);
2024-01-21 23:45:25 -05:00
const unpunishLog = `Case #${interaction.options.getInteger('case_id')} was used in \`/${interaction.commandName}\` for \`${reason}\``;
Logger.console('log', 'UnpunishmentLog', unpunishLog);
(client.channels.cache.get(client.config.dcServer.channels.punishment_log) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColor).setTitle('Unpunishment Log').setDescription(unpunishLog).setTimestamp()]});
2023-12-24 10:21:40 -05:00
}
static data = new Discord.SlashCommandBuilder()
2023-02-24 19:55:11 -05:00
.setName('unpunish')
.setDescription('Remove the active punishment from a member')
2023-05-23 01:14:17 -04:00
.addIntegerOption(x=>x
2023-02-24 19:55:11 -05:00
.setName('case_id')
2024-01-27 20:29:36 -05:00
.setDescription('Case ID of the active punishment to be overwritten')
2023-02-24 19:55:11 -05:00
.setRequired(true))
2023-05-23 01:14:17 -04:00
.addStringOption(x=>x
2023-02-24 19:55:11 -05:00
.setName('reason')
.setDescription('Reason for removing the punishment'))
2023-10-06 01:54:27 -04:00
}