#Button
1 messages ยท Page 1 of 1 (latest)
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')
}
})
}
}
m.author.id != client.user.id; what is m?
or what is that supposed to mean?
It should be an i...
Oh
also m.author.id != client.user.id; does not do anything since ur bot cant press interactions
@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;
Let me try
I have async?
await is only valid in async functions and the top level bodies of modules
Oh no
Im dumb
did u figure out how to solve that error
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
WAIT i just realised
ur calling createMessageCollector
ur collecting messages not responses from the interaction
...
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
Unhandled Rejection: TypeError: interaction.createMessageComponentCollector is not a function
wait a sec
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?
@willow acorn interaction.channel.createMessageComponent....
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')
}
}
})
}
}
i.setCustomId does not exist
and you're replying to the wrong interaction in the collect event
I never saw that...
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
How?