1
votes

Alright, this may look like a copy and paste but it is NOT. I need more support. I'm trying to make my bot do more. I should've added it to the first question but I don't think it'll get viewed. Here's what I'm trying to add.

  • Say when user joined guild at what time and date
  • Tag user in userinfo.tag function
  • List user's nickname

I've tried using the .guildmember class but it just won't work, I'm attaching userMention to the .guildmember class, like this : userMention.guildmember.joinedAt or displayName. Most of my results when modifying my code were either TypeErrors from the bot or ReferenceErrors.

I did use other's code, and I installed Moment, so I could run it with another person's code, but again it gave out an error.

TypeError: Cannot read property 'filter' of undefined

I wasn't able to get the Moment code.

var commando = require('discord.js-commando');
var discord = require('discord.js');

class aboutuser extends commando.Command 
{
    constructor(client) {
        super(client, {
            name: 'aboutuser',
            group: 'help',
            memberName: 'aboutuser',
            description: 'Lists information about a specific user.',
            aliases: ['au', 'aboutu', 'auser', 'user'],
        })
    }
async run(message, args){
    const userMention = message.mentions.users.first() || message.author;

    let userinfo = {};
    userinfo.bot = userMention.bot;
    userinfo.createdat = userMention.createdAt;
    userinfo.joinedat = userMention.message.guildmember.joinedat;
    userinfo.discrim = userMention.discriminator;
    userinfo.id = userMention.id;
    userinfo.tag = userMention.tag;
    userinfo.uname = userMention.username;
    userinfo.status = userMention.presence.status;
    userinfo.play = userMention.presence.game; 

    userinfo.avatar = userMention.avatarURL;

    const rolesOfTheMember = userMention.roles.filter(r => r.name !== '@everyone').map(role => role.name).join(', ')

    var myInfo = new discord.RichEmbed()
        .setAuthor(userinfo.uname, userinfo.avatar)
        .addField("Username",userinfo.uname, true)
        .addField("Client Tag",userinfo.tag, true)
        .addField("Created At",userinfo.createdat, true)
        .addField("Joined at:",userinfo.joinedat, true)
        .addField("Discriminator",userinfo.discrim, true)
        .addField("Client ID",userinfo.id, true)
        .addField("Bot?",userinfo.bot, true)
        .addField("Status",userinfo.status, true)
        .addField("Playing",userinfo.play, true)
        .addField("Roles",rolesOfTheMember, true)
        .setColor(0xf0e5da)
        .setFooter('s!aboutserver')
        .setTitle("About this user...")
        .setThumbnail(userinfo.avatar)


        message.channel.sendEmbed(myInfo);

}

}
module.exports = aboutuser;

Expect: A bot that lists all shown in the code, plus the bullets.

Actual: A bot that only shows Type and Reference Errors. It's things like

TypeError: Cannot read property 'guildmember' of undefined
TypeError: Cannot read property 'filter' of undefined
ReferenceError: guildmember is not defined
ReferenceError: user is not defined

I'm using these sites for reference

https://discord.js.org/#/docs/main/stable/general/welcome

How to show roles of user discord.js / userinfo command *Specifically this line!

.addField('Joined at:', `${moment.utc(user.joinedAt).format('dddd, MMMM Do YYYY, HH:mm:ss')}`, true)

https://www.youtube.com/watch?v=W2iI32FDYW8

2

2 Answers

1
votes

Use

var umen = message.mentions.members.first() || message.member;
var umen2 = message.mentions.users.first() || message.author;

Also had trouble with "Booleans" and those should NOT be === "false" as they are Booleans, not strings. Do === false or === true

0
votes

Try using userMention = message.mentions.members.first(); I think its what's causing the issue