Is it possible to save hidden data in embed?

Is there anyway to save hidden data in embed, because i have command sending an embed and that embed has buttons, after user clicking the button, i need to extract a data from command parameters like a channelId or something, is it possible?
8 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Kryp Arnold
Kryp ArnoldOP13mo ago
async execute(interaction: ChatInputCommandInteraction) {
const embed = new EmbedBuilder()
.setTitle("#" + (interaction.channel as TextChannel).name)
.setColor(Colors.DarkGreen);

const setupButton = new ButtonBuilder()
.setCustomId("word-game-setup")
.setLabel(localizations[interaction.locale === Locale.Turkish ? "tr" : "en"].buttons.setup)
.setStyle(ButtonStyle.Primary);

const buttonRow = new ActionRowBuilder()
.addComponents(setupButton);

await interaction.reply({
embeds: [embed],
//@ts-ignore
components: [buttonRow],
ephemeral: true
});
},
async execute(interaction: ChatInputCommandInteraction) {
const embed = new EmbedBuilder()
.setTitle("#" + (interaction.channel as TextChannel).name)
.setColor(Colors.DarkGreen);

const setupButton = new ButtonBuilder()
.setCustomId("word-game-setup")
.setLabel(localizations[interaction.locale === Locale.Turkish ? "tr" : "en"].buttons.setup)
.setStyle(ButtonStyle.Primary);

const buttonRow = new ActionRowBuilder()
.addComponents(setupButton);

await interaction.reply({
embeds: [embed],
//@ts-ignore
components: [buttonRow],
ephemeral: true
});
},
here is my command's execute function
async execute(interaction: ButtonInteraction){
console.log(interaction.message.embeds[0]); // I need to extract hidden data here.
}
async execute(interaction: ButtonInteraction){
console.log(interaction.message.embeds[0]); // I need to extract hidden data here.
}
here is my button's execute function im thinking a way, i can store the id thing in my customId, is it a good way?
treble/luna
treble/luna13mo ago
No. Use collectors
Kryp Arnold
Kryp ArnoldOP13mo ago
oh, i got it, i'll send the embed and then i'll wait for the button interaction right?
treble/luna
treble/luna13mo ago
yes
d.js docs
d.js docs13mo ago
In TypeScript the ActionRowBuilder class has a generic type parameter that specifies the type of component the action row holds:
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
Kryp Arnold
Kryp ArnoldOP13mo ago
oh thank you so much
Want results from more Discord servers?
Add your server