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
zeyadOP2y ago
it doesn't log anything
Oreo ™
Oreo ™2y ago
is the file in the right folder? also instead of using client in there try using container.client
zeyad
zeyadOP2y ago
should the file be specifically in a folder named listeners?
Oreo ™
Oreo ™2y ago
yes
Oreo ™
Oreo ™2y ago
Sapphire Framework
Creating your own listeners | Sapphire
Similar to what you learned in both Creating Commands and [Creating
Oreo ™
Oreo ™2y ago
or else sapphire wont know where to look
zeyad
zeyadOP2y ago
okay got it thanks
Solution
zeyad
zeyad2y ago
Had to put the event file in Listeners folder
Favna
Favna2y 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 ™2y ago
yeah i didnt see any examples on the GitHub using client in there so i was just being safe lol good to know

Did you find this page helpful?