Ready event does not run

import { Listener } from "@sapphire/framework";
import { Client } from "discord.js";

export class ReadyListener extends Listener {
public constructor(
context: Listener.LoaderContext,
options: Listener.Options
) {
super(context, {
...options,
once: true,
event: "ready",
});
}
public run(client: Client) {
const { username, id } = client.user!;
this.container.logger.info(`Successfully logged in as ${username} (${id})`);
}
}
import { Listener } from "@sapphire/framework";
import { Client } from "discord.js";

export class ReadyListener extends Listener {
public constructor(
context: Listener.LoaderContext,
options: Listener.Options
) {
super(context, {
...options,
once: true,
event: "ready",
});
}
public run(client: Client) {
const { username, id } = client.user!;
this.container.logger.info(`Successfully logged in as ${username} (${id})`);
}
}
Solution:
Had to put the event file in Listeners folder
Jump to solution
10 Replies
zeyad
zeyadOP8mo ago
it doesn't log anything
Oreo ™
Oreo ™8mo ago
is the file in the right folder? also instead of using client in there try using container.client
zeyad
zeyadOP8mo ago
should the file be specifically in a folder named listeners?
Oreo ™
Oreo ™8mo ago
yes
Oreo ™
Oreo ™8mo ago
Sapphire Framework
Creating your own listeners | Sapphire
Similar to what you learned in both Creating Commands and [Creating
Oreo ™
Oreo ™8mo ago
or else sapphire wont know where to look
zeyad
zeyadOP8mo ago
okay got it thanks
Solution
zeyad
zeyad8mo ago
Had to put the event file in Listeners folder
Favna
Favna8mo ago
FYI ready is the only event that receives client. https://discord.js.org/docs/packages/discord.js/14.14.1/Client:Class#ready
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Oreo ™
Oreo ™8mo ago
yeah i didnt see any examples on the GitHub using client in there so i was just being safe lol good to know
Want results from more Discord servers?
Add your server