简体   繁体   中英

Discord bot stops working after a few hours

My bot works for 7-8 hours then i get that message.

at GuildMember.isStaff (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:126:98) at Client. (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:56:25) at Client.emit (events.js:400:28) at VoiceStateUpdate.handle (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\actions\\VoiceStateUpdate.js:40:14) at Object.module.exports [as VOICE_STATE_UPDATE] (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\handlers\\VOICE_STATE_UPDATE.js:4:35) at WebSocketManager.handlePacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketManager.js:384:31) at WebSocketShard.onPacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketShard.js:444:22) at WebSocketShard.onMessage (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketShard.js:301:10) at WebSocket.onMessage (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\ws\\lib\\event-target.j s:132:16) at WebSocket.emit (events.js:400:28) (Use node --trace-warnings ... to show where the warning was created) (node:12296) 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: 1) (node:12296) [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. (node:12296) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'position' of undefined at GuildMember.isStaff (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:126:98) at Client. (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:56:25) at Client.emit (events.js:400:28) at VoiceStateUpdate.handle (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\actions\\VoiceStateUpdate.js:40:14) at Object.module.exports [as VOICE_STATE_UPDATE] (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\handlers\\VOICE_STATE_UPDATE.js:4:35) at WebSocketManager.handlePacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketManager.js:384:31) at WebSocketShard.onPacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketShard.js:444:22) at WebSocketShard.onMessage (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketShard.js:301:10) at WebSocket.onMessage (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\ws\\lib\\event-target.j s:132:16) at WebSocket.emit (events.js:400:28) (node:12296) 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)

What should i do ?

You have a few options I'd think:

  1. Fail the bot with process.exit(-1); where -1 is the error code and have Process Manager restart it but ensure you set a delay on startup so it doesn't get stuck in a crash and completely stay offline.
  2. Your error is located GuildMember.isStaff (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:126:98); Your isStaff check is throwing you can wrap a try/catch and fail it safely without crashing program.
  3. Fix the error, it's obviously returning null/undefined the value or just not possible so more homework necessary and examination of the code at the lines above in app.js.

You need to handle promise rejections accordingly or at least handle them in some way. The error message does have instructions at the bottom "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()"

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