0
votes

So I want to make a command that allows someone to send an embed message, they can decide the description, and color, no need for a title. and to set a color, they should write "-color #[color]" (E.G: !embed description -color #00000). That's my code:

const say = args.join(" ");
message.channel.send(say)
message.delete()
}
if (command === 'embed') {
    if (!args[1]) return message.reply('Please input a description and a color.');
    description : arg[1]
    color : arg[2]
    const exampleEmbed = new Discord.MessageEmbed()
    .setColor(color)
    .setDescription(description)

channel.send(exampleEmbed);
  }

However it's not working, also I'm new in discord.js, can someone fix my code?

1

1 Answers

0
votes

Try this:

if (args.length < 2) return message.reply('Please provide a color and a description')
let description = '';
do {
    if (args[0].toLowerCase() === '-color') {
        args.shift();
        break;
    }
    description += ` ${args.shift()}`
} while (args.length > 1)
if (!args[0]) return message.reply('Please provide a color')
if (description === '') return message.reply('Please provide a description')
let exampleEmbed = new Discord.MessageEmbed()
    .setDescription(description)
    .setColor(args[0])
message.channel.send(exampleEmbed)