I am trying to make a userinfo command but it aint working.. Only giving errors like:
.join is not a function or member is not defind. My friend also did not get the errors. Anyone who could take a look at it? Thanks!
const discord = require('discord.js');
const moment = require('moment');
module.exports = {
name: 'userinfo',
description: 'let you see the info about you',
usage: '[command name]',
execute(message, args, client) {
let user = message.mentions.users.first() || message.author;
var roles = member.roles.cache.size - 1;
var roleNames = member.roles.cache.map(r => r).join(" ").replace("@everyone", "");
if(roles == 0) roleNames = "No roles";
var embed = new discord.MessageEmbed()
.setColor("RANDOM")
.setThumbnail(message.author.avatarURL)
.addField(`${user.tag}`, `${user}`, true)
.addField("ID:", `${user.id}`, true)
.addField("Roles:", message.member.roles.cache.some(roles => `${roles}`).join(', '), true)
.addField("Joined The Server On:", `${moment.utc(member.joinedAt).format("dddd, MMMM Do YYYY")}`, true)
.addField("Account Created On:", `${moment.utc(user.createdAt).format("dddd, MMMM Do YYYY")}`, true)
.addField("Roles:", member.roles.map(roles => `${roles}`).join(', '), true)
message.channel.send(embed);
}
};
>Solution :
You get this particular error because the member variable is not defined. If you want your code to work, you can add const member = message.member to the execute function and it should work