[英]client.guilds.find is not a function
Hi so I have been provided a bot to work on discord which requires a bunch of dependencies to help it run.嗨,我已经获得了一个在 discord 上工作的机器人,这需要一堆依赖项来帮助它运行。
So I have called on them and had the results below.所以我打电话给他们,结果如下。
The last thing was to call 'forever -o out.log bot.js' to run the bot and again had the result below.最后一件事是调用“forever -o out.log bot.js”来运行机器人并再次得到以下结果。 I am still new to all this but it would seem that its not able to call a function that should be in discord.js.
我对这一切仍然很陌生,但它似乎无法调用应该在 discord.js 中的 function。 if so can someone explain why this is, especially if I have called it before running the bot.
如果是这样,有人可以解释为什么会这样,特别是如果我在运行机器人之前调用了它。 Any help will be gratefully appreciated.
任何帮助将不胜感激。
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Kevins-Air:PDL_Season_4 kev$ npm install discord.io winston --save
npm WARN kev@1.0.0 No description
npm WARN kev@1.0.0 No repository field.
+ winston@3.2.1
+ discord.io@2.5.3
updated 2 packages and audited 305 packages in 5.017s
31 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
Kevins-Air:PDL_Season_4 kev$ npm install discord.js
npm WARN kev@1.0.0 No description
npm WARN kev@1.0.0 No repository field.
+ discord.js@12.2.0
updated 1 package and audited 305 packages in 2.738s
31 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
Kevins-Air:PDL_Season_4 kev$ npm install https://github.com/woor/discord.io/tarball/gateway_v6
npm WARN kev@1.0.0 No description
npm WARN kev@1.0.0 No repository field.
+ discord.io@2.5.3
updated 1 package and audited 305 packages in 2.803s
31 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
Kevins-Air:PDL_Season_4 kev$ npm install googleapis
npm WARN kev@1.0.0 No description
npm WARN kev@1.0.0 No repository field.
+ googleapis@39.2.0
updated 1 package and audited 305 packages in 4.529s
30 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
Kevins-Air:PDL_Season_4 kev$ npm install forever -g
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
/Users/kev/.npm-packages/bin/forever -> /Users/kev/.npm-packages/lib/node_modules/forever/bin/forever
+ forever@3.0.0
updated 1 package in 8.677s
Kevins-Air:PDL_Season_4 kev$ forever -o out.log bot.js
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
Authentication set.
PokeDraftBotBeta running...
Loading Servers...
Loading Server: PDL Season 4
(node:1554) UnhandledPromiseRejectionWarning: TypeError: client.guilds.find is not a function
at /Users/kev/Desktop/PDL_Season_4/bot.js:1204:37
at new Promise (<anonymous>)
at LoadServerObject (/Users/kev/Desktop/PDL_Season_4/bot.js:1201:10)
at InitializeServers (/Users/kev/Desktop/PDL_Season_4/bot.js:1152:27)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:1554) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:1554) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
in v12 client.guilds is a GuildsManager, it used to be a collection but the collection was moved to client.guilds.cache
在 v12 中,client.guilds 是 GuildsManager,它曾经是一个集合,但该集合已移至
client.guilds.cache
So all in all just change client.guilds.find
=> client.guilds.cache.find
所以总而言之,只需更改
client.guilds.find
=> client.guilds.cache.find
Also you should tag discord.js in the future你也应该在未来标记 discord.js
Client.guilds returns a GuildsManager which has no function find
. Client.guilds返回没有 function
find
的GuildsManager 。 What are you exactly trying to do?你到底想做什么?
By the way you have a security vulnerability in your dependencies, run npm audit fix
as it's said in your logs.顺便说一句,您的依赖项中存在安全漏洞,请按照日志中的说明运行
npm audit fix
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.