this is my code
const Discord = require('discord.js');
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message => {
if (message.content === `[ done ] the @🔥 gold 🔥 succes`) {
message.channel.send('!addinvites @username_who_write_in_code 50');
}
});
client.login(token);
i dont know how can i get it nodejs username who write in the code i try it just simple but not working any pepole name how can i give it the user name?
In the API, message.author
gives the message's author, which can be used to find the username. However, pings in discord.js
work differently than in channel, requiring the user's ID rather than their username. Here's a quick example:
...
message.channel.send("!addinvites <@${message.author.id}> 50");
...