2023-10-13 15:04:11 +02:00
import {
SlashCommandBuilder ,
SlashCommandSubcommandBuilder ,
SlashCommandChannelOption ,
ChannelType ,
SlashCommandStringOption ,
ButtonBuilder ,
ActionRowBuilder ,
EmbedBuilder ,
} from "discord.js" ;
2022-11-09 14:44:05 +01:00
2023-09-13 21:12:45 +02:00
export default {
2022-12-14 11:45:20 +01:00
data : new SlashCommandBuilder ( )
2023-10-13 15:04:11 +02:00
. setName ( "toggle" )
2022-11-09 14:44:05 +01:00
. setDefaultMemberPermissions ( 0x8 )
2023-10-13 15:04:11 +02:00
. setDescription ( "Activer différents paramètres." )
2022-11-09 14:44:05 +01:00
. addSubcommand (
new SlashCommandSubcommandBuilder ( )
2023-10-13 15:04:11 +02:00
. setName ( "commandes" )
. setDescription ( "Désactiver/Réactiver les commandes bénévoles" )
2022-11-09 14:44:05 +01:00
. addChannelOption (
new SlashCommandChannelOption ( )
2023-10-13 15:04:11 +02:00
. setName ( "channel" )
. setDescription ( "Salon du panel" )
2022-11-09 14:44:05 +01:00
. addChannelTypes ( ChannelType . GuildText )
2023-10-13 15:04:11 +02:00
. setRequired ( true ) ,
)
2022-11-09 14:44:05 +01:00
. addStringOption (
new SlashCommandStringOption ( )
2023-10-13 15:04:11 +02:00
. setName ( "messageid" )
. setDescription ( "ID du message du panel" )
. setRequired ( true ) ,
) ,
2022-12-14 11:45:20 +01:00
) ,
2023-09-30 08:29:50 +02:00
async execute ( interaction ) {
2023-10-13 15:04:11 +02:00
await interaction . deferReply ( { ephemeral : true } ) ;
const channel = interaction . options . getChannel ( "channel" ) ;
const message = await channel . messages . fetch (
interaction . options . getString ( "messageid" ) ,
) ;
if ( ! message )
return interaction . reply ( {
content :
"Je n'ai pas trouvé le message correspondant, vérifiez votre id" ,
ephemeral : true ,
} ) ;
2022-11-09 14:44:05 +01:00
2023-09-30 08:29:50 +02:00
const a = new ButtonBuilder ( message . components [ 0 ] . components [ 0 ] . data ) ;
2023-10-13 15:04:11 +02:00
const b = new ButtonBuilder (
message . components [ 0 ] . components [ 1 ] . data ,
) . setDisabled ( ! message . components [ 0 ] . components [ 1 ] . data . disabled ) ;
2022-11-09 14:44:05 +01:00
2023-09-30 08:29:50 +02:00
const embed = new EmbedBuilder ( message . embeds [ 0 ] . data ) ;
2022-12-14 11:45:20 +01:00
if ( message . components [ 0 ] . components [ 1 ] . data . disabled ) {
2023-09-30 08:29:50 +02:00
embed . setDescription ( description [ 0 ] ) ;
} else {
embed . setDescription ( description [ 1 ] ) ;
2023-10-13 15:04:11 +02:00
}
2022-11-09 14:44:05 +01:00
2023-10-13 15:04:11 +02:00
const msg = message . components [ 0 ] . components [ 1 ] . data . disabled
? "Commandes bénévoles activées !"
: "Commandes bénévoles désactivées !" ;
2022-11-09 14:44:05 +01:00
2023-10-13 15:04:11 +02:00
await message . edit ( {
components : [ new ActionRowBuilder ( ) . addComponents ( [ a , b ] ) ] ,
embeds : [ embed ] ,
} ) ;
2023-09-30 08:29:50 +02:00
await interaction . editReply ( { ephemeral : true , content : msg } ) ;
} ,
2022-11-09 14:44:05 +01:00
} ;
2022-12-14 11:45:20 +01:00
const description = [
2022-11-09 14:44:05 +01:00
"Tu veux passer commande ? Choisis ci-dessous en fonction de ton budget ! ^^" ,
"Tu veux passer commande ? Choisis ci-dessous en fonction de ton budget ! ^^\n\n**Les tickets bénévoles sont actuellement désactivés pour cause de surcharge !** Dès que la plupart seront écoulés, les commandes bénévoles rouvriront !\n\n*Vous pouvez regarder le nombre de commandes en cours via le </info server:947504536417878046> !*" ,
2023-09-30 08:29:50 +02:00
] ;