GatewayIntentBits.Guilds - Cannot read properties of undefined (reading 'Guilds')

here is exactly everything. I'm following the docs so idk what's wrong. Version and full error images attached.
const fs = require('fs');
require("dotenv").config();

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

const Topgg = require("@top-gg/sdk"); //topgg stuff
const express = require("express");
const userVote = require("./User functions/userVote");

const app = express()

const webhook = new Topgg.Webhook("LlamaLoot6543");

app.post("/dblwebhook", webhook.listener(vote => {
userVote(vote);
}))

console.log("app listening");
app.listen(80); //topgg stuff

global.client = new Client({ // **** client is here *****
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers
],
partials: [Partials.Channel]
});


const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

const commands = [];

client.commands = new Collection();

//command register
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
client.commands.set(command.data.name, command);
}

//event register
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, commands));
} else {
client.on(event.name, (...args) => event.execute(...args, commands));
}
}

client.login(token);
const fs = require('fs');
require("dotenv").config();

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

const Topgg = require("@top-gg/sdk"); //topgg stuff
const express = require("express");
const userVote = require("./User functions/userVote");

const app = express()

const webhook = new Topgg.Webhook("LlamaLoot6543");

app.post("/dblwebhook", webhook.listener(vote => {
userVote(vote);
}))

console.log("app listening");
app.listen(80); //topgg stuff

global.client = new Client({ // **** client is here *****
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers
],
partials: [Partials.Channel]
});


const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

const commands = [];

client.commands = new Collection();

//command register
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
client.commands.set(command.data.name, command);
}

//event register
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, commands));
} else {
client.on(event.name, (...args) => event.execute(...args, commands));
}
}

client.login(token);
105 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
yes Should I restart it?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
ok uh where on the line? sorry ive never used that
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
ok a screen came up, what information is important?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
GatewayIntentBits is not underlined. Only the word require is. I thought that's what it was when i hover it it only says import gatewayintentbits
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
wait the import doesn't underline it, just the client when I define it. I'm sorry Nothing in the const {} = require("discord.js") underlines with the ctrl key + hover
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
that shouldnt be necessary on v14
BradyDaLlama .*˖ pings are ok
i think discord js hates me
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
Whats line 51 of llama.js Thats where it appears to be coming from
BradyDaLlama .*˖ pings are ok
GatewayIntentBits.GuildMembers ima just get rid of that rq
monbrey
monbrey3y ago
Is that the file you showed earlier? It didnt look like intents were 51 lines deep
BradyDaLlama .*˖ pings are ok
it's in the file, should be Oh I have some comments for myself i took them out to make it a bit shorter
monbrey
monbrey3y ago
np
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
ok if I import them all separately I get a different error
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
const GatewayIntentBits = require('discord.js');
const Client = require('discord.js');
const Partials = require('discord.js');
const GatewayIntentBits = require('discord.js');
const Client = require('discord.js');
const Partials = require('discord.js');
I tried it like this
monbrey
monbrey3y ago
thats definitely completely wrong
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
You cant require discord.js as three different things You're not destructuring anymore
BradyDaLlama .*˖ pings are ok
well then that would be that error. dang it
monbrey
monbrey3y ago
It was right before
BradyDaLlama .*˖ pings are ok
Yeah I got it from the docs, I was just trying it (I changed it back)
monbrey
monbrey3y ago
Thonk actually can you try npm ls discord-api-types You should get 0.36.2 nested under discord.js in a few places
BradyDaLlama .*˖ pings are ok
dunno what all this is but side note I've uninstalled builders as per the docs npm uninstall @discordjs/builders
monbrey
monbrey3y ago
that all looks correct The top level install isnt necessary but wouldnt break anything
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
If you right click the import and click Go To Definition does that work?
BradyDaLlama .*˖ pings are ok
no definition found for Gateway intent bits that seems... problematic
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
At this point
BradyDaLlama .*˖ pings are ok
so that's the problem, but why doesn't it is the answer?
monbrey
monbrey3y ago
Uninstall and reinstall discord.js and restart VSC lol
BradyDaLlama .*˖ pings are ok
I've done that a few times but I will again in that order
monbrey
monbrey3y ago
Actually wait Uninstall whatever that discord module is
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
I dont see where thats being used
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
This shows "discord": "^0.8.2"
BradyDaLlama .*˖ pings are ok
oh got it
monbrey
monbrey3y ago
No idea what that is Also js?
BradyDaLlama .*˖ pings are ok
tbh... me either
monbrey
monbrey3y ago
Seems like you accidentally did npm i discord js at some point Remove those, give VSC a restart and let me know
BradyDaLlama .*˖ pings are ok
still getting that error
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
install all my packages again you mean? Like npm i cron, discord.js, mongodb all that just so I don't do something catastrophic
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
ok it's asking if I want to permanently delete the folders and files. This seems important so I want to be sure. Delete them?
monbrey
monbrey3y ago
if its just node_modules yes You can safely delete that and reinstall
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
ok yup that's what I had
monbrey
monbrey3y ago
If that still doesnt work, please give me ALL the code and I'll take a look, see if I can replicate the error Actually wait wait The error path shows /root/discord/llama.js But here this looks like you're not in the discord folder I think that shouldnt matter but its still a bit weird
BradyDaLlama .*˖ pings are ok
let me finish with the node modules folder and ill get on that
monbrey
monbrey3y ago
Really still just this at this point
BradyDaLlama .*˖ pings are ok
its just taking a while to delete, ok now lets try
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
After npm i................ same error. by full code what do you mean? Everything else in that file is a comment
monbrey
monbrey3y ago
yeah, but removing them messes up line numbers so its harder for me to diagnose
BradyDaLlama .*˖ pings are ok
ah sorry. I can get that but also the node Modules folder didn't reappear does it just take a bit?
monbrey
monbrey3y ago
When you ran npm i?
monbrey
monbrey3y ago
Yeah this makes me extra sure you've been running commands in the wrong directory
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
the node modules folder was not in the discord folder just for info ty for helping mittel I really appreciate it. Have a good night!
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
hopefully. I won a bid for an ad on top gg and already paid...
monbrey
monbrey3y ago
Yeah that seems like the problem then
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
They were installed at the wrong level
BradyDaLlama .*˖ pings are ok
Should I do that again the correct place? Where would that be
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
cd discord npm i
BradyDaLlama .*˖ pings are ok
The node modules folder did appear but I can't tell if there was always one in discord. There was one in root which is what I thought was the only one
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
regardless of that sorry to be a wet blanket or whatever but... the error persists
monbrey
monbrey3y ago
I would have thought it belongs in discord but I really have no idea what your project structure is anymore
BradyDaLlama .*˖ pings are ok
Let me try some things. I think I see whats wrong
monbrey
monbrey3y ago
I'd need a screenshot of your folder structure in VSC, and all the code of llama.js
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖ pings are ok
Ok I fixed it. I believe a while ago I forgot to cd into discord and created a node modules folder. Today I installed v14 to that, not the one in discord. I updated discordjs while cd into discord and the error went away, I just have to update all the other v 14 stuff
monbrey
monbrey3y ago
Those thick yellow lines are hiding things lol Okay cool, great Glad we got there
BradyDaLlama .*˖ pings are ok
Basically I was really stupid. I'm super sorry for wasting ur time but thank you so much for helping and walking me through it(both of you)
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
so that is inside the discord folder Yeah thanks, looks right that you should be working in there
BradyDaLlama .*˖ pings are ok
Yeah I just updated the discord folder one. instead of outside that
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
Very hard to spot tiny issues like that in error stacks etc
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?