Is there any method that i can use

to update my embed message? I hope I describe my problem right. I send a embed messege in a channel and then the bot respond I choise from the select menu something and the bot responsed again with a new msg but it's possibile to update the first msg to the sec that I only have 1 embed and not two? Ty for advise me
10 Replies
d.js toolkit
d.js toolkit3w 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!
Nicolas Matheisen
u see the bot responsed the messeg but I want to delete the upper one or update
d.js docs
d.js docs3w ago
:method: StringSelectMenuInteraction#update @14.15.3 Updates the original message of the component on which the interaction was received on.
// Remove the components from the message
interaction.update({
content: "A component interaction was received",
components: []
})
.then(console.log)
.catch(console.error);
// Remove the components from the message
interaction.update({
content: "A component interaction was received",
components: []
})
.then(console.log)
.catch(console.error);
Nicolas Matheisen
ohhh ok I try it and test it sec It dont want update
await interaction.reply('Ping!');
await interaction.reply('Pong!');
await interaction.deleteReply();
await interaction.reply('Ping!');
await interaction.reply('Pong!');
await interaction.deleteReply();
if I write it in this order it delete pong any idea how to delete ping ?
Nicolas Matheisen
ok sec
const {
SlashCommandBuilder,
EmbedBuilder,
StringSelectMenuBuilder, StringSelectMenuOptionBuilder,
ActionRowBuilder,
ComponentType
} = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('start')
.setDescription('Dein Abenteuer beginnt!'),
async execute(interaction) {
const exampleEmbed = new EmbedBuilder()
.setColor('#0099FF')
.setTitle('Wähle eine Berufung!')
.setDescription('Du kannst zwischen folgenden Berufungen wählen:')
.addFields(
{ name: ':warrior: Krieger',
value: '\u200b'
},
{ name: ':mage: Zauberer', value: '\u200b' },
{ name: ':martialartist: Kampfkünstler', value: '\u200b' },
{ name: ':priest: Priester', value: '\u200b' },
{ name: ':thief: Dieb', value: '\u200b' },
{ name: ':minstrel: Barde', value: '\u200b' }
);

const select = new StringSelectMenuBuilder()
.setCustomId(interaction.id)
.setPlaceholder('Wähle eine Berufung!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Krieger')
.setDescription('Mächtige Kämpfer, die ihre Gefährten furchtlos verteidigen.')
.setValue('Krieger'),
new StringSelectMenuOptionBuilder()
.setLabel('Zauberer')
.setDescription('Experten der Kampfmagie, die Hackfleisch aus Monstern machen.')
.setValue('Zauberer'),
new StringSelectMenuOptionBuilder()
.setLabel('Kampfkünstler')
.setDescription('Bei Kampfkünstlern stehen Stärke und Flinkheit an erster Stelle.')
.setValue('Kampfkünstler'),
new StringSelectMenuOptionBuilder()
.setLabel('Priester')
.setDescription('Meister der Heilmagie, die auch den Kampf nicht scheuen, wenn es die Umstände verlangen.')
.setValue('Priester'),
new StringSelectMenuOptionBuilder()
.setLabel('Dieb')
.setDescription('Vielseitige Vagabunden mit einem Riecher für Reichtümer.')
.setValue('Dieb'),
new StringSelectMenuOptionBuilder()
.setLabel('Barde')
.setDescription('Multitalente, die ihre Umgebung mit vielerlei Wunderwerken zu begeistern wissen.')
.setValue('Barde'),
);

const row = new ActionRowBuilder()
.addComponents(select);

const reply = await interaction.reply({
embeds: [exampleEmbed],
components: [row],
});

const collector = reply.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
filter: (i) => i.user.id === interaction.user.id && i.customId === interaction.id,
time: 60_000,
});

collector.on('collect', (interaction) => {
if (!interaction.values.length) {


interaction.reply('Du hast keine Berufung gewählt!');
return;
}


interaction.reply(`Du hast folgende Berufung gewählt: ${interaction.values}`);
});

},
};
const {
SlashCommandBuilder,
EmbedBuilder,
StringSelectMenuBuilder, StringSelectMenuOptionBuilder,
ActionRowBuilder,
ComponentType
} = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('start')
.setDescription('Dein Abenteuer beginnt!'),
async execute(interaction) {
const exampleEmbed = new EmbedBuilder()
.setColor('#0099FF')
.setTitle('Wähle eine Berufung!')
.setDescription('Du kannst zwischen folgenden Berufungen wählen:')
.addFields(
{ name: ':warrior: Krieger',
value: '\u200b'
},
{ name: ':mage: Zauberer', value: '\u200b' },
{ name: ':martialartist: Kampfkünstler', value: '\u200b' },
{ name: ':priest: Priester', value: '\u200b' },
{ name: ':thief: Dieb', value: '\u200b' },
{ name: ':minstrel: Barde', value: '\u200b' }
);

const select = new StringSelectMenuBuilder()
.setCustomId(interaction.id)
.setPlaceholder('Wähle eine Berufung!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Krieger')
.setDescription('Mächtige Kämpfer, die ihre Gefährten furchtlos verteidigen.')
.setValue('Krieger'),
new StringSelectMenuOptionBuilder()
.setLabel('Zauberer')
.setDescription('Experten der Kampfmagie, die Hackfleisch aus Monstern machen.')
.setValue('Zauberer'),
new StringSelectMenuOptionBuilder()
.setLabel('Kampfkünstler')
.setDescription('Bei Kampfkünstlern stehen Stärke und Flinkheit an erster Stelle.')
.setValue('Kampfkünstler'),
new StringSelectMenuOptionBuilder()
.setLabel('Priester')
.setDescription('Meister der Heilmagie, die auch den Kampf nicht scheuen, wenn es die Umstände verlangen.')
.setValue('Priester'),
new StringSelectMenuOptionBuilder()
.setLabel('Dieb')
.setDescription('Vielseitige Vagabunden mit einem Riecher für Reichtümer.')
.setValue('Dieb'),
new StringSelectMenuOptionBuilder()
.setLabel('Barde')
.setDescription('Multitalente, die ihre Umgebung mit vielerlei Wunderwerken zu begeistern wissen.')
.setValue('Barde'),
);

const row = new ActionRowBuilder()
.addComponents(select);

const reply = await interaction.reply({
embeds: [exampleEmbed],
components: [row],
});

const collector = reply.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
filter: (i) => i.user.id === interaction.user.id && i.customId === interaction.id,
time: 60_000,
});

collector.on('collect', (interaction) => {
if (!interaction.values.length) {


interaction.reply('Du hast keine Berufung gewählt!');
return;
}


interaction.reply(`Du hast folgende Berufung gewählt: ${interaction.values}`);
});

},
};
cause it look wired sec If I replace this happend :
Nicolas Matheisen
now I got it just the select menu is too much
Nicolas Matheisen
xD hart