Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

EDIT so i am trying to make a embed command and it will send a embed given the user input, a user will send the command like `.embed ?d description ?f footer ?i image url

so on

how do i make the options like ?d and ?f optional and the order want matter but it will create the embed on the given options

'example: .embed ?d description : this will create a embed with only a description'

i have already tried but i messed up here is the code https://hatebin.com/uzdsqwtqyw

but this outputs this :

enter image description here

question from:https://stackoverflow.com/questions/65858794/having-optional-args-for-discord-js-embed-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
935 views
Welcome To Ask or Share your Answers For Others

1 Answer

What you need to do is : go in your main file(like index.js) and set in top of code this :

const Discord = require('discord.js');

Then where command 'embed' is you need to set this :

if(command === 'embed'){
          client.commands.get('embed').execute(message, args, Discord);

Then in your command folder you will make a file named embed.js . In embed.js you need to set this code:

module.exports = {
    name: 'embed',
    description: 'Embed Test',
    execute(message, args, Discord){
        const newEmbed = new Discord.MessageEmbed()
        .setTitle('Your Title')
        .setColor('RANDOM')
        .setFooter('Some Footer here', 'another footer here' )
        .setDescription('> ?testa
' + '> ?testb
' + '> testc');
        message.delete();
        message.channel.send(newEmbed);
    }

});

And you get only the description after command and message with command ([prefix]embed) will delete after you post it !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...