Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Breaking:** set minimum Node version to 22.18.0
- **Breaking:** upgrade to Node 24
- Replace `nodemon` with `node --watch` for the `npm run dev` script
- Use `clientReady` event instead of `ready` to fix deprecation warning
- Use `Events` enum for event handler names
- Replace `tsx` with native Node for `release.ts` script
- Replace `jiti` with native Node for loading `eslint.config.ts`
Expand Down
14 changes: 7 additions & 7 deletions src/events/ready.test.ts → src/events/clientReady.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const mockVerifyCommandDeployments = verifyCommandDeployments as Mock<
vi.mock('../logger.js');

// Import the code to test
import { ready } from './ready.js';
import { clientReady } from './clientReady.js';

describe('once(ready)', () => {
describe('once(clientReady)', () => {
const client = {
user: { username: 'Ze Kaiser Jr.' },
destroy() {
Expand All @@ -56,7 +56,7 @@ describe('once(ready)', () => {
deploy: false,
revoke: false,
});
await ready.execute(client);
await clientReady.execute(client);
expect(mockDeployCommands).not.toHaveBeenCalled();
expect(mockRevokeCommands).not.toHaveBeenCalled();
});
Expand All @@ -66,7 +66,7 @@ describe('once(ready)', () => {
deploy: true,
revoke: false,
});
await ready.execute(client);
await clientReady.execute(client);
expect(mockDeployCommands).toHaveBeenCalledWith(client);
expect(mockRevokeCommands).not.toHaveBeenCalled();
});
Expand All @@ -76,7 +76,7 @@ describe('once(ready)', () => {
deploy: false,
revoke: true,
});
await ready.execute(client);
await clientReady.execute(client);
expect(mockDeployCommands).not.toHaveBeenCalled();
expect(mockRevokeCommands).toHaveBeenCalledWith(client);
});
Expand All @@ -86,13 +86,13 @@ describe('once(ready)', () => {
deploy: true,
revoke: true,
});
await ready.execute(client);
await clientReady.execute(client);
expect(mockDeployCommands).toHaveBeenCalledWith(client);
expect(mockRevokeCommands).not.toHaveBeenCalled();
});

test('verifies command deployments', async () => {
await ready.execute(client);
await clientReady.execute(client);
expect(mockVerifyCommandDeployments).toHaveBeenCalledWith(client);
});
});
2 changes: 1 addition & 1 deletion src/events/ready.ts → src/events/clientReady.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { info } from '../logger.js';
/**
* The event handler for when the Discord Client is ready for action
*/
export const ready = onEvent(Events.ClientReady, {
export const clientReady = onEvent(Events.ClientReady, {
once: true,
async execute(client) {
info(`Starting ${client.user.username} v${appVersion}...`);
Expand Down
4 changes: 2 additions & 2 deletions src/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ export function registerEventHandlers(client: Client): void {
}

// Install event handlers
import { clientReady } from './clientReady.js';
import { error } from './error.js';
import { interactionCreate } from './interactionCreate.js';
import { messageReactionAdd } from './messageReactionAdd.js';
import { messageReactionRemove } from './messageReactionRemove.js';
import { ready } from './ready.js';

_add(clientReady as EventHandler);
_add(error as EventHandler);
_add(interactionCreate as EventHandler);
_add(messageReactionAdd as EventHandler);
_add(messageReactionRemove as EventHandler);
_add(ready as EventHandler);
// 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