Skip to content

Commit 9062c2e

Browse files
authored
Use clientReady event instead of ready (#511)
1 parent ab5f4e1 commit 9062c2e

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- **Breaking:** set minimum Node version to 22.18.0
1616
- **Breaking:** upgrade to Node 24
1717
- Replace `nodemon` with `node --watch` for the `npm run dev` script
18+
- Use `clientReady` event instead of `ready` to fix deprecation warning
1819
- Use `Events` enum for event handler names
1920
- Replace `tsx` with native Node for `release.ts` script
2021
- Replace `jiti` with native Node for loading `eslint.config.ts`
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ const mockVerifyCommandDeployments = verifyCommandDeployments as Mock<
2929
vi.mock('../logger.js');
3030

3131
// Import the code to test
32-
import { ready } from './ready.js';
32+
import { clientReady } from './clientReady.js';
3333

34-
describe('once(ready)', () => {
34+
describe('once(clientReady)', () => {
3535
const client = {
3636
user: { username: 'Ze Kaiser Jr.' },
3737
destroy() {
@@ -56,7 +56,7 @@ describe('once(ready)', () => {
5656
deploy: false,
5757
revoke: false,
5858
});
59-
await ready.execute(client);
59+
await clientReady.execute(client);
6060
expect(mockDeployCommands).not.toHaveBeenCalled();
6161
expect(mockRevokeCommands).not.toHaveBeenCalled();
6262
});
@@ -66,7 +66,7 @@ describe('once(ready)', () => {
6666
deploy: true,
6767
revoke: false,
6868
});
69-
await ready.execute(client);
69+
await clientReady.execute(client);
7070
expect(mockDeployCommands).toHaveBeenCalledWith(client);
7171
expect(mockRevokeCommands).not.toHaveBeenCalled();
7272
});
@@ -76,7 +76,7 @@ describe('once(ready)', () => {
7676
deploy: false,
7777
revoke: true,
7878
});
79-
await ready.execute(client);
79+
await clientReady.execute(client);
8080
expect(mockDeployCommands).not.toHaveBeenCalled();
8181
expect(mockRevokeCommands).toHaveBeenCalledWith(client);
8282
});
@@ -86,13 +86,13 @@ describe('once(ready)', () => {
8686
deploy: true,
8787
revoke: true,
8888
});
89-
await ready.execute(client);
89+
await clientReady.execute(client);
9090
expect(mockDeployCommands).toHaveBeenCalledWith(client);
9191
expect(mockRevokeCommands).not.toHaveBeenCalled();
9292
});
9393

9494
test('verifies command deployments', async () => {
95-
await ready.execute(client);
95+
await clientReady.execute(client);
9696
expect(mockVerifyCommandDeployments).toHaveBeenCalledWith(client);
9797
});
9898
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { info } from '../logger.js';
1212
/**
1313
* The event handler for when the Discord Client is ready for action
1414
*/
15-
export const ready = onEvent(Events.ClientReady, {
15+
export const clientReady = onEvent(Events.ClientReady, {
1616
once: true,
1717
async execute(client) {
1818
info(`Starting ${client.user.username} v${appVersion}...`);

src/events/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ export function registerEventHandlers(client: Client): void {
5353
}
5454

5555
// Install event handlers
56+
import { clientReady } from './clientReady.js';
5657
import { error } from './error.js';
5758
import { interactionCreate } from './interactionCreate.js';
5859
import { messageReactionAdd } from './messageReactionAdd.js';
5960
import { messageReactionRemove } from './messageReactionRemove.js';
60-
import { ready } from './ready.js';
6161

62+
_add(clientReady as EventHandler);
6263
_add(error as EventHandler);
6364
_add(interactionCreate as EventHandler);
6465
_add(messageReactionAdd as EventHandler);
6566
_add(messageReactionRemove as EventHandler);
66-
_add(ready as EventHandler);
6767
// Not sure why these type casts are necessary, but they seem sound. We can remove them when TS gets smarter, or we learn what I did wrong

0 commit comments

Comments
 (0)