"discord.client is not a constructor"

So I am trying to make a discord bot, which would be the first bot I made. However, I keep getting an error saying “discord.client is not a constructor”. Here is my code and the error
My code for my Passport Bot
const Discord = require(‘discord.js’);

const client = new Discord.client();

client.once('ready',()=> {

    console.log('Passport bot is passporting')

});

client.login('AuthToken');

The Error I get when I use the “node .” or “node main.js” commands
const client = new Discord.client();
^

TypeError: Discord.client is not a constructor
    at Object.<anonymous> (C:\Users\Owner\Desktop\DiscordBot\main.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Any and all help would be greatly appreciated! Thank you!

1 Like

There’s a snippet of code from discord.js’s website that says:

const Discord = require('discord.js');
const client = new Discord.Client();

And you’ve shown your code to say:

const Discord = require('discord.js');

const client = new Discord.client();

That difference in the capitalization of .Client is subtle, but significant in JavaScript. Property names are case sensitive.

Because of that, Discord.client and Discord.Client refer to two different values. The .Client is indeed a constructor, as documented. The .client, as far as I know, isn’t even defined. If that’s true, then accessing it returns the special undefined value, which isn’t a constructor.

4 Likes

Thats coding for you, even a single upcase letter can get you an error.

2 Likes

Ah yes. A single letter my favorite.
Thanks though!

I made an account just to thank you, you are such a hero and thank you so much haha. I spent around, say, 20-30 minutes rewriting the code to see if that would fix anything, and ended up remaking the entire bot about 3 times. Still, every time I failed. I can’t thank you enough!

2 Likes

Hi. Me too I have a problem. I debutant.
I have the same error but I don’t see where I fail

const Discord = require(‘discord.js’);

Client.log(‘token removed’);

const client = new Discord.Client();

Client.once(‘ready’,() => {

console.log('Ready !');

});

Client.on(‘message’, (message) => {

if (message.content === ‘!ping’) {

  message.channel.send('Pong.');

}

});

And the error message

TypeError: Discord.client is not a constructor
at Object. (C:\Users\User\Documents\Quentinbot\index.js:3:16)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47

Um. I don’t recommend leaking your token.

Hi @Quentin_Gales
You need to change Client.log to Client.login and put that login line below the new client line. I have also flagged your post due to the fact you leaked your token. I recommend you refresh the token via the Discord Application Portal
Hope this helps :slight_smile:

2 Likes

I believe @tasha just removed the token, but for the future, don’t share tokens :slight_smile:

I actually reset it for him just in case.