#no
1 messages · Page 1 of 1 (latest)
also in your first screenshot, it looks like you're running node from D:/file/files/command handler
is that where index.js is?
And the only output you get is that mongodb started?
yes
const { glob } = require("glob");
const { promisify } = require("util");
const { Client } = require("discord.js");
const mongoose = require("mongoose");
const globPromise = promisify(glob);
/**
* @param {Client} client
*/
module.exports = async (client) => {
const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`);
commandFiles.map((value) => {
const file = require(value);
const splitted = value.split("/");
const directory = splitted[splitted.length - 2];
if (file.name) {
const properties = { directory, ...file };
client.commands.set(file.name, properties);
}
});
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
eventFiles.map((value) => require(value));
const slashCommands = await globPromise(
`${process.cwd()}/SlashCommands/*/*.js`
);
const arrayOfSlashCommands = [];
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
client.slashCommands.set(file.name, file);
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
arrayOfSlashCommands.push(file);
});
client.on("ready", async () => {
await client.guilds.cache
.get("997256998930350231")
.commands.set(arrayOfSlashCommands);
});
const { mongooseConnectionString } = require('../config/config.json')
if (!mongooseConnectionString) return;
mongoose.connect(mongooseConnectionString).then(() => console.log('Connected to mongodb'));
};```
my handler
And it worked before right ?
before I switched from v13 to v14 worked but with a couple of errors now that I'm in v14 nothing just does not load the slashes and sends the ready in console
So there were some breaking changes in v14
if it does not go but now how can I solve?
Comment out your handler in index js and try to run it just to see
Sorry i had to get up so kinda hard to look through
I checked the docs and it all seems imported rightly
Yeah but it's hard to tell exactly what's going on
If you comment out your require handler and it still doesn't work at least we know the problem isn't there
in your handler
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`); eventFiles.map((value) => require(value));
is this working properly
ok
check with a console log or something to make sure its requiring the right files
how do I do it?
after const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
in handler yeah
ok try
changing client.on("ready", async () => { await client.guilds.cache .get("997256998930350231") .commands.set(arrayOfSlashCommands); });
to
ok well there's one issue
sorry I had missed one thing this is what gives
so your event files is empty
ok and how do we do it?
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
aren't your events in an event folder?
er
under this?
anywhere should work but sure
sure
where do I publish it?
just a screenshot in here
is fine
just so I can see your paths
I think they're all fine
whats in your slash command folder
I've been trying to figure it out for hours
i've never used glob
try doing
well first
pretty sure it's an issue with your file mapping
ok
you could try mapping the files like they show
here
I copied all the files and pasted into another folder with the different name could be the cause?
I doubt it but you could try
I would check if your commandFiles is empty too, and
and if it is try replacing it with what fs and what they use on the docs
client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection
// With the key as the command name and the value as the exported module
client.commands.set(command.data.name, command);
}
ok how do we do it?
do I put this?
😱
any ideas
I’m just watching
I have no idea what you guys are doing
I don’t even use a command handler myself 💀
I just shove everything in the index file and use “if” for every command
any chance you have this on github
thus?
the path is going to be a little different
oh actually
its probably fine
for events
for commands you have a sub directory
i think
give me your nik on github that I add to the repo?