首页 > 解决方案 > Discord 机器人未运行

问题描述

所以,我正在创建一个不和谐的机器人,昨天它刚刚停止运行。所以我在看这里,有人说要处理错误。有了这个,我试了一下。

bot.on('error', (e) => console.error(e));
bot.on('warning', (e) => console.warn(e));
bot.on('debug', (e) => console.info(e));

现在我明白了

Preparing to connect to the gateway...
[WS => Manager] Fetched Gateway Information
    URL: wss://gateway.discord.gg
    Recommended Shards: 1
[WS => Manager] Session Limit Information
    Total: 1000
    Remaining: 1000
[WS => Manager] Spawning shards: 0
[WS => Shard 0] [CONNECT]
    Gateway    : wss://gateway.discord.gg/
    Version    : 6
    Encoding   : json
    Compression: none
[WS => Shard 0] Setting a HELLO timeout for 20s.
[WS => Shard 0] [CLOSE]
    Event Code: 1006
    Clean     : false
    Reason    : No reason received
[WS => Shard 0] Clearing the HELLO timeout.
[WS => Shard 0] WS State: CLOSED
[WS => Shard 0] Failed to connect to the gateway, requeueing...
[WS => Manager] Shard Queue Size: 1; continuing in 5 seconds...
[WS => Manager] Session Limit Information
    Total: 1000
    Remaining: 1000
[WS => Shard 0] [CONNECT]
    Gateway    : wss://gateway.discord.gg/
    Version    : 6
    Encoding   : json
    Compression: none
[WS => Shard 0] Setting a HELLO timeout for 20s.
[WS => Shard 0] [CLOSE]
    Event Code: 1006
    Clean     : false
    Reason    : No reason received
[WS => Shard 0] Clearing the HELLO timeout.
[WS => Shard 0] WS State: CLOSED
[WS => Shard 0] Failed to connect to the gateway, requeueing...
[WS => Manager] Shard Queue Size: 1; continuing in 5 seconds...

在我的终端中,机器人仍然没有运行。有人能帮我吗?

标签: javascriptdiscord.js

解决方案


我相信您遇到的问题直接列在控制台中。您将碎片设置为 0,或者根本不生成任何碎片。这显示在控制台中:

[WS => Manager] Spawning shards: 0

要解决此问题,我建议您遵循本指南,其中介绍了分片的内容、方式和时间。而且,如果您决定使用指南开始分片,请注意 Discord 推荐的分片数量。您可以在控制台中找到此金额。目前,这似乎是 1,如下所示:

[WS => Manager] Fetched Gateway Information
    URL: wss://gateway.discord.gg
    Recommended Shards: 1

推荐阅读