createMockRawMember
function in meocord/testing Since 4.2.0
createMockRawMember(
overrides?: MockRawMemberOverrides,
): APIInteractionGuildMemberCreates the member Discord sends with an interaction from a server the bot isn't in, as discord.js keeps it.
Give it as an interaction's member, with the server's guildId and no guild, to test a user-installed command
run there: the interaction reads inRawGuild() true, guild and channel null, user the member's user and
memberPermissions the member's, and a user option's member is the plain member Discord resolves too.
Parameters
| Name | Type | Description |
|---|---|---|
overrides? | MockRawMemberOverrides | Fields for the member; see |
Returns
APIInteractionGuildMemberThe member, as an APIInteractionGuildMember.
Examples
import { expect } from 'vitest'
const member = createMockRawMember({ roles: ['300000000000000001'], permissions: [PermissionFlagsBits.SendMessages] })
const command = createMockInteraction(ChatInputCommandInteraction, { guildId: '100000000000000001', member })
expect(command.inRawGuild()).toBe(true)