mardi 6 avril 2021

how to check number of args

I want my code to check that the person is inputting 2 or more arguments. I tried using if statements. I'm not sure if that's what I should use or should I try a function statement? My current code is:

module.exports = {
    name: 'report',
    description: "report a naughty person",
    async execute(message, args, Discord, client){ 
    const reason = args.splice(1)

if (arguments.length >= 2){ 

    let embed = new Discord.MessageEmbed()
        .setColor('#1ed700')
        .setTitle('Report \n')
        .setDescription(`Person who reported ${message.author} \n`
        + `Channel reported in: ${message.channel}\n`
        + `Person reported: ${args[0]} \n` //The second argument
        + `Reason reported: ${reason.join(' ')}`) // The third argument
         

    let messageEmbed = await message.channel.send(embed);
    message.channel.send(`<@&${process.env.DUMMY_ROLE}>`)
    
    }else if (arguments.length < 2) {
        message.channel.send('Command is not written properly')

}}};

Currently, the if statements aren't really doing anything to my knowledge.

Aucun commentaire:

Enregistrer un commentaire