Advertisement
CrispyCream

stack overflow help

Jun 1st, 2022
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { MessageButton, MessageActionRow } = require('discord.js');
  2.  
  3. module.exports = {
  4.     name: 'interactionCreate',
  5.     async execute(interaction, client) {
  6.         if (interaction.isCommand()) {
  7.         const command = client.slash.get(interaction.commandName); // We need to change this to the new collection called slash. You can change the name to whatever you want but you need to do it in index.js as well
  8.         if(!command) return;
  9.  
  10.         try{
  11.             await command.execute(interaction);
  12.         }catch(error){
  13.             console.error(error);
  14.             await interaction.reply({content : "There was an error while executing action"})
  15.         }
  16.  
  17.         console.log(`${interaction.user.tag} in #${interaction.channel.name} triggered an interaction.`);
  18.         return;
  19.  
  20.     } else if (interaction.isButton()) {
  21.         interaction.reply("you clicked" + interaction.customId);
  22.         console.log(interaction);
  23.  
  24.         if (interaction.customId === 'offense') {
  25.             console.log(`${interaction.user.tag} in #${interaction.channel.name} clicked the offense button.`);
  26.        
  27.             const ActionRow = new MessageActionRow().setComponents(new MessageButton()
  28.               .setCustomId('CustomId')
  29.               .setLabel('Label')
  30.               .setStyle('PRIMARY'));
  31.        
  32.             return interaction.update({
  33.               content: 'Hey',
  34.               components: [ActionRow],
  35.               ephemeral: true
  36.             });
  37.        
  38.         }
  39.     }
  40.     },
  41. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement