Discord机器人无法上线。

huangapple go评论53阅读模式
英文:

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 &#39;new&#39;
    at Object.&lt;anonymous&gt; 
    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 });

huangapple
  • 本文由 发表于 2023年5月17日 06:34:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76267484.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定