#help me please

1 messages · Page 1 of 1 (latest)

silent crow
#

You might've hit circular dependency

dull bane
#

so how should I do it?

silent crow
#

No one can tell you exactly without seeing your code

#

Check your import order

dull bane
#
const Command = require("../structure/Command");
const { Client, Message } = require("discord.js");

class Ping extends Command {
    constructor() {
        super({
            name: "ping",
            description: "Permet de connaître les informations réseaux du bot"
        })
    }

    /**
     * @param {Client} client
     * @param {Message} message
     * @param {string[]} args
    */

    async execute(client, message, args) {
        message.channel.sendTyping();
        
        await message.channel.send(`${emojis.mysaki_loading} Chargement en cours...`).then((result) => {
            let latency = result.createdTimestamp - message.createdTimestamp;

            const pingEmbed = new MessageEmbed()
            .setColor("RED")
            .setTitle(`${emojis.mysaki_information} Information réseau du bot`)
            .addField(`${emojis.mysaki_ping} Ping du bot : `, `${this.ws.ping}ms`)
            .addField(`${emojis.mysaki_latency} Latence de l'API de Discord : `, `${latency}ms`)

            result.edit({ embeds: [pingEmbed], content: " " });
        })
    }
}

module.exports = Ping;
#

my code

#

@silent crow

silent crow
#

If that's the code with the problem, then Command is undefined

#

Because first line doesn't work, due circular dependency

#

It's a JS related issue

dull bane
#

and then I do how to settle it?

silent crow
#

Do you even know what circular dependency is?

dull bane
#

no

silent crow
#

Then search on Google, because there's lot to explain, and it may require you make lots of code changes

dull bane
#

even searching on the internet I can't solve the problem

silent crow
#

Because it is a type of problems, you have to understand it

#

1 min of read is nowhere near

dull bane
#

I had just forgotten to module.exports I am too stupid error of innatention X)

silent crow
#

You're lucky it had nothing to do with circular dependency

dull bane
#

it doesn't work
I'm trying to switch to ES Module