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 .*˖
yes Should I restart it?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖
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 .*˖
ok a screen came up, what information is important?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖
no
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖
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
BradyDaLlama .*˖
yes
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖
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
BradyDaLlama .*˖
this?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
that shouldnt be necessary on v14
BradyDaLlama .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
well then that would be that error. dang it
monbrey
monbrey3y ago
It was right before
BradyDaLlama .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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
BradyDaLlama .*˖
where?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey3y ago
This shows "discord": "^0.8.2"
BradyDaLlama .*˖
oh got it
monbrey
monbrey3y ago
No idea what that is Also js?
BradyDaLlama .*˖
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 .*˖
still getting that error
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖
yes
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
BradyDaLlama .*˖
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 .*˖
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 .*˖
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 .*˖
let me finish with the node modules folder and ill get on that
monbrey
monbrey3y ago
Really still just this at this point
BradyDaLlama .*˖
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 .*˖
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 .*˖
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?
BradyDaLlama .*˖
yes
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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 .*˖
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
Want results from more Discord servers?
Add your server