diff --git a/.version b/.version index ee90284..90a27f9 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.0.4 +1.0.5 diff --git a/src/commands/create-command.ts b/src/commands/create-command.ts index 83d4bbc..9732a26 100644 --- a/src/commands/create-command.ts +++ b/src/commands/create-command.ts @@ -34,8 +34,6 @@ export async function handleCreateCommand( return; } - await interaction.deferReply(); - const casual = !!interaction.options.getBoolean('casual', false); const info = interaction.options.getString('info', false) ?? undefined; const timeInMinutes = @@ -56,11 +54,10 @@ export async function handleCreateCommand( const rolePing = getPingsForServer(interaction, casual); - const reply = await interaction.editReply({ + const reply = await interaction.reply({ content: rolePing || undefined, embeds: [embed], components: [buttonRow, selectRow], - allowedMentions: { parse: ['roles', 'users', 'everyone'] }, }); const message = await reply.fetch(); const matchId = randomUUID(); diff --git a/src/commands/reping-command.ts b/src/commands/reping-command.ts index 6689aec..b6ca6d1 100644 --- a/src/commands/reping-command.ts +++ b/src/commands/reping-command.ts @@ -117,8 +117,6 @@ export async function handleRepingCommand( return; } - await interaction.deferReply(); - await eventManager.deleteRepingMessageIfExists( userEventId, interaction.client, @@ -127,9 +125,8 @@ export async function handleRepingCommand( const guildId = interaction.guildId; const messageUrl = `https://discord.com/channels/${guildId}/${channelId}/${userEventId}`; - const reply = await interaction.editReply({ + const reply = await interaction.reply({ content: REPING_MESSAGE(rolePing, missingPlayers, messageUrl), - allowedMentions: { parse: ['roles', 'users', 'everyone'] }, }); const repingMessage = await withRetry( diff --git a/src/tests/commands/create-command.test.ts b/src/tests/commands/create-command.test.ts index cec48fd..f4506e6 100644 --- a/src/tests/commands/create-command.test.ts +++ b/src/tests/commands/create-command.test.ts @@ -46,8 +46,18 @@ describe('create-command', () => { getString: vi.fn(() => null), getInteger: vi.fn(() => null), }, - reply: vi.fn().mockResolvedValue(undefined), - deferReply: vi.fn().mockResolvedValue(undefined), + reply: vi.fn().mockResolvedValue({ + fetch: vi.fn().mockResolvedValue({ + id: 'message123', + channelId: 'channel123', + }), + }), + deferReply: vi.fn().mockResolvedValue({ + fetch: vi.fn().mockResolvedValue({ + id: 'message123', + channelId: 'channel123', + }), + }), editReply: vi.fn().mockResolvedValue({ fetch: vi.fn().mockResolvedValue({ id: 'message123', @@ -102,7 +112,10 @@ describe('create-command', () => { content: ERROR_MESSAGES.ALREADY_SIGNED_UP, flags: ['Ephemeral'], }); - expect(mockInteraction.deferReply).not.toHaveBeenCalled(); + expect(mockInteraction.reply).toHaveBeenCalledWith({ + content: ERROR_MESSAGES.ALREADY_SIGNED_UP, + flags: ['Ephemeral'], + }); }); }); @@ -116,8 +129,7 @@ describe('create-command', () => { mockTelemetry as never, ); - expect(mockInteraction.deferReply).toHaveBeenCalled(); - expect(mockInteraction.editReply).toHaveBeenCalled(); + expect(mockInteraction.reply).toHaveBeenCalled(); expect(mockEventManager.setCreator).toHaveBeenCalledWith( 'message123', 'user123', @@ -264,7 +276,7 @@ describe('create-command', () => { describe('error handling', () => { it('should handle errors and call safeReplyToInteraction', async () => { - mockInteraction.deferReply.mockRejectedValue(new Error('Network error')); + mockInteraction.reply.mockRejectedValue(new Error('Network error')); const { safeReplyToInteraction } = await import('../../utils/helpers.js'); await handleCreateCommand( diff --git a/src/tests/commands/reping-command.test.ts b/src/tests/commands/reping-command.test.ts index dec31c8..53e1b93 100644 --- a/src/tests/commands/reping-command.test.ts +++ b/src/tests/commands/reping-command.test.ts @@ -52,8 +52,8 @@ describe('reping-command', () => { fetch: vi.fn().mockResolvedValue(mockChannel), }, }, - reply: vi.fn().mockResolvedValue(undefined), - deferReply: vi.fn().mockResolvedValue(undefined), + reply: vi.fn().mockResolvedValue(mockReply), + deferreply: vi.fn().mockResolvedValue(mockReply), editReply: vi.fn().mockResolvedValue(mockReply), }; }