client.guilds.find不是一个函数



嗨,所以我得到了一个机器人来处理不和谐,这需要一堆依赖项来帮助它运行。

所以我打电话给他们,结果如下。

最后一件事是调用"永远 -o out.log bot.js"来运行机器人,结果如下。我对这一切仍然很陌生,但似乎它无法调用应该不和谐的函数.js。如果是这样,有人可以解释为什么会这样,特别是如果我在运行机器人之前调用了它。任何帮助将不胜感激。

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.

在 v12 中 client.guilds 是一个 GuildsManager,它曾经是一个集合,但该集合被移至client.guilds.cache

所以总而言之,只需更改client.guilds.find=>client.guilds.cache.find

此外,您还应该标记不和谐.js将来

Client.guilds 返回一个没有函数find的 GuildsManager 。 你到底想做什么?

顺便说一下,依赖项中存在安全漏洞,请按照日志中的说法运行npm audit fix

最新更新