I've been trying to show my server member count from my bot but I don't know the input to type.
const {MessageEmbed} = require("discord.js")
module.exports.run = async (client, message, args) => {
console.log(message.guild.iconURL())
const messageEmbed = new MessageEmbed()
.setTitle(" Server Information ")
.setThumbnail(message.guild.iconURL())
.addFields(
{name: "Server Name:", value: `\`${message.guild.name}\``, inline: true},
{name: "Server Owner:", value: `${message.guild.owner}`, inline: true},
{name: "Server Created:", value: `${message.guild.createdAt}`},
{name: "Emoji count:", value: `${message.guild.emojis.cache.size}`, inline: true},
{name: "Member count:", value: `${message.guild.members}`, inline: true}
)
.setColor("#FFFF66")
.setFooter("Requested by " message.author.tag)
.setTimestamp()
message.channel.send(messageEmbed)
}
exports.help = {
name: "serverinfo"
}
I have a feeling that ${message.guild.members}
is wrong.
CodePudding user response:
Message
has no members
property. What you need to do is get the Guild
class from Message#guild
and access its memberCount
property.
{name: "Member count:", value: message.guild.memberCount, inline: true}
Note that you should request the GUILDS
and GUILD_MEMBERS
intents when creating your client. For example:
const client = new Discord.Client({
intents: ['GUILDS', 'GUILD_MEMBERS']
});