Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

javascript - Discord.js对于每个用户(Discord.js For each user)

I tried making an Interval and searching for a Guild and so on but it always says that it cannot Read the property 'users' of undefined and I don't seem to find the Problem here is the code I tried(我试着做一个间隔并搜索一个公会,依此类推,但它总是说它无法读取未定义的属性“ 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); Error Message(错误信息) (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   ask by Link translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The users field is undefined because there was no guilds with that matching id.(users字段未定义,因为没有具有该匹配ID的行会。)

Double check that the id is the id of the guild you're after and that your bot is a member of that guild.(仔细检查ID是您所追寻的公会的ID,并且您的机器人是该公会的成员。) When getting a signle guild by id from a Collection , you can use the get() method.(当通过Collection从id获取一个行会时,可以使用get()方法。) The get() method is a method on the vanilla Map object, since Discord.js' Collection extends Map , and the key for each guild in that Collection, is the guild id.(get()方法是香草Map对象上的方法,因为Discord.js的Collection扩展了Map ,并且该Collection中每个公会的键都是公会ID。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...