你需要使用Intents
来运行你的机器人。
如果您正在使用discordjs v14
这是你如何使用Intents
:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages
]
});
自 v14 添加以来GateWayIntentBits
代替Intents
。这是你如何使用Intents
on v13:
const { Client, Intents } = require('discord.js')
const client = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] })
Since GateWayIntentBits
v13 discord 上未添加。你可以看看你的package.json
查看您使用的版本dependencies
"dependencies": {
"discord.js": "^13.6.0", //This will be your version
"dotenv": "^16.0.0",
"fs": "^0.0.1-security",
"mongoose": "^6.4.0",
"ms": "^2.1.3",
"node.js": "^0.0.1-security"
}