Search code examples
javascriptdiscord.jsbots

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.


Solution

  • You need to add new before Client like this:

    const client = new Client({ intents: GatewayIntentBits.Guilds });