Discord.js Very simple question with arguments

Script:

const Discord = require(‘discord.js’);
module.exports =
{
name: ‘Warn’,
description: Warn people use 'space' to give reason,
cooldown: “3”,
run: async(message,args) =>
{
//args is Argument without prefix and command
const sender = message.member
if (sender.hasPermission(‘KICK_MEMBERS’))
{
const member = message.mentions.members.first();
var Embed = new Discord.MessageEmbed()
.setDescription(${member} was warned for ${args.join(' ').split(&{member}).join(' ')})
.setColor(’#56F99C’)
message.channel.send(Embed)
}
},
};

I want to remove the 1st argument from args which is table

Sorry but i had to blur the name due to some reason

You can remove the first argument from args (an array) by using .shift().

args.shift();

Ok i will try it right now

1 Like

I manipulated the code a bit

        const member = message.mentions.members.first();
        var Embed = new Discord.MessageEmbed()
        .setDescription(`${member} was warned for ${args.shift().join(' ')}`)
        .setColor('#56F99C')
	      message.channel.send(Embed)

TypeError: args.shift(…).join is not a function
Did i miss something?

For .shift() to work, args must be an array.

1 Like

Here is args

args = message.content.split(’.${Command}’)
//this works^

I just want to remove the 1st argument

Can you do console.log(args); and paste the result here?

1 Like

Ok i will do it right now

Here is what it printed

[ ‘<@536467985783848971>’, ‘Testing’ ]

1 Like

So you don’t want the first argument (which is the user’s mention), right?

Yes what i am trying to do is remove the user mention and the rest is the reason for warn so i just want to remove the mentioned name

Sorry if this was already answered but you should just be able to do args.slice(0).join(' ');

Can you do console.log(args); right at the start of the run function and tell us what it logs actually?

We were trying to do

args.shift().join(’ ')

Try this:

const Discord = require(‘discord.js’);
module.exports =
{
name: ‘Warn’,
description: Warn people use ',' to give reason,
cooldown: “3”,
run: async(message, args) =>
{
console.log(args);
const sender = message.member
if (sender.hasPermission(‘KICK_MEMBERS’))
{
const member = message.mentions.members.first();
var Embed = new Discord.MessageEmbed()
.setDescription(${member} was warned for ${args.slice(0).join(' ')})
.setColor(’#56F99C’)
message.channel.send(Embed)
}
},
};


It still pings the user in reason

Can you show us what the bot logs though?

It logs all the things:
User mention Testing if this works or not
all sperate by comma

I have already sent this also you can see it above as well