#Button

1 messages ยท Page 1 of 1 (latest)

willow acorn
#
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
let { commands } = require('../');

 module.exports = {
     name: 'help',
     category: 'info',
     description: 'Lost? Get help here!',
     
        run: async (interaction, channel) => {

            const embed = new MessageEmbed()
                .setAuthor({ name: 'Help Embed'})
                .setColor('GREEN')
                .setDescription(`Hello There! Seems like you have lost yourself... Don't worry! I'm here to help! Select what you need help with down below!`)

            const button = new MessageButton()
                .setLabel('Administration')
                .setEmoji('๐Ÿ‘‘')
                .setStyle('SUCCESS')
                .setCustomId('ad')

            const row = new MessageActionRow()
                .addComponents([ button ]);

            interaction.reply({ embeds: [embed], allowedMentions: { repliedUser: false }, components: [row]})

            const filter = i => i.customId === 'ad' && m.author.id != client.user.id;

            const collector = interaction.channel.createMessageCollector({ filter, time: 10000 }); 
            
            collector.on('collect', i => {
                if (i.setCustomId === 'ad') {
                    interaction.reply('Hello! This is Administration Embed')
                }
            })
            
        
    }
 }
calm crest
#

or what is that supposed to mean?

willow acorn
#

It should be an i...

calm crest
#

interactions does not have an author

willow acorn
#

Oh

calm crest
#

also m.author.id != client.user.id; does not do anything since ur bot cant press interactions

willow acorn
#

Wdym by that

#

Removing m doesnt work either

calm crest
#

@willow acornfirst add await to interaction.reply:

await  interaction.reply...

i assume u want to filter the message collector to only accept the user who ran the command, if so then your filter should be

const filter = i => i.customId === 'ad' && interaction.user.id == i.user.id;
willow acorn
#

Let me try

#

I have async?
await is only valid in async functions and the top level bodies of modules

#

Oh no

#

Im dumb

calm crest
#

did u figure out how to solve that error

willow acorn
#

Yep

#

Still no response from th ebutton

calm crest
# willow acorn Yep

add await to this part as well

 interaction.reply({ embeds: [embed], allowedMentions: { repliedUser: false }, components: [row]})
#

it could be that it is creating the message collector before the interaction was updated

willow acorn
#

Done

#

Ahh

calm crest
#

ur calling createMessageCollector

#

ur collecting messages not responses from the interaction

willow acorn
#

...

calm crest
#

if u want to collect the interaction responses then use createMessageComponentCollector:

const collector = interaction.createMessageComponentCollector({ filter, time: 10000 }); 
#

also, ```js
if (i.setCustomId === 'ad') {
await interaction.reply('Hello! This is Administration Embed')
}

this part is wrong, `setCustomId` is a function, you are comparing a function to a string
willow acorn
#

Unhandled Rejection: TypeError: interaction.createMessageComponentCollector is not a function

calm crest
#

wait a sec

willow acorn
#

This is the code as of rn

const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
let { commands } = require('../');

 module.exports = {
     name: 'help',
     category: 'info',
     description: 'Lost? Get help here!',
     
        run: async (interaction, channel) => {

            const embed = new MessageEmbed()
                .setAuthor({ name: 'Help Embed'})
                .setColor('GREEN')
                .setDescription(`Hello There! Seems like you have lost yourself... Don't worry! I'm here to help! Select what you need help with down below!`)

            const button = new MessageButton()
                .setLabel('Administration')
                .setEmoji('๐Ÿ‘‘')
                .setStyle('SUCCESS')
                .setCustomId('ad')

            const row = new MessageActionRow()
                .addComponents([ button ]);

            await interaction.reply({ embeds: [embed], allowedMentions: { repliedUser: false }, components: [row]})

            const filter = i => i.customId === 'ad' && interaction.user.id == i.user.id;

            const collector = interaction.createMessageComponentCollector({ filter, time: 10000 }); 
            
            collector.on('collect', async(i) => {
                if (i.setCustomId === 'ad') {
                    await interaction.reply('Hello! This is Administration Embed')
                  }
            })
            
        
    }
 }
#

@calm crest You there?

#

@calm crest?

calm crest
#

@willow acorn interaction.channel.createMessageComponent....

willow acorn
#

Still nothing...

#
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
let { commands } = require('../');

 module.exports = {
     name: 'help',
     category: 'info',
     description: 'Lost? Get help here!',
     
        run: async (interaction, channel) => {

            const embed = new MessageEmbed()
                .setAuthor({ name: 'Help Embed'})
                .setColor('GREEN')
                .setDescription(`Hello There! Seems like you have lost yourself... Don't worry! I'm here to help! Select what you need help with down below!`)

            const button = new MessageButton()
                .setLabel('Administration')
                .setEmoji('๐Ÿ‘‘')
                .setStyle('SUCCESS')
                .setCustomId('ad')

            const button1 = new MessageButton()
                .setLabel('Fun')
                .setEmoji('๐ŸŽ‰')
                .setStyle('SUCCESS')
                .setCustomId('fun')

            const row = new MessageActionRow()
                .addComponents([ button, button1 ]);

            await interaction.reply({ embeds: [embed], allowedMentions: { repliedUser: false }, components: [row]})

            //const filter = i => i.customId === 'ad' && interaction.user.id == i.user.id;

            //const collector = interaction.createMessageComponentCollector({ filter, time: 10000 }); 
            const collector = interaction.channel.createMessageComponentCollector(); 
            
            collector.on('collect', async(i) => {
                if (i.setCustomId === 'ad') {
                    await interaction.reply('Hello! This is Administration Embed')
                  } else {
                      if (i.customId === 'fun') {
                          await interaction.reply('This is a Fun Embed')
                      }
                  }
            })
            
        
    }
 }
royal lichen
#

i.setCustomId does not exist

#

and you're replying to the wrong interaction in the collect event

willow acorn
#

I made an interactionCreate event

#

Unhandled Rejection: Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.

#

After clicking the button, this is what i get

willow acorn
royal lichen
#

that's not replying to the interaction

willow acorn
#

Ahh

#

It works now