args discord js code example
Example 1: define args discord
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
Example 2: discord.js arguments
let seperateArgs = args[0];
let fullArgs = args.slice(0).join(' ');
Example 3: args slice discord.js
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command === "RandomCommand") {
let firstArgs = args[0];
let secondArgs = args[1];
if (firstArgs && secondArgs) {
message.channel.send(firstArgs, secondArgs)
}
}
Example 4: how to define args using param discord.js
const prefix = "!";
const args = message.content.substring(prefix.length).split(" ")