我的 guild.members.cache.size
没有工作是返回旧的成员计数(用于带有语音频道的membercount),但当我键入 console.log(guild.members.cache.size)
is返回新成员计数(我认为不是缓存)。
我的代码
index.js
const functions = require('./Utils/functions.js')
client.on('guildMemberAdd', (member) => functions.updateMembers(member.guild));
client.on('guildMemberRemove', (member) => functions.updateMembers(member.guild));
functions.js
const { client } = require("../index.js");
exports.updateMembers = (guild) => {
if((client.dbcount.get(guild.id+"m") === false) || (!client.dbcount.has(guild.id+"m"))) {
return;
}
const channel = guild.channels.cache.get(client.dbcount.get(guild.id + "m"+'ch'));
let obj;
if(client.dbcount.has(guild.id + "m" + "obj")) {
obj = client.dbcount.get(guild.id + "m" + "obj");
} else {
obj = "∞";
}
channel.setName('Membres: ' + guild.memberCount + "/" + obj)
console.log(guild.memberCount);
};
1条答案
按热度按时间ykejflvf1#
你可以试试这个。