#The client.on('ready') event will not work

1 messages · Page 1 of 1 (latest)

rotund dragonBOT
#

@north night to help others find answers, you can mark your question as solved via Right Click Solution Message->Apps->✅ Mark Solution

north night
#

So, basically what happened, it does not log anything in the welcome event.

hearty egret
north night
#

Ok!

#

heh

#

here is the client.on('ready') part

hearty egret
#

Use pastebin

north night
#

ah

#

k

hearty egret
#

because for mobile users (like me) I have to download the file to view it

north night
#

here

hearty egret
#

Line 9 won't work

north night
#

Lemme see what that is

#

why

hearty egret
#

Because your client isn't logged in by that time

north night
#

so

#

what do I do?

#

Put the client.login(TOKEN) at the very top?

#

(on line 3)

hearty egret
#

no

#

use where you need it

#

for example if you need it in a message command then declare it inside the messageCreate event

#

and do you see any error in console? Because the code seems fine

north night
#

Its just empty

hearty egret
#

weird

north night
#

yeah

#

idk what to do

north night
#

My ascii table isn't showing up either.

#

OH

#

I fINALLY GOT AN ERROR

#
/Users/ahmed/Desktop/Arkansas-Utilities/Handlers/Events.js:10
    (await PG(`${process.cwd()}/Events/*/*.js`)).map(async (file) => {
    ^

TypeError: (intermediate value) is not a function
    at module.exports (/Users/ahmed/Desktop/Arkansas-Utilities/Handlers/Events.js:10:5)
#

the code is

#
const { Events } = require("../Validation/EventNames")
const { promisify } = require('util')
const { glob } = require('glob')
const PG = promisify(glob)
const Ascii = require('ascii-table')

module.exports = async (client) => {
    const Table = new Ascii("Events Loaded")

    (await PG(`${process.cwd()}/Events/*/*.js`)).map(async (file) => {
        const event = require(file)

        if (!Events.includes(event.name) || !event.name) {
            const L = file.split("/")
            await Table.addRow(`${event.name || "MISSING"}`, `⛔️ Event name is either invalid or missing: ${L[6] + "/" + L[7]}`)
            return
        }

        if (event.once) {
            client.once(event.name, (...args) => event.execute(...args, client))
        } else {
            client.on(event.name, (...args) => event.execute(...args, client))
        }

        await Table.addRow(event.name, "✅ SUCCESSFUL")
    })

    console.log(Table.toString())
}
#

idk what it means tho

civic leaf
#

have you uh considered using sapphire instead of making your own command/event handler? just a thought

north night
#

Nope

#

Idk how to use it

#

heh

north night
#

ok

#

So

#

I just switched my entire code to discord.js@14

civic leaf
#

you're literally in the Sapphire server buddy

north night
#

i am?