Cannot parse command arguments in JS

85 Views Asked by At

So i need the command !!ban [user] [length] [reason] to be put into 3 variables. As seen below:

run: async(message, client, args) => {
   let banned = message.mentions.users.first() || client.users.resolve(args[0]);
   const time = args.shift(2)
   const reason = args.slice(1).join(' ');
    

After some code we get to this:

 message.guild.members.ban(banned, { reason: reason });

  let successfullyembed = new discord.MessageEmbed()
    .setTitle('Successfully banned!')
    .setDescription(`${banned.tag} has been successfully banned.`)
    .addFields(
        { name: `Reason: ${reason}`, value: `Ban Length: ${time}`, inline: false },

    )
    .setColor("#2C2F33");
    message.channel.send(successfullyembed);

And the embed for it looks like this:

Successfully banned!
CandyMan#6411 has been successfully banned.
Reason: 3h s;egjf bs;g;sgbn s;jknghkjnh \nih\se
Ban Length: undefined

I know it has something to do with the args at the start, but me being relatively new to JS, I cant pinpoint what.

0

There are 0 best solutions below