Skip to content
Open
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.12.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

### Removed

Expand Down
16 changes: 8 additions & 8 deletions src/events/ready.test.ts → src/events/clientReady.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,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)', () => {
beforeEach(() => {
// Default is no deploy, no revoke, no method behavior
mockParseArgs.mockReturnValue({
Expand All @@ -77,7 +77,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 @@ -87,7 +87,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 @@ -97,7 +97,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 @@ -107,18 +107,18 @@ 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);
});

test('sets user activity', async () => {
await ready.execute(client);
await clientReady.execute(client);
expect(mockSetActivity).toHaveBeenCalledOnce();
});
});
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 @@ -13,7 +13,7 @@ import { info } from '../logger.js';
/**
* The event handler for when the Discord Client is ready for action
*/
export const ready = onEvent('ready', {
export const clientReady = onEvent('clientReady', {
once: true,
async execute(client) {
info(`Starting ${client.user.username} v${appVersion}...`);
Expand Down
2 changes: 1 addition & 1 deletion src/events/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('allEvents', () => {
(allEventHandlers as Map<string, unknown>).clear();

const fakeReadyEvent: EventHandler = {
name: 'ready',
name: 'clientReady',
once: true,
execute: vi.fn(),
};
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
4 changes: 2 additions & 2 deletions src/helpers/onEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ describe('Creating event handlers', () => {
// few arguments, or arguments of the wrong type.

test('creates a proper event handler', () => {
const handler = onEvent('ready', {
const handler = onEvent('clientReady', {
once: true,
execute: executeMock,
});
expect(handler).toHaveProperty('name', 'ready');
expect(handler).toHaveProperty('name', 'clientReady');
expect(handler).toHaveProperty('once', true);
expect(handler).toHaveProperty('execute', executeMock);
});
Expand Down