find a customid

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