Reputation: 53
Im making a bot in discord.js v13, and i wanted to return client's number of guilds/users/channels.
But it returns function get() { [native code] }
instead.
const main = new MessageEmbed()
.setColor("#6164ab")
.addField("<:discordReply:971028493645262888> Stats", `• ${client.guilds.cache.get} guilds\n• ${client.users.cache.get} users\n• ${client.channels.cache.get} channels`)
await interaction.reply({ embeds: [main], ephemeral: true })
This is my code. Thanks.
Upvotes: 1
Views: 1405
Reputation: 197
In Discord.JS docs, as i see guilds.cache
is returning a collection and it has properties to get size. So you can basically get size of guilds with;
client.guilds.cache.size // => Returns number
Unfortunately, .get
is method and so it should be .get()
which is returning undefined...
Upvotes: 1
Reputation: 53
The correct property for getting the number of entries turned out to be .size
and not .get
.
Upvotes: 1