JudeLT
JudeLT

Reputation: 11

How would I make a command display more then one ARG

I am trying to make a /say command

Using the only code as

message.channel.send(args[1])

It then sends Arg one, but then how would I make it do infinite arguments. To extend it.

Upvotes: 1

Views: 36

Answers (2)

BrunoT
BrunoT

Reputation: 442

Discord.js documentation says that channel.send() accepts message content as a string and options as an object.

Reference: https://discord.js.org/#/docs/main/master/class/TextChannel?scrollTo=send

Therefore, you cannot extend the send() method. You could easily just concatenate the args strings and send them as one message. If you really need a send() function that accepts infinite parameters you could create your own implementation the following way:

// Delimiter defines the string by which the args strings will be joined
function send(channel, delimiter, ...args) {
    channel.send(args.join(delimiter));
}
send(message.channel, " ", args[1], args[2], args[3]);

Upvotes: 0

Radnerus
Radnerus

Reputation: 592

args is an array of string. So you can either do message.channel.send(args[1]+' '+args[2]); (Which is not very efficient if want to send more strings.) or do let statement = args.join(' '); which would join all the strings in the array with a space and then send statement.

Upvotes: 1

Related Questions