Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

My userinfo command in discord.js is giving only errors

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading