I am a new discord coder and i am having problems with this when i type in node . and enter it shows me this

const client = new Dicord.Client();
^

ReferenceError: Dicord is not defined
at Object. (C:\Users\minec\OneDrive\Desktop\DiscordBot\main.js:3:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.12.1

Hi @Liebed and welcome to the community! Can you tell us your project URL?

can someone please help

There’s a typo.

It should be const client = new discord.Client();

Also, be careful with sharing your discord bot token. I recommend resetting the discord bot token and putting the token in .env if the project is public.

now im facing this error

  throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents);
  ^

TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.
at Client._validateOptions (C:\Users\minec\OneDrive\Desktop\DiscordBot\node_modules\discord.js\src\client\Client.js:489:13) at new Client (C:\Users\minec\OneDrive\Desktop\DiscordBot\node_modules\discord.js\src\client\Client.js:78:10)
at Object. (C:\Users\minec\OneDrive\Desktop\DiscordBot\main.js:3:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: ‘ClientMissingIntents’
}

What is the version of discord.js your discord bot is using?


this?

Yeah, it looks like you’re using discord.js 14.7.1.

Since discord.js v13, you need to provide intents for the client.

You can read more about intents here: Gateway Intents | discord.js Guide

I stopped coding discord bots since discord.js v12. This is all that I know.

Ok, I have put together a piece of code.


const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({
	intents: [
		GatewayIntentBits.Guilds,
		GatewayIntentBits.GuildMessages,
		GatewayIntentBits.MessageContent,
		GatewayIntentBits.GuildMembers,
	],
});

client.once('ready', () => {
console.log('Bot is now online');
});

client.login("TOKEN");

For this to work, your discord bot needs to have the following intents enabled in the discord developer dashboard - SERVER MEMBERS INTENT and MESSAGE CONTENT INTENT

To enable intents, go here, Discord Developer Portal and click on the bot that you are working on, click Bot on the left side of the website under OAuth2, and look for the intents under Privileged Gateway Intents and enable those two intents.

If you don’t have those intents enabled, it will throw a Privileged intent provided is not enabled or whitelisted. error message.

1 Like

im getting
ReferenceError: Discord is not defined

here’s my code

const { Client, Gatewayintentbits, Embedbuilder, Permisionsitfield, Permissions } = require(‘Discord.js’);

const prefix = ‘.’;

const client = Discord.Client();({ intents: [Gatewayintentbits.Guilds, Gatewayintentbits.GuildMessages,Gatewayintentbits.MessageContent] });

client.on(“ready”, () => {
console.log(“Liebed is now online!”);

client.user.setActivity(`Liebed is epic`, { type: "WATCHING" });

})

client.login(“token”);

Replace
const client = Discord.Client();({ intents: [Gatewayintentbits.Guilds, Gatewayintentbits.GuildMessages,Gatewayintentbits.MessageContent] });

with

const client = new Client({
  intents: [
    Gatewayintentbits.Guilds,
    Gatewayintentbits.GuildMessages,
    Gatewayintentbits.MessageContent,
  ],
});
1 Like

now im getting this

Gatewayintentbits.Guilds,
^

TypeError: Cannot read properties of undefined (reading ‘Guilds’)
at Object. (C:\Users\minec\OneDrive\Desktop\DiscordBot\main.js:7:25)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Ok

Replace
const { Client, Gatewayintentbits, Embedbuilder, Permisionsitfield, Permissions } = require(‘discord.js’);

with

const { Client, GatewayIntentBits, EmbedBuilder, PermissionsBitField, Permissions } = require("discord.js");

didnt work
same error

Ok. Can I help you remotely to help you fix the code?

friended u again and invited u to the project

My discord is Nicholas#6825 - Can you send a friend request again? I accidentally denied it.

Tip: If it’s not solved, Don’t mark it solved :slight_smile:

Small mistake from the original rewritten code:

Replace Gatewayintentbits to GatewayIntentBits (Case sensitive) and that should fix the issue.