@@ -98,18 +98,22 @@ async function runGuildSlashCommand(params?: {
|
98 | 98 | } |
99 | 99 | |
100 | 100 | function expectNotUnauthorizedReply(interaction: MockCommandInteraction) { |
101 | | -expect(interaction.followUp).not.toHaveBeenCalledWith( |
102 | | -expect.objectContaining({ content: "You are not authorized to use this command." }), |
103 | | -); |
| 101 | +const unauthorizedReplies = interaction.followUp.mock.calls.filter(([payload]) => { |
| 102 | +if (!payload || typeof payload !== "object" || Array.isArray(payload)) { |
| 103 | +return false; |
| 104 | +} |
| 105 | +return ( |
| 106 | +(payload as { content?: unknown }).content === "You are not authorized to use this command." |
| 107 | +); |
| 108 | +}); |
| 109 | +expect(unauthorizedReplies).toEqual([]); |
104 | 110 | } |
105 | 111 | |
106 | 112 | function expectUnauthorizedReply(interaction: MockCommandInteraction) { |
107 | | -expect(interaction.followUp).toHaveBeenCalledWith( |
108 | | -expect.objectContaining({ |
109 | | -content: "You are not authorized to use this command.", |
110 | | -ephemeral: true, |
111 | | -}), |
112 | | -); |
| 113 | +expect(interaction.followUp).toHaveBeenCalledWith({ |
| 114 | +content: "You are not authorized to use this command.", |
| 115 | +ephemeral: true, |
| 116 | +}); |
113 | 117 | expect(interaction.reply).not.toHaveBeenCalled(); |
114 | 118 | } |
115 | 119 | |
@@ -457,9 +461,7 @@ describe("Discord native slash commands with commands.allowFrom", () => {
|
457 | 461 | const dispatchCall = vi.mocked(dispatcherModule.dispatchReplyWithDispatcher).mock.calls[0]?.[0]; |
458 | 462 | await dispatchCall?.dispatcherOptions.deliver({ text: longReply }, { kind: "final" }); |
459 | 463 | |
460 | | -expect(interaction.followUp).toHaveBeenCalledWith( |
461 | | -expect.objectContaining({ content: longReply }), |
462 | | -); |
| 464 | +expect(interaction.followUp).toHaveBeenCalledWith({ content: longReply, ephemeral: true }); |
463 | 465 | expect(interaction.reply).not.toHaveBeenCalled(); |
464 | 466 | }); |
465 | 467 | |
|