#no

1 messages · Page 1 of 1 (latest)

manic remnant
#

alright can you show your index.js

gentle cosmos
manic remnant
#

also in your first screenshot, it looks like you're running node from D:/file/files/command handler

#

is that where index.js is?

gentle cosmos
#

yes

#

D:\File\Files\Command Handler

#

directory

#

@manic remnant

manic remnant
#

And the only output you get is that mongodb started?

gentle cosmos
#

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

manic remnant
#

And it worked before right ?

gentle cosmos
#

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

manic remnant
#

So there were some breaking changes in v14

gentle cosmos
#

if it does not go but now how can I solve?

manic remnant
#

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

gentle cosmos
#

I checked the docs and it all seems imported rightly

manic remnant
#

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

gentle cosmos
#

I put a ready in my index and now goes

#

@manic remnant

manic remnant
#

in your handler

#

const eventFiles = await globPromise(`${process.cwd()}/events/*.js`); eventFiles.map((value) => require(value));

#

is this working properly

gentle cosmos
#

ok

manic remnant
#

check with a console log or something to make sure its requiring the right files

manic remnant
#

before eventFiles.map

#

console.log(eventFiles)

gentle cosmos
#

handler?

manic remnant
#

after const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);

#

in handler yeah

gentle cosmos
#

ok

manic remnant
#

ok try

#

changing client.on("ready", async () => { await client.guilds.cache .get("997256998930350231") .commands.set(arrayOfSlashCommands); });

#

to

gentle cosmos
manic remnant
#

ok well there's one issue

gentle cosmos
#

sorry I had missed one thing this is what gives

manic remnant
#

so your event files is empty

gentle cosmos
#

ok and how do we do it?

manic remnant
#

const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);

#

aren't your events in an event folder?

#

er

gentle cosmos
manic remnant
#

yeah

#

console log process.cwd()

manic remnant
#

anywhere should work but sure

gentle cosmos
#

thus?

manic remnant
#

sure

gentle cosmos
#

second

manic remnant
#

hmm

#

can you post your project tree again

#

like the folders

gentle cosmos
#

where do I publish it?

manic remnant
#

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

gentle cosmos
manic remnant
#

i found your original

#

its all good

#

but yeah whats in slash commands

gentle cosmos
manic remnant
#

ok

#

trying to figure out whats happening

#

a little weird

gentle cosmos
#

I've been trying to figure it out for hours

manic remnant
#

i've never used glob

#

try doing

#

well first

#

pretty sure it's an issue with your file mapping

gentle cosmos
#

ok

manic remnant
#

you could try mapping the files like they show

#

here

gentle cosmos
#

I copied all the files and pasted into another folder with the different name could be the cause?

manic remnant
#

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);
}
gentle cosmos
manic remnant
#

i'd try changing how you set your command files

#

/ event files

#

first

gentle cosmos
#

ok how do we do it?

manic remnant
#

yeah not exactly like that

#

but

lavish crater
#

😱

manic remnant
lavish crater
#

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

manic remnant
#

Yeah his setup is quite different than anything ive done

#

haha

manic remnant
gentle cosmos
manic remnant
#

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

gentle cosmos
#

give me your nik on github that I add to the repo?