简体   繁体   中英

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.

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. 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. 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

So all in all just change client.guilds.find => client.guilds.cache.find

Also you should tag discord.js in the future

Client.guilds returns a GuildsManager which has no function find . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM