Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { MessageButton, MessageActionRow } = require('discord.js');
- module.exports = {
- name: 'interactionCreate',
- async execute(interaction, client) {
- if (interaction.isCommand()) {
- 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
- if(!command) return;
- try{
- await command.execute(interaction);
- }catch(error){
- console.error(error);
- await interaction.reply({content : "There was an error while executing action"})
- }
- console.log(`${interaction.user.tag} in #${interaction.channel.name} triggered an interaction.`);
- return;
- } else if (interaction.isButton()) {
- interaction.reply("you clicked" + interaction.customId);
- console.log(interaction);
- if (interaction.customId === 'offensebank') {
- console.log(`${interaction.user.tag} in #${interaction.channel.name} clicked the offense button.`);
- const ActionRow = new MessageActionRow()
- .setComponents(
- new MessageButton()
- .setCustomId('ambulance')
- .setLabel('Ambulance')
- .setStyle('PRIMARY'),
- new MessageButton()
- .setCustomId('construction')
- .setLabel('Construction')
- .setStyle('PRIMARY'),
- new MessageButton()
- .setCustomId('housefront')
- .setLabel('House Front')
- .setStyle('PRIMARY'));
- return interaction.update({
- content: 'Choose your spawn site',
- components: [ActionRow],
- ephemeral: true
- });
- }
- else if (interaction.customId === 'defensebank') {
- console.log(`${interaction.user.tag} in #${interaction.channel.name} clicked the offense button.`);
- const ActionRow = new MessageActionRow()
- .setComponents(
- new MessageButton()
- .setCustomId('kids')
- .setLabel('Kids')
- .setStyle('PRIMARY'),
- new MessageButton()
- .setCustomId('laundry')
- .setLabel('Laundry')
- .setStyle('PRIMARY'),
- new MessageButton()
- .setCustomId('kitchen')
- .setLabel('Kitchen')
- .setStyle('PRIMARY'));
- return interaction.update({
- content: 'Choose the site your defending',
- components: [ActionRow],
- ephemeral: true
- });
- }
- }
- },
- };
Add Comment
Please, Sign In to add comment