discord https api how to pass arguments 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: 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]; //first argument
  let secondArgs = args[1]; //second argument
  if (firstArgs && secondArgs) { //check if the args are existing
  	message.channel.send(firstArgs, secondArgs) //send the value of the args
  }
}

Tags:

Misc Example