我试着设置一个间隔,搜索一个Guild等等,但是总是说它不能读取未定义的属性'users‘,我似乎没有发现问题,这是我尝试过的代码
setInterval(function () {
client.guilds.find(g => g.id == '419967722349133825').users.forEach(function (guildMember) {
if (fs.existsSync("Warns for " + guildMember.id)) fs.unlinkSync("Warns for " + guildMember.id)
})
}, 2629800000);错误消息
(node:11504) TimeoutOverflowWarning: 2629800000 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
client.guilds.find(g => g.id == '419967722349133825').users.forEach(function (guildMember) {
^
TypeError: Cannot read property 'users' of undefined发布于 2019-11-28 22:28:08
users字段未定义,因为没有具有匹配id的行会。仔细检查id是你要找的行会的id,并且你的机器人是那个行会的成员。
当通过id从Collection获取一个单行会时,你可以使用get()方法。get()方法是普通Map对象上的一个方法,因为Discord.js的Collection扩展了Map,而该集合中每个行会的键是行会id。
https://stackoverflow.com/questions/59090025
复制相似问题