Skip to content

Commit 9989f08

Browse files
author
Sorra
committed
SB-0MNV1PCOQ000KUY0: Replace deprecated 'ready' event with 'clientReady' for discord.js v15
- Replaced this.client.once('ready', ...) with this.client.once('clientReady', ...) - Added startupDone flag to ensure idempotent startup (handler runs only once) - Updated handleReady() method to contain startup logic - Tests pass (177 tests across 33 test files)
1 parent 6366a29 commit 9989f08

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

src/discord/client.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,23 @@ export class DiscordBot {
3939
return this.client;
4040
}
4141

42-
async start(): Promise<void> {
43-
this.client.once("ready", async (client) => {
44-
this.options.logger.info("Discord bot connected", {
45-
userTag: client.user.tag,
46-
monitoredChannelId: this.options.monitoredChannelId
47-
});
42+
private startupDone = false;
43+
44+
private handleReady(client: any): void {
45+
if (this.startupDone) return;
46+
this.startupDone = true;
47+
48+
this.options.logger.info("Discord bot connected", {
49+
userTag: client.user.tag,
50+
monitoredChannelId: this.options.monitoredChannelId
51+
});
52+
53+
this.registerSlashCommands();
54+
}
4855

49-
// Register slash commands
50-
await this.registerSlashCommands();
56+
async start(): Promise<void> {
57+
this.client.once("clientReady", (client) => {
58+
this.handleReady(client);
5159
});
5260

5361
this.client.on("messageCreate", async (message) => {

0 commit comments

Comments
 (0)