throw err; ^Error: Cannot find module '../commands/fun/avatar.js'Require stack:

Main.js File
const { Client, Intents, Collection } = require('discord.js');

const Discord = require("discord.js")
const db = require('quick.db')
const bot = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] })
const { token } = require('./config.json');
const hostedBy = (true)
const config = require('./config.json');
bot.config = config;
const prefix = "."

const { readdirSync } = require("fs");
const ascii = require("ascii-table");
const table = new ascii("Commands");
table.setHeading("File Name", "Load Status");

const fs = require("fs");

bot.commands = new Discord.Collection();

const commands = fs.readdirSync("./commands/").filter(file => file.endsWith(".js"))
for(file of commands) {
const commandName = file.split(".")[0]
const command = require(`./commands/${commandName}`)
client.commands.set(commandName, command)
}

bot.on("messageCreate", message => {
if(message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/g)
const commandName = args.shift()
const command = client.commands.get(commandName)
if(!command) return
command.run(client, message, args)
}
})

bot.aliases = new Discord.Collection();



const { GiveawaysManager } = require('discord-giveaways');

bot.giveawaysManager = new GiveawaysManager(bot, {
storage: "./giveaways.json",
updateCountdownEvery: 5000,
default: {
botsCanWin: false,
exemptPermissions: [],
embedColor: "#FF0000",
reaction: "šŸŽ‰"
}
});



bot.on("guildMemberAdd", (member) => {

let msg = db.get(`welmessage_${member.guild.id}`)
if (!msg) msg = "We are very happy to have you in our server"
const { Client, Intents, Collection } = require('discord.js');

const Discord = require("discord.js")
const db = require('quick.db')
const bot = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] })
const { token } = require('./config.json');
const hostedBy = (true)
const config = require('./config.json');
bot.config = config;
const prefix = "."

const { readdirSync } = require("fs");
const ascii = require("ascii-table");
const table = new ascii("Commands");
table.setHeading("File Name", "Load Status");

const fs = require("fs");

bot.commands = new Discord.Collection();

const commands = fs.readdirSync("./commands/").filter(file => file.endsWith(".js"))
for(file of commands) {
const commandName = file.split(".")[0]
const command = require(`./commands/${commandName}`)
client.commands.set(commandName, command)
}

bot.on("messageCreate", message => {
if(message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/g)
const commandName = args.shift()
const command = client.commands.get(commandName)
if(!command) return
command.run(client, message, args)
}
})

bot.aliases = new Discord.Collection();



const { GiveawaysManager } = require('discord-giveaways');

bot.giveawaysManager = new GiveawaysManager(bot, {
storage: "./giveaways.json",
updateCountdownEvery: 5000,
default: {
botsCanWin: false,
exemptPermissions: [],
embedColor: "#FF0000",
reaction: "šŸŽ‰"
}
});



bot.on("guildMemberAdd", (member) => {

let msg = db.get(`welmessage_${member.guild.id}`)
if (!msg) msg = "We are very happy to have you in our server"
11 Replies
d.js toolkit
d.js toolkitā€¢12mo ago
ā€¢ What's your exact discord.js npm list discord.js and node node -v version? ā€¢ Post the full error stack trace, not just the top part! ā€¢ Show your code! ā€¢ Explain what exactly your issue is. ā€¢ Not a discord.js issue? Check out #useful-servers.
Kevin
Kevinā€¢12mo ago
let chx = db.get(`welchannel_${member.guild.id}`);

if (chx === null) {
return;
}

let wembed = new Discord.MessageEmbed()
.setAuthor(member.user.username, member.user.avatarURL())
.setColor('RANDOM')
.setThumbnail(member.user.avatarURL())
.setDescription(`${msg}`)
.setTimestamp()
.setFooter(`ID: ${member.user.id}`);


bot.channels.cache.get(chx).send(wembed)

})




bot.once('ready', () => {
readdirSync("./commands/").map((dir) => {
// Get all the sub folders
// eslint-disable-next-line no-unused-vars
const commands = readdirSync(`./commands/${dir}/`).map((cmd) => {
// Get the command
const pull = require(`../commands/${dir}/${cmd}`);
// Add the command to bot.commands
bot.commands.set(pull.name, pull);
table.addRow(cmd, "āœ“");
// Load the aliases and add it to bot.aliases
if (pull.aliases && Array.isArray(pull.aliases)) {
pull.aliases.forEach((alias) =>
bot.aliases.set(alias, pull.name),
);
}
});
});
console.log(table.toString());

console.log('Ready!');
bot.user.setActivity(`.help | discord.gg/knrqhnD`);
});

bot.login(token);
let chx = db.get(`welchannel_${member.guild.id}`);

if (chx === null) {
return;
}

let wembed = new Discord.MessageEmbed()
.setAuthor(member.user.username, member.user.avatarURL())
.setColor('RANDOM')
.setThumbnail(member.user.avatarURL())
.setDescription(`${msg}`)
.setTimestamp()
.setFooter(`ID: ${member.user.id}`);


bot.channels.cache.get(chx).send(wembed)

})




bot.once('ready', () => {
readdirSync("./commands/").map((dir) => {
// Get all the sub folders
// eslint-disable-next-line no-unused-vars
const commands = readdirSync(`./commands/${dir}/`).map((cmd) => {
// Get the command
const pull = require(`../commands/${dir}/${cmd}`);
// Add the command to bot.commands
bot.commands.set(pull.name, pull);
table.addRow(cmd, "āœ“");
// Load the aliases and add it to bot.aliases
if (pull.aliases && Array.isArray(pull.aliases)) {
pull.aliases.forEach((alias) =>
bot.aliases.set(alias, pull.name),
);
}
});
});
console.log(table.toString());

console.log('Ready!');
bot.user.setActivity(`.help | discord.gg/knrqhnD`);
});

bot.login(token);
Issue is
throw err;
^

Error: Cannot find module '../commands/fun/avatar.js'
Require stack:
throw err;
^

Error: Cannot find module '../commands/fun/avatar.js'
Require stack:
treble/luna
treble/lunaā€¢12mo ago
fix your path not djs related either
Kevin
Kevinā€¢12mo ago
wdym oh is it cause
treble/luna
treble/lunaā€¢12mo ago
you provided an invalid path to the file
Kevin
Kevinā€¢12mo ago
it goes through fun then avatar which line
treble/luna
treble/lunaā€¢12mo ago
i dont know you tell me all i'm saying is that 1) this isnt djs related and 2) you provided an invalid filepath just note that there is a huge difference between ../ and ./
Kevin
Kevinā€¢12mo ago
oh thanks its fixed that now now im missing client intents šŸ„²
treble/luna
treble/lunaā€¢12mo ago
then add / enable them
Kevin
Kevinā€¢12mo ago
intents are so confusing just messes with me mind const client = new Discord.Client(); this is the line causing it isnt there like a website showing all the intents i forgot wht the website was
d.js docs
d.js docsā€¢12mo ago
guide Popular Topics: Gateway Intents read more