'Splitting arguments that have spaces
I'm trying to make a poll command for a bot, with the ability to set a title for the embed and a description (which will be the actual poll).
This is my code:
if (command === "pollvote") {
if(!args.length){
const embed = new Discord.MessageEmbed()
.setTitle(`You didn't give a question.`)
.setColor(`#245ebd`)
message.channel.send(embed)
return
}
var arguments = args.toString();
arguments = arguments.split(",")
const embed = new Discord.MessageEmbed()
.setTitle(arguments[0])
.setColor(`#245ebd`)
.setThumbnail(`https://media.discordapp.net/attachments/960395119809429584/976463843008086146/Videostreamers_logo_nieuw_pink3.2.png?width=666&height=666`)
.setDescription(arguments[1])
message.channel.send(embed).then(sentEmbed => {
sentEmbed.react("👍")
sentEmbed.react("👎")
});
}
The code doesn't error when running the command nor when launching the bot. The only issue is that it doesn't do the job properly
Example:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

