Embed Using Options Content

I can create a slash command that has multiple options. I just am drawing the short straw trying to have my bot respond to my slash command with a formatted embed using the content provided within the options. Any help would be much appreciated! DM's are open, and I am new to this so I will try my best to easily understand any help given.
31 Replies
d.js toolkit
d.js toolkit2y 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.
Munxo
MunxoOP2y ago
Kinect3000
Kinect30002y ago
A slash command can have multiple options
d.js docs
d.js docs2y ago
guide Slash Commands: Adding options read more
Kinect3000
Kinect30002y ago
You can add as many options up to Discord’s limit
Munxo
MunxoOP2y ago
Yeah, I can do that. I have a command with mutiple commands. I know how to have my bot respond to a slash command using an embeded message that is preset, but I want one that will format the content the member provides in the options.
Kinect3000
Kinect30002y ago
Just use the interaction.options.getXOption() to get the option of x type
Munxo
MunxoOP2y ago
So like, .setDescription(interaction.options.getXOption('ign') ? Would that be a valid line of code to get the content from my option called "ign"?
Squid
Squid2y ago
if ign is a string type, you need to use get getString() instead of the example getXOption()
Munxo
MunxoOP2y ago
So id I have a command that has these:
Munxo
MunxoOP2y ago
I could do .setDescription( getString( 'server' ), ); Or something like that?
Squid
Squid2y ago
Your code up here is pretty much exactly what you need, so just make sure you're using an actual method for getting the option instead of the example you were given But yeah, you can use whichever option you want for the description as long as it's a string-type option
Munxo
MunxoOP2y ago
So would this: .setDescription( Server: getString( 'server' ), ); format it as: Server: 1 & 2 if 1 & 2 was selected for the content of the 'server' option?
Squid
Squid2y ago
Assuming this is just pseudo-code, yeah, that would work like you're saying
Munxo
MunxoOP2y ago
Uhh I have no idea Not familiar with the term pseudo-code
Squid
Squid2y ago
I just mean theoretical/non-literal code Like don't literally copy-paste the block that you sent Again, your code up here is pretty much perfect
Munxo
MunxoOP2y ago
Let me write up the full block of code for the command and I'll reply back to you. I'll obviously run the bot and test it as well I'm running into an issue with this: const { SlashCommandBuilder, ApplicationCommandOptionType } = require('discord.js'); module.exports = { data: new SlashCommandBuilder([ { name: 'report', description: 'Files a report on a player.', options: [ { name: 'server', description: 'Server 1 or 2', type: ApplicationCommandOptionType.String, required: true, }, { name: 'ign', description: 'In-game Name', type: ApplicationCommandOptionType.String, required: true, }, { name: 'punishment', description: 'Mute, Kick, Ban & Duration', type: ApplicationCommandOptionType.String, required: true, }, { name: 'reason', description: 'Why they were punished?', type: ApplicationCommandOptionType.String, required: true, }, { name: 'message-link', description: 'Copy & paste message link.', type: ApplicationCommandOptionType.String, }, { name: 'picture', description: 'Pictures of the rulebreak.', type: ApplicationCommandOptionType.Attachment, }, ], }], interaction.reply("report") )};
Squid
Squid2y ago
yeah that's not valid JS syntax you can't just call a function in the middle of an object
Munxo
MunxoOP2y ago
So then back to this: const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('report') .setDescription("Player Report"), run: ({ interaction }) => { interaction.reply("report"); }, }; I have my /report command, but it does not have any options. I have a reply, but it is not an embed.
d.js docs
d.js docs2y ago
guide Slash Commands: Adding options read moreguide Popular Topics: Embeds read more
Munxo
MunxoOP2y ago
I will post back anything I run into an issue with.
Munxo
MunxoOP2y ago
@Squid I am in need again. Here is my code:
d.js docs
d.js docs2y ago
To share long code snippets use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks.
Squid
Squid2y ago
Also an entire file doesn't really tell me what "in need" means
Munxo
MunxoOP2y ago
That code recognizes my command /report and gives me all the same options I mentioned before, but when I try to run the command even with a simple reply to it, I get this:
chewie
chewie2y ago
interaction.response.send_message isn't a thing, so makes sense use interaction.reply()
d.js docs
d.js docs2y ago
method ChatInputCommandInteraction#reply() Creates a reply to this interaction. (more...)
Munxo
MunxoOP2y ago
I replaced that chunk with interaction.reply('hello') , but the bot still does not respond..
chewie
chewie2y ago
you are returning if its a chatinputinteraction
Munxo
MunxoOP2y ago
I have this now. I have a slash command with options (required and non required), and with this code: client.on('interactionCreate', (interaction) => { if (interaction.commandName === 'report') { interaction.reply('hello') } }); it responds to my command with hello. I now need it to respond using a formatted embed using fetchReply() or getString()?
d.js docs
d.js docs2y ago
guide Slash Commands: Parsing options read more
Want results from more Discord servers?
Add your server