Discord Bot 不可用公会问题
Discord Bot Unavailable Guilds Troubles
我开始为我朋友的服务器创建自己的 Discord 机器人,我一直 运行 遇到同样的问题。
我写了一个简单的东西来让我和机器人进行第一次互动:
client.on("messageCreate", message => {
console.log(message.content);
});
这应该在控制台中写入机器人所连接的不和谐服务器上发送的任何消息的内容(它只连接到我的测试服务器)
我不明白为什么这不起作用,所以我开始寻找它并使用了“调试”事件。
当 运行 node index.js
控制台告诉我:
Booting up...
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 981
[WS => Manager] Spawning shards: 0
[WS => Shard 0] [CONNECT]
Gateway : wss://gateway.discord.gg/
Version : 9
Encoding : json
Compression: none
[WS => Shard 0] Setting a HELLO timeout for 20s.
[WS => Shard 0] [CONNECTED] Took 172ms
[WS => Shard 0] Clearing the HELLO timeout.
[WS => Shard 0] Setting a heartbeat interval for 41250ms.
[WS => Shard 0] [IDENTIFY] Shard 0/1 with intents: 8
[WS => Shard 0] [READY] Session f3fcd33aad118dc188b7b63c3eec3eed.
[WS => Shard 0] [ReadyHeartbeat] Sending a heartbeat.
[WS => Shard 0] Shard will not receive any more guild packets.
Unavailable guild count: 1
Booted !
[WS => Shard 0] Heartbeat acknowledged, latency of 112ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 0] Heartbeat acknowledged, latency of 120ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
然后它一直发送心跳并确认它,直到我停止它。
告诉我有问题的是:
“分片将不再接收任何公会数据包”
“不可用的公会数:1”
这是我的全部 index.js
(只有我的代币在 config.json
):
console.log("Booting up...");
const { Client, Intents } = require("discord.js");
const {spd} = require("./config.json");
const botIntents = 8;
const client = new Client({intents : botIntents});
client.login(spd);
client.once("ready", isBooted);
client.on("messageCreate", message => {
console.log(message.content);
});
client.on("debug", err => {
console.log(err);
});
/////////
function isBooted() {
console.log(" Booted !");
}
系统信息:
Windows 10
NPM 8.0.0
Node v16.11.1
Discord.js 13.2.0
如果您需要更多信息来帮助您,请告诉我。
您使用的唯一 Intent 似乎是 GUILD_EMOJIS_AND_STICKERS
,这是我通过 intents calculator 发现的。您应该显示每个意图,以便您可以轻松修改它:
const { Client, Intents } = require("discord.js")
const client = new Client({intents : [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]});
我开始为我朋友的服务器创建自己的 Discord 机器人,我一直 运行 遇到同样的问题。
我写了一个简单的东西来让我和机器人进行第一次互动:
client.on("messageCreate", message => {
console.log(message.content);
});
这应该在控制台中写入机器人所连接的不和谐服务器上发送的任何消息的内容(它只连接到我的测试服务器)
我不明白为什么这不起作用,所以我开始寻找它并使用了“调试”事件。
当 运行 node index.js
控制台告诉我:
Booting up...
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 981
[WS => Manager] Spawning shards: 0
[WS => Shard 0] [CONNECT]
Gateway : wss://gateway.discord.gg/
Version : 9
Encoding : json
Compression: none
[WS => Shard 0] Setting a HELLO timeout for 20s.
[WS => Shard 0] [CONNECTED] Took 172ms
[WS => Shard 0] Clearing the HELLO timeout.
[WS => Shard 0] Setting a heartbeat interval for 41250ms.
[WS => Shard 0] [IDENTIFY] Shard 0/1 with intents: 8
[WS => Shard 0] [READY] Session f3fcd33aad118dc188b7b63c3eec3eed.
[WS => Shard 0] [ReadyHeartbeat] Sending a heartbeat.
[WS => Shard 0] Shard will not receive any more guild packets.
Unavailable guild count: 1
Booted !
[WS => Shard 0] Heartbeat acknowledged, latency of 112ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 0] Heartbeat acknowledged, latency of 120ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
然后它一直发送心跳并确认它,直到我停止它。
告诉我有问题的是:
“分片将不再接收任何公会数据包”
“不可用的公会数:1”
这是我的全部 index.js
(只有我的代币在 config.json
):
console.log("Booting up...");
const { Client, Intents } = require("discord.js");
const {spd} = require("./config.json");
const botIntents = 8;
const client = new Client({intents : botIntents});
client.login(spd);
client.once("ready", isBooted);
client.on("messageCreate", message => {
console.log(message.content);
});
client.on("debug", err => {
console.log(err);
});
/////////
function isBooted() {
console.log(" Booted !");
}
系统信息:
Windows 10
NPM 8.0.0
Node v16.11.1
Discord.js 13.2.0
如果您需要更多信息来帮助您,请告诉我。
您使用的唯一 Intent 似乎是 GUILD_EMOJIS_AND_STICKERS
,这是我通过 intents calculator 发现的。您应该显示每个意图,以便您可以轻松修改它:
const { Client, Intents } = require("discord.js")
const client = new Client({intents : [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]});