[英]Why doesn't my discord bot get online when I type node main.js in command promp?
This is my package.json
file:这是我的
package.json
文件:
{
"name": "bot",
"version": "1.0.0",
"description": "My discord Bot",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Undefined Human",
"license": "ISC",
"dependencies": {
"discord.js": "^14.3.0"
}
}
Here is the main.js
file:这是
main.js
文件:
const Discord = require('discord.js');
const client = new Discord.Client({
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MESSAGES
]
});
client.once('ready', () => {
console.log('GhxstedCloudz is online');
});
client.login('my bot token');
and here is the error I get when I type node.
这是我输入
node.
or node main.js
in the terminal:或终端中的
node main.js
:
C:\Users\Administrator\Desktop\bot\main.js:5
Discord.Intents.FLAGS.GUILDS,
^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
at Object.<anonymous> (C:\Users\Administrator\Desktop\bot\main.js:5:25)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
There is no more Discord.Intents.FLAGS
thing Now typings are different and in v14 we need to use this没有更多的
Discord.Intents.FLAGS
东西现在类型不同了,在 v14 中我们需要使用它
const { Client, GatewayIntentBits } = require('discord.js')
const client = new Client({
intents: [
GatewayIntentBits.Guilds //etc.
])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.