Idk why am i getting this error while running bot for first time

C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules\discord.js\src\client\websocket\handlers\READY.js:17 client.guilds._add(guild); ^ TypeError: client.guilds._add is not a function at module.exports [as READY] (C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules\discord.js\src\client\websocket\handlers\READY.js:17:19) at WebSocketManager.handlePacket (C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules\discord.js\src\client\websocket\WebSocketManager.js:348:31) at WebSocketManager.<anonymous> (C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules\discord.js\src\client\websocket\WebSocketManager.js:232:12) at WebSocketManager.emit (C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31) at WebSocketShard.<anonymous> (C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules@discordjs\ws\dist\index.js:1190:51) at WebSocketShard.emit (C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31) at WebSocketShard.onMessage (C:\Users\Pc\Desktop\Discord.JS Bot Economy\node_modules@discordjs\ws\dist\index.js:1005:14) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Node.js v18.18.2 it seems this error is occuring in READY.js websocked file in discord.js node_module, help?
6 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Zain
ZainOP2mo ago
14.16.3 node is v18.18.2 code:
const {Client, GatewayIntentBits, Collection} = require('discord.js');
const int = GatewayIntentBits;
const bot = new Client({intents:[int.Guilds,int.GuildMessages,int.GuildMembers,int.MessageContent]});
const fs = require('fs')
bot.commands = new Collection();
bot.snipes = new Collection();
bot.guilds = new Collection();
bot.esnipes = new Collection();

const {QuickDB} = require('quick.db');
const db = new QuickDB();

const eventsDir = fs.readdirSync("./events/").filter(c=>c.endsWith(".js"));
for(const eventFile of eventsDir) {
const event = require('./events/'+eventFile);
if(event.once)
bot.once(event.name, (bot, ...args) => event.execute(bot, args));
else bot.on(event.name, (bot,...args) => event.execute(bot, args));
}
let commands = [];
const commandsDir = fs.readdirSync('./commands/');
for(const commandFolders of commandsDir) {
const commandFolder = fs.readdirSync('./commands/'+commandFolders+'/').filter(c=>c.endsWith(".js"));
for(const commandFiles of commandFolder) {
const command = require(`./commands/${commandFolders}/${commandFiles}`);
commands[command.name] = command;
}
}
bot.commands.set('commands', commands);
db.get('bot.commands') ? 0 : (db.set('bot.commands', commands))

bot.db = db;

bot.login(require('./config.js').token)
const {Client, GatewayIntentBits, Collection} = require('discord.js');
const int = GatewayIntentBits;
const bot = new Client({intents:[int.Guilds,int.GuildMessages,int.GuildMembers,int.MessageContent]});
const fs = require('fs')
bot.commands = new Collection();
bot.snipes = new Collection();
bot.guilds = new Collection();
bot.esnipes = new Collection();

const {QuickDB} = require('quick.db');
const db = new QuickDB();

const eventsDir = fs.readdirSync("./events/").filter(c=>c.endsWith(".js"));
for(const eventFile of eventsDir) {
const event = require('./events/'+eventFile);
if(event.once)
bot.once(event.name, (bot, ...args) => event.execute(bot, args));
else bot.on(event.name, (bot,...args) => event.execute(bot, args));
}
let commands = [];
const commandsDir = fs.readdirSync('./commands/');
for(const commandFolders of commandsDir) {
const commandFolder = fs.readdirSync('./commands/'+commandFolders+'/').filter(c=>c.endsWith(".js"));
for(const commandFiles of commandFolder) {
const command = require(`./commands/${commandFolders}/${commandFiles}`);
commands[command.name] = command;
}
}
bot.commands.set('commands', commands);
db.get('bot.commands') ? 0 : (db.set('bot.commands', commands))

bot.db = db;

bot.login(require('./config.js').token)
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Zain
ZainOP2mo ago
ik i didnt use it
NyR
NyR2mo ago
You are overriding <Client>.guilds with a collection, don't do that
Zain
ZainOP2mo ago
ohhh i see m so dumb, i last made a bot in 2023 forgot evevrything works now
Want results from more Discord servers?
Add your server