Discord.js Very simple question with arguments

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

I think that was from console.log(args.shift().join(' ')); though - I’m asking for you to me the updated version of this from console.log(args);

Oh yes correct sorry

Output:

<@536467985783848971> Testing if this works or not

Code:

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

So console.log(args); logs the text below into the Glitch project logs?

yes it logs it
<@536467985783848971> Testing if this works or not

Is that in an array?

I just want to remove the 1st argument is there any other way like

message.content.slice(${member})