I'm trying to make a command in discord.js.
I want to make it where ?party (link or something here) requirements: be cool is typed and then it would say
@user has pinged for party Link: (link that was posted) requirements: be cool
I'm new to discord.js so I'm trying to learn. Thank You!
Well, prolly change you command to be something like:
?party (link) (be cool). Keep things simple :)
Then you could parse thru the contents of the command and separate out the link from the requirements, like so:
text = message.content;
// check if the text is a command for your bot
if (text.startsWith("?party")) {
// convert the contents of the command to an array, by splitting the text at spaces
// Also get the rid of the command itself (?party)
commandContents = text.split(" ").slice(1);
link = commandContents[0];
requirements = commandContents.slice(1).join(" "); // join the requirements back by spaces.
if (!link) {
message.channel.send(" no link");
} else if (!requirements) {
message.channel.send(" no requirements");
} else {
message.channel.send(
`<@${message.author.id}> has pinged for party\n \n Link: ${link}]\n\nRequirements:${requirements}\n\n@everyone`
);
}
}