anon
anon

Reputation:

Discord.js TypeError: Cannot read property 'size' of undefined

So I am trying to make a stats command for my bot but I keep on getting the following error whenever I run the command:

TypeError: Cannot read property 'size' of undefined
    at Object.execute (C:\Users\jack\Bot\commands\stats.js:19:51)
    at module.exports (C:\Users\jack\Bot\events\message.js:44:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Here is the stats command command:

const {  MessageEmbed } = require("discord.js");
const moment = require("moment");
require("moment-duration-format");

module.exports = {
    name: "stats",
    aliases: ["botinfo"],
    description: "Says your input via the bot",
    usage: "<input>",
    execute(message, args, client) {
        const uptime = moment.duration(client.uptime).format("D [days], H [hrs], M [mins], S [secs]")
       
    const statsEmbed = new MessageEmbed()
        .addField('Uptime', uptime)
        .setThumbnail(
            client.user.displayAvatarURL({dynamic: true, size: 512})
            )
        .addField("Memory Usage", `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB`)
        .addField('Users', `${client.users.chache.size}`);

    message.channel.send(statsEmbed)
    }}

Upvotes: 0

Views: 265

Answers (1)

Irian3x3
Irian3x3

Reputation: 56

You typed client.users.chache.size. The correct would be client.users.cache.size.

Your problem:

.addField('Users', `${client.users.chache.size}`);
                                    ^^^

The fix:

.addField('Users', `${client.users.cache.size}`);
                                    ^^

Upvotes: 1

Related Questions