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

//Seperate Arguments
let seperateArgs = args[0]; //0 being the first argument
//Input "hello world"
//Output "hello"

//Full Arguments
let fullArgs = args.slice(0).join(' ');
//Input "hello world"
//Output "hello world"

Example 3: how to define args using param discord.js

const prefix = "!";
const args = message.content.substring(prefix.length).split(" ")

Example 4: discord bot how to make that if a specific player types the command something else will happen

else if(user == 'USER ID'){
            return message.channel.send('I rate SpaceTie a 100/100')
        }