简体   繁体   English

Discord 机器人在几个小时后停止工作

[英]Discord bot stops working after a few hours

My bot works for 7-8 hours then i get that message.我的机器人工作了 7-8 个小时,然后我收到了这条消息。

at GuildMember.isStaff (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:126:98) at Client.在 GuildMember.isStaff (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:126:98) 在客户端。 (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 (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:56:25) 在 Client.emit (events.js:400:28) 在 VoiceStateUpdate.handle (C:\\Users\\Mert\\ Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\actions\\VoiceStateUpdate.js:40:14) 在 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) 在 WebSocketManager.handlePacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules \\discord.js\\src\\client\\websocket\\WebSocketManager.js:384:31) 在 WebSocketShard.onPacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\ websocket\\WebSocketShard.js:444:22) 在 WebSocketShard.onMessage (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketShard.js:301:10 ) 在 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. s:132:16) 在 WebSocket.emit (events.js:400:28) (使用node --trace-warnings ...显示警告的创建位置)(节点:12296) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。 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().这个错误要么是因为在没有 catch 块的情况下抛出了异步函数,要么是因为拒绝了一个没有用 .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).要在未处理的承诺拒绝时终止节点进程,请使用 CLI 标志--unhandled-rejections=strict (请参阅 https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)。 (rejection id: 1) (node:12296) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. (rejection id: 1) (node:12296) [DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。 In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程。 (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. (node:12296) UnhandledPromiseRejectionWarning: TypeError: 无法在客户端读取 GuildMember.isStaff (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:126:98) 的未定义属性“位置”。 (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 (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:56:25) 在 Client.emit (events.js:400:28) 在 VoiceStateUpdate.handle (C:\\Users\\Mert\\ Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\actions\\VoiceStateUpdate.js:40:14) 在 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) 在 WebSocketManager.handlePacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules \\discord.js\\src\\client\\websocket\\WebSocketManager.js:384:31) 在 WebSocketShard.onPacket (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\ websocket\\WebSocketShard.js:444:22) 在 WebSocketShard.onMessage (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\node_modules\\discord.js\\src\\client\\websocket\\WebSocketShard.js:301:10 ) 在 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. s:132:16) 在 WebSocket.emit (events.js:400:28) (node:12296) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。 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().这个错误要么是因为在没有 catch 块的情况下抛出了异步函数,要么是因为拒绝了一个没有用 .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).要在未处理的承诺拒绝时终止节点进程,请使用 CLI 标志--unhandled-rejections=strict (请参阅 https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)。 (rejection id: 2) (拒绝编号:2)

What should i do ?我该怎么办 ?

You have a few options I'd think:我认为你有几个选择:

  1. Fail the bot with process.exit(-1);使用 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.其中 -1 是错误代码,让 Process Manager 重新启动它,但要确保在启动时设置延迟,这样它就不会陷入崩溃并完全保持离线状态。
  2. Your error is located GuildMember.isStaff (C:\\Users\\Mert\\Desktop\\Tasarım\\Discord Botları\\bot3\\app.js:126:98);你的错误位于 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.您的 isStaff 检查正在抛出您可以包装 try/catch 并安全地使其失败而不会导致程序崩溃。
  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.修复错误,它显然返回 null/undefined 值或只是不可能,因此需要更多的作业并检查 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()"错误消息的底部确实有说明“此错误源于在没有 catch 块的异步函数内部抛出,或拒绝未使用 .catch() 处理的承诺”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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