I have a command in my discord.js file that allows users to vote for someone using a !vote @user command. Whenever I print out @user, I get <@!user_id>
. Is there a way to turn that value into something manipulatable to for example, get @users's username or mute them in a voice call like when using msg.user
?
client.on('message', msg) {
if (msg.content.startsWith('!')) {
let command = msg.content.substring('!'.length);
let ping = command.split(' ');
if(command == 'vote') {
// Convert <@!user_id> into a manipulatable user?
let user_information = ping[1]
}
}
}
You could use message.mentions.users
Like this:
const mention = message.mentions.users.first();
Or if you wanted the member you could use message.mentions.members.first()
like:
const mention = message.mentions.members.first();
If you don't want to use that you could use discord.js's guide on parsing mentions