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

26 lines
1.7 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-09-03 04:56:22 -04:00
2022-11-13 19:18:15 -05:00
export default {
2023-02-24 19:55:11 -05:00
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, 'dcmod');
const punishment = (await client.punishments._content.find({})).find(x=>x._id === interaction.options.getInteger('case_id', true));
if (!punishment) return interaction.reply({content: 'Invalid Case ID', ephemeral: true});
if (punishment.expired) return interaction.reply('This case has been overwritten by another case.');
const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
await client.punishments.removePunishment(punishment.id, interaction.user.id, reason, interaction);
Logger.forwardToConsole('log', 'UnpunishmentLog', `Case #${interaction.options.getInteger('case_id')} was used in /${interaction.commandName} for ${reason}`);
2023-05-07 04:41:20 -04:00
(client.channels.cache.get(client.config.mainServer.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()]});
2023-02-24 19:55:11 -05:00
},
2023-05-23 01:14:17 -04:00
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'))
2022-11-13 19:18:15 -05:00
}