Reputation: 39
I have an embed bot for a bounty system that users can pick up bounties that people set up. With my code a user can set a title for the embed using args. I'm trying to allow them to set the description and possibly the footer here is my code. Any help would be appreciated. I was thinking something like
!bounty Title + Description but I'm not sure how to allow for user input in the description I can set the bot to DM and allow for user input for each field but I want something more user-friendly and fast.
if (!args[0]) return message.reply('You need to supply the question');
let embed = new Discord.MessageEmbed()
.setTitle(args.join(' '))
.setDescription('Bounty posted by ' + message.author.tag)
.addField('Status', 'Bounty is currently available.')
.setColor('#ffd700')
.attachFiles(new Discord.MessageAttachment('https://i.imgur.com/eGEKp8k.png', 'thumbnail.png'))
.setThumbnail('attachment://thumbnail.png')
.setFooter('Bot created by James (Rock)₇₇₇');
Upvotes: 1
Views: 1739
Reputation: 1245
What you could do is introduce some kind of separator into your command. That way you can keep the Title apart from the Description.
What you need to do first is get the index of your separator. Note: In this example I use the separator ->
. You can use whatever you want.
let i = args.indexOf("->");
Next we get the Title by slicing from the first element in args
to the point of our separator.
let Title = args.slice(0, i);
Next we get the description. We get that by slicing off the part before the separator. Once that is done we remove the separator entirely.
let Description = args.slice(i);
Description.shift();
Now that we have both our Title
and our Description
we can put them inside our embed. Note: Keep in mind that we now have two arrays
as our Title and Description.
let embed = new Discord.MessageEmbed()
.setTitle(Title.join(" "))
.setDescription(`Bounty posted by ${message.author.tag}
${Description.join(" ")}`)
// the rest of your embed
Upvotes: 1