英文:
Discord bot won't come online
问题
I'm having trouble on trying to program the bot from getting online but its not working. Many changes have been made but still no luck.
我在尝试让机器人上线的编程过程中遇到了问题,但它还没有起作用。已经进行了许多更改,但仍然没有运行。
I've tried declaring the client once but that didn't work and I've changed the variable too but nothing.
我尝试过声明客户端一次,但那并没有起作用,我也更改了变量,但没有效果。
Here is the code
这是代码:
const client = Client({ intents: GatewayIntentBits.Guilds });
Here is the code response error
这是代码的错误响应:
TypeError: Class constructor Client cannot be invoked without 'new'
at Object.<anonymous>
at Module._compile (node:internal/modules/cjs/loader:1267:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
at Module.load (node:internal/modules/cjs/loader:1125:32)
at Module._load (node:internal/modules/cjs/loader:965:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Thank you.
谢谢。
英文:
I'm having trouble on trying to program the bot from getting online but its not working. Many changes have been made but still no luck.
I've tried declaring the client once but that didn't work and I've changed the variable too but nothing.
Here is the code
const client = Client({ intents: GatewayIntentBits.Guilds });
Here is the code response error
TypeError: Class constructor Client cannot be invoked without 'new'
at Object.<anonymous>
at Module._compile (node:internal/modules/cjs/loader:1267:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
at Module.load (node:internal/modules/cjs/loader:1125:32)
at Module._load (node:internal/modules/cjs/loader:965:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Thank you.
答案1
得分: 0
你需要在 "Client" 前面加上 "new",就像这样:
const client = new Client({ intents: GatewayIntentBits.Guilds });
英文:
You need to add new before Client like this:
const client = new Client({ intents: GatewayIntentBits.Guilds });
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论