Edit embed in DM

Hi, I've already written on the djs-help-v14 channel and received a hint on how I can edit the embed using interaction.update({ components: [] }), but I still don't know how to do it, and I'm out of ideas. I want to achieve the following effect: When sending a private message to the user with information that they have received a warning (message in an embed), it also creates a button for an appeal in the embed. After clicking the button, it creates a modal. I want the embed in the private message to be updated after sending the modal (so that the appeal button is removed or set to .setDisabled(true) after successfully sending the modal [isModalSubmit]). Class 'interactionCreate':
if (interaction.isModalSubmit()) {
if (interaction.customId === "modal") {
const fields = interaction.fields.fields;
const administratorNameInput = fields.get("administrator-name-input").value;
const appealDescription = fields.get("appeal-description").value;
const incidentDate = fields.get("incidentDate").value;
const guild = interaction.guild || await client.guilds.fetch(config.guildID);

if (guild) {
const guildChannelId = config.guildChannelId;
const guildChannel = guild.channels.cache.get(guildChannelId);

if (guildChannel) {
guildChannel.send(`INPUT1: ${administratorNameInput}\nINPUT2: ${appealDescription}\nUser: ${interaction.user.tag} (<@${interaction.user.id}>)\nDate: ${incidentDate}`);
interaction.deferUpdate();
} else {
console.error("<interactionCreate.js:60>");
}
} else {
console.error("<interactionCreate.js:60>");
}
}
}
if (interaction.isModalSubmit()) {
if (interaction.customId === "modal") {
const fields = interaction.fields.fields;
const administratorNameInput = fields.get("administrator-name-input").value;
const appealDescription = fields.get("appeal-description").value;
const incidentDate = fields.get("incidentDate").value;
const guild = interaction.guild || await client.guilds.fetch(config.guildID);

if (guild) {
const guildChannelId = config.guildChannelId;
const guildChannel = guild.channels.cache.get(guildChannelId);

if (guildChannel) {
guildChannel.send(`INPUT1: ${administratorNameInput}\nINPUT2: ${appealDescription}\nUser: ${interaction.user.tag} (<@${interaction.user.id}>)\nDate: ${incidentDate}`);
interaction.deferUpdate();
} else {
console.error("<interactionCreate.js:60>");
}
} else {
console.error("<interactionCreate.js:60>");
}
}
}
4 Replies
d.js toolkit
d.js toolkit11mo 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
oneyz_
oneyz_OP11mo ago
fragment class 'warn.js':
const warnDM = target.user.send ({
embeds: [
new EmbedBuilder()
.setTitle(`Warn for - ${target.user.tag}`)
.setDescription(`info guild (${interaction.guild.name})`)
.setColor('Red')
.addFields(
{ name: 'Administrator', value: `${administrator}`, inline: true },
{ name: '\u200b', value: '\u200b', inline: true },
{ name: 'Reason', value: `${reason}`, inline: true },
{ name: '\u200b', value: '\u200b', inline: true }
)
.setThumbnail(avatarTargetURL)
.setFooter(
{
text: 'smth of appeal',
iconURL: 'https://i.imgur.com/dXAkEzI.png'
}
)
.setTimestamp()
],
components: [
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setLabel("Appeal")
.setStyle(ButtonStyle.Success)
.setCustomId("appeal-warn")
)
]
});
const warnDM = target.user.send ({
embeds: [
new EmbedBuilder()
.setTitle(`Warn for - ${target.user.tag}`)
.setDescription(`info guild (${interaction.guild.name})`)
.setColor('Red')
.addFields(
{ name: 'Administrator', value: `${administrator}`, inline: true },
{ name: '\u200b', value: '\u200b', inline: true },
{ name: 'Reason', value: `${reason}`, inline: true },
{ name: '\u200b', value: '\u200b', inline: true }
)
.setThumbnail(avatarTargetURL)
.setFooter(
{
text: 'smth of appeal',
iconURL: 'https://i.imgur.com/dXAkEzI.png'
}
)
.setTimestamp()
],
components: [
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setLabel("Appeal")
.setStyle(ButtonStyle.Success)
.setCustomId("appeal-warn")
)
]
});
mallusrgreat
mallusrgreat11mo ago
its the same as interaction.editReply you can use EmbedBuilder.from(interaction.message.embeds[index]) to construct an embed, taking the embed of the message of the interaction as the base
oneyz_
oneyz_OP11mo ago
thanks, already make it
Want results from more Discord servers?
Add your server