2022-11-16 13:53:42 -05:00
import Discord , { SlashCommandBuilder } from 'discord.js' ;
2023-04-14 06:47:58 -04:00
import TClient from '../client.js' ;
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' ) ;
2023-04-29 19:08:21 -04:00
console . log ( client . logTime ( ) , ` [UnpunishmentLog] Case ${ interaction . options . getInteger ( 'case_id' ) ? ? '--' } was used in / ${ interaction . commandName } for ${ interaction . options . getString ( 'reason' ) ? ? 'Reason unspecified' } ` ) ;
2023-02-24 19:55:11 -05:00
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 ) ;
} ,
data : new SlashCommandBuilder ( )
. setName ( 'unpunish' )
. setDescription ( 'Remove the active punishment from a member' )
2023-04-24 06:10:11 -04:00
. addIntegerOption ( opt = > opt
2023-02-24 19:55:11 -05:00
. setName ( 'case_id' )
2023-03-29 07:21:46 -04:00
. setDescription ( 'Case ID of the punishment to be overwritten' )
2023-02-24 19:55:11 -05:00
. setRequired ( true ) )
2023-04-24 06:10:11 -04:00
. addStringOption ( opt = > opt
2023-02-24 19:55:11 -05:00
. setName ( 'reason' )
. setDescription ( 'Reason for removing the punishment' ) )
2022-11-13 19:18:15 -05:00
}