question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Initial Files" code doesn't work

See original GitHub issue

Describe the bug

When following the v13 guide, I get a type error when trying to run

To Reproduce

Follow this guide: https://discordjs.guide/creating-your-bot/

The resulting code doesn’t work

// Require the necessary discord.js classes
const { Client, Intents } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

// When the client is ready, run this code (only once)
client.once('ready', () => {
	console.log('Ready!');
});

// Login to Discord with your client's token
client.login(token);

Screenshots

C:\Users\derek\dev\src\discord-bot\index.js:6
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
                                              ^

TypeError: Cannot read properties of undefined (reading 'FLAGS')
    at Object.<anonymous> (C:\Users\derek\dev\src\discord-bot\index.js:6:47)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Node.js v18.6.0

Device (please complete the following information)

Windows 11, nodejs 18.6.0

Additional notes

If I try adding the Guilds intents on the app page, it requests a callback url, which the code isn’t listening for

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Jiralitecommented, Jul 20, 2022

Yes (via npm tags or altering package.json then installing). Although, you should have received an error stating discord.js does not provide an export named Intents, so this looks suspicious to me.

A note: https://v13.discordjs.guide/ is for browsing the guide in version 13.

0reactions
derekslenkcommented, Jul 20, 2022

Either way, pinning to 13.9.0 fixed it for me. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Eclipse won't compile/run java file - Stack Overflow
Create a new project; Create a class in it; Add erroneous code, let error come; Now go to your project; Go to Problems...
Read more >
unable to associate .txt file with listed Visual Studio Code on ...
The problem is that none of this is working with VS Code. Currently my .txt files are associated with EmEditor. I change the...
Read more >
User and Workspace Settings - Visual Studio Code
You can open the settings.json file with the Preferences: Open Settings (JSON) command in the Command Palette (Ctrl+Shift+P).
Read more >
CC2803X: "C28xx: GEL: Encountered a problem loading file:"
In all seriousness - I think the cause was the original debugger configuration error in CCS. When I turned on the development kit,...
Read more >
Fix problems uploading files on the OneDrive website
Notes: If you have a problem that isn't about uploading, you might find help in these articles: Fix OneDrive sync problems.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found