DreamRocket
DreamRocket

Reputation: 31

Take full args list after command (Discord.js)

Hello wonderful internet people

I am writing code to set the status of my bot in discord.js. I am wondering how I can take a user's full args list and put it into one let statement, like saying (args[0] + ' ' + args[1], etc)

Here is my current code

Thank you, hope you have a great day

let statgame = (args[0])
    client.user.setActivity(statgame);

Upvotes: 1

Views: 160

Answers (2)

igk
igk

Reputation: 96

Not sure if I got you 100%. From what I understood you can achieve this with arguments object MDN

function myargs() { console.log([...arguments].join(' ')) }

Upvotes: 0

Cameron R
Cameron R

Reputation: 86

Given args is an array, JS provides a join function that does this for you

let joinedArgs = args.join(" ");

The first argument is the string that separates each element

Upvotes: 3

Related Questions