π™†π˜Όπ™‰π™Š
π™†π˜Όπ™‰π™Š
DIAdiscord.js - Imagine an app
Created by π™†π˜Όπ™‰π™Š on 1/7/2024 in #djs-questions
Cannot Read Properties of undefined
I'm using a starting guide for discord.js (discordjs.guide) this is the code it gave me
const { Client, Events, GatewayIntentBits, intents } = import('discord.js');
const { token } = import('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
const { Client, Events, GatewayIntentBits, intents } = import('discord.js');
const { token } = import('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
Error:
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'Guilds')
at <anonymous> (c:\Users\Kano2\Downloads\node\index.mjs:14:57)
at run (internal/modules/esm/module_job:194:25)
--- await ---
at processTicksAndRejections (internal/process/task_queues:95:5)
--- await ---
at runMainESM (internal/modules/run_main:55:21)
at executeUserEntryPoint (internal/modules/run_main:78:5)
at <anonymous> (internal/main/run_main_module:23:47)
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'Guilds')
at <anonymous> (c:\Users\Kano2\Downloads\node\index.mjs:14:57)
at run (internal/modules/esm/module_job:194:25)
--- await ---
at processTicksAndRejections (internal/process/task_queues:95:5)
--- await ---
at runMainESM (internal/modules/run_main:55:21)
at executeUserEntryPoint (internal/modules/run_main:78:5)
at <anonymous> (internal/main/run_main_module:23:47)
12 replies