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

28 lines
1.9 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});
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);
Logger.console('log', 'UnpunishmentLog', `Case #${interaction.options.getInteger('case_id')} was used in /${interaction.commandName} for ${reason}`);
(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(`Case #${interaction.options.getInteger('case_id')} was used in \`/${interaction.commandName}\` for \`${reason}\``).setTimestamp()]});
}
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')
.setDescription('Case ID of the 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
}