getResponse
function in meocord/testing Since 4.1.0
getResponse(interaction: Interaction): ResponseReportReports how an interaction was answered: where its answer stands, and every answer call it got, in order.
Use it after invoke or dispatch to check what the member sees. A mock interaction records each reply,
deferReply, editReply, followUp, deleteReply, update, deferUpdate and showModal, whether the handler
made it through respond() or with discord.js directly, so both are reported, each once. For a message or a
reaction, read the mock's own methods.
Parameters
| Name | Type | Description |
|---|---|---|
interaction | Interaction | The interaction a handler answered. |
Returns
ResponseReportThe state, whether anything the member can see was sent, and the calls, in order.
Examples
import { expect } from 'vitest'
@Controller()
class RefreshController {
@Command('refresh', CommandType.BUTTON)
@Defer()
async refresh(interaction: ButtonInteraction) {
await respond(interaction).send('Refreshed.')
}
}
const module = MeoCordTestingModule.create({ controllers: [RefreshController] }).compile()
const interaction = createMockInteraction(ButtonInteraction, { customId: 'refresh' })
await module.invoke(RefreshController, 'refresh', interaction)
expect(getResponse(interaction).calls.map(call => call.method)).toEqual(['deferUpdate', 'editReply'])