Discord.js: Multiple Args For One Variable
i`m try to make this: !send message who sended (message who sended is 3 args but i'm need one) Who send arguments after message ID (args[0]) for everyone who reacted to
Solution 1:
If you want to join multiple arguments together, you can use splice
and join
To begin, we need to define it as a new variable equal to args
messageable = args
Next, use splice to make a new array out of the index. If you want to make it so it is everything after the <id>
, remove ,5
, so .splice(2)
messageable = args.splice(2,5)
Finally, join it into a string using join
, adding a space in-between the arguments
messageable = args.splice(2,5).join(" ")
With this, messageable
should look like "message who sended"
Post a Comment for "Discord.js: Multiple Args For One Variable"