find a customid

How do i find a customid that was used
23 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Idris
Idris2y ago
<MessageComponentInteraction>.customId
Soap
SoapOP2y ago
wdum can i have an example
Idris
Idris2y ago
I just sent the example
Soap
SoapOP2y ago
whats MessageComponentInteraction
Idris
Idris2y ago
your button or select menu
Soap
SoapOP2y ago
huh? ReferenceError: MessageComponentInteraction is not defined
d.js docs
d.js docs2y ago
Explaining <Class> and Class#method notation: learn more
Soap
SoapOP2y ago
what about my button or select menu?
jay
jay2y ago
the name of your button or menu for example button.customId
Soap
SoapOP2y ago
const userinfo = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`userinfo-${id}`)
.setLabel(`Requested by ${requested}`)
.setStyle(ButtonStyle.Secondary)
.setDisabled(false)
);
const userinfo = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`userinfo-${id}`)
.setLabel(`Requested by ${requested}`)
.setStyle(ButtonStyle.Secondary)
.setDisabled(false)
);
what would the name be for this one? ?
Squid
Squid2y ago
whenever someone clicks that button, it will emit the interactionCreate event with a ButtonInteraction instance (an extension of the MessageComponentInteraction class) which has a .customId property that would be the userinfo-${id} string
Soap
SoapOP2y ago
yeah but what do i use to get the customId
Squid
Squid2y ago
a ButtonInteraction instance (...) which has a .customId property
Soap
SoapOP2y ago
so ButtonInteraction.customId?
Squid
Squid2y ago
If ButtonInteraction is how you defined your ButtonInteraction instance and not the ButtonInteraction class itself, then yes!
Soap
SoapOP2y ago
i honestly dont know what most of what you said means
Squid
Squid2y ago
// ButtonInteraction class
const { ButtonInteraction } = require('discord.js');

// ButtonInteraction instance
client.on('interactionCreate', interaction => {
if (interaction.isButton()) console.log(interaction.customId);
});
// ButtonInteraction class
const { ButtonInteraction } = require('discord.js');

// ButtonInteraction instance
client.on('interactionCreate', interaction => {
if (interaction.isButton()) console.log(interaction.customId);
});
Soap
SoapOP2y ago
i have:
const {
SlashCommandBuilder,
EmbedBuilder,
ApplicationCommandOptionType,
CommandInteractionOptionResolver,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Events,
ButtonInteraction,
} = require("discord.js");

module.exports = {
data: {
name: `userinfo`,
},
async execute(interaction, client) {
const message = await interaction.deferReply({
fetchReply: true,
});
const custom = ButtonInteraction.customId;
// const split = custom.split(" - ");
// const newMessage = split[1];

await interaction.editReply({
content: custom,
});
},
};
const {
SlashCommandBuilder,
EmbedBuilder,
ApplicationCommandOptionType,
CommandInteractionOptionResolver,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Events,
ButtonInteraction,
} = require("discord.js");

module.exports = {
data: {
name: `userinfo`,
},
async execute(interaction, client) {
const message = await interaction.deferReply({
fetchReply: true,
});
const custom = ButtonInteraction.customId;
// const split = custom.split(" - ");
// const newMessage = split[1];

await interaction.editReply({
content: custom,
});
},
};
but: rawError: { message: 'Cannot send an empty message', code: 50006 },
Squid
Squid2y ago
Because you defined ButtonInteraction as the class ButtonInteraction.customId attempts to access the customId static property of the ButtonInteraction class, which is undefined, so Discord sees you're trying to send a message without content
d.js docs
d.js docs2y ago
guide Popular Topics: Interaction collectors - Basic message component collector read more
Squid
Squid2y ago
This is the best way to temporarily collect button interactions that were sent in response to commands
Soap
SoapOP2y ago
how do i save ButtonInteraction then
Want results from more Discord servers?
Add your server