find a customid

How do i find a customid that was used
23 Replies
d.js toolkit
d.js toolkit3y 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
</> Idris3y ago
<MessageComponentInteraction>.customId
Soap
SoapOP3y ago
wdum can i have an example
</> Idris
</> Idris3y ago
I just sent the example
Soap
SoapOP3y ago
whats MessageComponentInteraction
</> Idris
</> Idris3y ago
your button or select menu
Soap
SoapOP3y ago
huh? ReferenceError: MessageComponentInteraction is not defined
d.js docs
d.js docs3y ago
Explaining <Class> and Class#method notation: learn more
Soap
SoapOP3y ago
what about my button or select menu?
jay
jay3y ago
the name of your button or menu for example button.customId
Soap
SoapOP3y 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
Squid3y 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
SoapOP3y ago
yeah but what do i use to get the customId
Squid
Squid3y ago
a ButtonInteraction instance (...) which has a .customId property
Soap
SoapOP3y ago
so ButtonInteraction.customId?
Squid
Squid3y ago
If ButtonInteraction is how you defined your ButtonInteraction instance and not the ButtonInteraction class itself, then yes!
Soap
SoapOP3y ago
i honestly dont know what most of what you said means
Squid
Squid3y 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
SoapOP3y 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
Squid3y 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 docs3y ago
guide Popular Topics: Interaction collectors - Basic message component collector read more
Squid
Squid3y ago
This is the best way to temporarily collect button interactions that were sent in response to commands
Soap
SoapOP3y ago
how do i save ButtonInteraction then

Did you find this page helpful?