Embed User Input

I am looking to accept a user input to fill in a few values in my embed command. How would I go about doing that? I attached a photo of the design that I am trying to access to help clarify if needed!
const { SlashCommandBuilder } = require('discord.js');
const { EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('mapwipe')
.setDescription('Map Wipe Announcement'),

async execute(interaction) {

//await interaction.deferReply();

const exampleEmbed = new EmbedBuilder()
.setColor(0xef2929)
.setTitle('Rust Map Wipe')
.setURL('https://i.imgur.com/dlecsVP.png')
.setAuthor({ name: 'Dads After Dark', iconURL: 'https://i.imgur.com/dlecsVP.png', url: 'https://i.imgur.com/dlecsVP.png' })
.setDescription('Map Wipe Map Announcement')
.addFields(
{ name: 'Map Announcement', value: 'https://rustmaps.com/map/3500_547795017' },
//.addFields({ name: 'Inline field title', value: 'Some value here', inline: true })
)
.setImage('https://content.rustmaps.com/maps/247/81d3439dceb346fb96bbb1acb8f64044/thumbnail.png')
.setTimestamp()
//.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/dlecsVP.png' });

await interaction.reply({ embeds: [exampleEmbed] })
},
};
const { SlashCommandBuilder } = require('discord.js');
const { EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('mapwipe')
.setDescription('Map Wipe Announcement'),

async execute(interaction) {

//await interaction.deferReply();

const exampleEmbed = new EmbedBuilder()
.setColor(0xef2929)
.setTitle('Rust Map Wipe')
.setURL('https://i.imgur.com/dlecsVP.png')
.setAuthor({ name: 'Dads After Dark', iconURL: 'https://i.imgur.com/dlecsVP.png', url: 'https://i.imgur.com/dlecsVP.png' })
.setDescription('Map Wipe Map Announcement')
.addFields(
{ name: 'Map Announcement', value: 'https://rustmaps.com/map/3500_547795017' },
//.addFields({ name: 'Inline field title', value: 'Some value here', inline: true })
)
.setImage('https://content.rustmaps.com/maps/247/81d3439dceb346fb96bbb1acb8f64044/thumbnail.png')
.setTimestamp()
//.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/dlecsVP.png' });

await interaction.reply({ embeds: [exampleEmbed] })
},
};
No description
7 Replies
d.js toolkit
d.js toolkit9mo 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
d.js docs
d.js docs9mo ago
Suggestion for @Zach: :guide: Slash Commands: Advanced command creation - Adding options read more :guide: Slash Commands: Parsing options read more
Zach
ZachOP9mo ago
Thank you! I was able to get variables in place to handle input, but now I have a seperate issue related to it. When I send the Embed I am receiving an error and it is stopping my bot and I have to restart, any idea how to prevent this from happening? The command works perfectly, I just need it to not quit the app when I run the embed: DiscordAPIError[10062]: Unknown interaction at handleErrors (c:\Coding Projects\Javascript\DAD_BOT\node_modules@discordjs\rest\dist\index.js:722:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async BurstHandler.runRequest (c:\Coding Projects\Javascript\DAD_BOT\node_modules@discordjs\rest\dist\index.js:826:23) at async _REST.request (c:\Coding Projects\Javascript\DAD_BOT\node_modules@discordjs\rest\dist\index.js:1266:22) at async ChatInputCommandInteraction.reply (c:\Coding Projects\Javascript\DAD_BOT\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5) at async Object.execute (c:\Coding Projects\Javascript\DAD_BOT\commands\utility\mapwipe.js:32:9) at async Object.execute (c:\Coding Projects\Javascript\DAD_BOT\events\interactionCreate.js:16:4) { requestBody: { files: [], json: { type: 4, data: [Object] } }, rawError: { message: 'Unknown interaction', code: 10062 }, code: 10062, status: 404, method: 'POST', url: 'https://discord.com/api/v10/interactions/1219845625416388609/aW50ZXJhY3Rpb246MTIxOTg0NTYyNTQxNjM4ODYwOTpzUFd4VXoxVFFpNm9Yd1NZdlpHdERId1ppdDl2cmpOTWNCa05jS2tnTXVoVHpVdmlUWkE1UWFzcjBXdWFIVklaeTVlQXltTG5vSTAyamdsazBMazN3TjhLMGxMR0ZYTlRPMnlkZHdYY3M1VUFXc0lPSnZIU3lSSURwc1llQk8wRw/callback' } node:events:496 throw er; // Unhandled 'error' event ^ DiscordAPIError[40060]: Interaction has already been acknowledged. at handleErrors (c:\Coding Projects\Javascript\DAD_BOT\node_modules@discordjs\rest\dist\index.js:722:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async BurstHandler.runRequest (c:\Coding Projects\Javascript\DAD_BOT\node_modules@discordjs\rest\dist\index.js:826:23) at async _REST.request (c:\Coding Projects\Javascript\DAD_BOT\node_modules@discordjs\rest\dist\index.js:1266:22)
at async ChatInputCommandInteraction.reply (c:\Coding Projects\Javascript\DAD_BOT\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5) at async Object.execute (c:\Coding Projects\Javascript\DAD_BOT\events\interactionCreate.js:22:5) Emitted 'error' event on Client instance at: at emitUnhandledRejectionOrErr (node:events:401:10) at process.processTicksAndRejections (node:internal/process/task_queues:84:21) { requestBody: { files: [], json: { type: 4, data: { content: 'There was an error while executing this command!', tts: false, nonce: undefined, embeds: undefined, components: undefined, username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: 64, message_reference: undefined, attachments: undefined, sticker_ids: undefined, thread_name: undefined } } }, rawError: { message: 'Interaction has already been acknowledged.', code: 40060 }, code: 40060, status: 400, method: 'POST', url: 'https://discord.com/api/v10/interactions/1219845625416388609/aW50ZXJhY3Rpb246MTIxOTg0NTYyNTQxNjM4ODYwOTpzUFd4VXoxVFFpNm9Yd1NZdlpHdERId1ppdDl2cmpOTWNCa05jS2tnTXVoVHpVdmlUWkE1UWFzcjBXdWFIVklaeTVlQXltTG5vSTAyamdsazBMazN3TjhLMGxMR0ZYTlRPMnlkZHdYY3M1VUFXc0lPSnZIU3lSSURwc1llQk8wRw/callback' }
ShompiFlen
ShompiFlen9mo ago
the first error means you are taking too long to reply to the interaction the second one means you are trying to send an initial reply (.reply() or .deferReply()) to an already replied interaction you can prevent your bot from crashing using try catch to catch these promise rejections, although your should handle these errors gracefully. For the first one, you have to send a reply within the first 3 seconds of receiving it, so if you are calling some kind of database before replying to the interaction, then use interaction.deferReply()
d.js docs
d.js docs9mo ago
Common causes of DiscordAPIError[10062]: Unknown interaction: - Initial response took more than 3 seconds ➞ defer the response *. - Wrong interaction object inside a collector. - Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance) * Note: you cannot defer modal or autocomplete value responses
ShompiFlen
ShompiFlen9mo ago
for the second error, you have to avoid replying to the same interaction twice
d.js docs
d.js docs9mo ago
- DiscordAPIError: Interaction has already been acknowledged - [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred. You have already replied to the interaction. - Use <Interaction>.followUp() to send a new message - If you deferred reply it's better to use <Interaction>.editReply() - Responding to slash commands / message components
Want results from more Discord servers?
Add your server