所以我一直只为一台显示服务器状态的服务器创建一个私人机器人,但我有一个问题。每次用户加入/退出公会时,该漫游器都会使用“ undefined”(未定义)更新频道,但这意味着该公会中的成员总数。有人能帮我吗?这是代码段:
const serverStats = {
guildID: '474658204475719701',
totalUsersID: '578114537589309441',
};
client.on('guildMemberAdd', member => {
if (member.guild.id !== serverStats.guildID) return;
client.channels.get(serverStats.totalUsersID).setName(`? MEMBERS COUNT: ${member.guild.membersCount}`);
});
client.on('guildMemberRemove', member => {
if (member.guild.id !== serverStats.guildID) return;
client.channels.get(serverStats.totalUsersID).setName(`? MEMBERS COUNT: ${member.guild.membersCount}`);
});
谢谢。
答案 0 :(得分:0)
答案 1 :(得分:0)
这是我用于server-info命令的内容:
const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
let sicon = message.guild.iconURL;
let serverembed = new Discord.RichEmbed()
.setDescription("Server Information")
.setColor("#ff0000")
.setThumbnail(sicon)
.addField("Server Name", message.guild.name)
.addField("Created On", message.guild.createdAt)
.addField("You Joined", message.member.joinedAt)
.addField("Total Members", message.guild.memberCount)
.addField("Bot Version", "2.4.4")
message.channel.send(serverembed);
}
答案 2 :(得分:0)
我希望你仍然需要他
const embed = new Discord.RichEmbed()
.setDescription(`? MEMBERS COUNT: ${message.guild.members.filter(member => !member.user.bot).size}`)
.setThumbnail(message.guild.iconURL)
client.on('guildMemberAdd', member => {
if (member.guild.id !== serverStats.guildID) return;
client.channels.get(serverStats.totalUsersID).send(embed);
});
client.on('guildMemberRemove', member => {
if (member.guild.id !== serverStats.guildID) return;
client.channels.get(serverStats.totalUsersID).send(embed);
});