Sorry if there are any typos, but english is not my first language.
Hi, I have a problem when I am trying to get userinfo from a mention. It works perfectly fine when I am doing the command on a non nicknamed user, but when I try on a nicknamed user, it only returns undefined. Keep in mind that I am using WOKCommands to handle my slash commands, and the error is happening on a slash command.
Here is the code for the command:
const { MessageEmbed } = require('discord.js');
const moment = require('moment');
module.exports = {
slash: true,
testOnly: true,
description: 'En spioneringskommando.',
minArgs: 1,
expectedArgs: '<Mention>',
callback: ({ args, client, interaction }) => {
const userId = args[0].toString().replace(/[\\<>@#&!]/g, "");
const guild = client.guilds.cache.get(interaction.guild_id);
const member = guild.members.cache.get(userId);
const embed = new MessageEmbed()
.setTitle("Spioneringsprogram v1.0")
.setDescription(`Bruker: ${member.user.username}`)
.setColor("RANDOM")
.addField("Kallenavn:", `${member.nickname ? `${member.nickname}` : 'Ingen'}`, false)
.addField("Ble medlem av discord:", `${moment.utc(member.user.createdAt).format('DD/MM/YY')}`, false)
.addField("Ble medlem av discord serveren:", `${moment.utc(member.joinedAt).format('DD/MM/YY')}`, false)
.setFooter(`ID: ${member.user.id}`)
.setTimestamp();
return embed;
}
}
And here is my index.js file:
require('dotenv').config();
const Discord = require("discord.js");
const WOKCommands = require('wokcommands');
const client = new Discord.Client();
const guildId = 'censored'
client.on('ready', () => {
console.log("Bot is ready!");
new WOKCommands(client, {
commandsDir: 'commands',
testServers: [guildId],
showWarns: false
});
});
Thanks for any help I can get.