Skip to content
GitHub

createMockRawMember

function in meocord/testing Since 4.2.0

createMockRawMember(
  overrides?: MockRawMemberOverrides,
): APIInteractionGuildMember

Creates 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

NameTypeDescription
overrides?MockRawMemberOverrides

Fields for the member; see MockRawMemberOverrides.

Returns

APIInteractionGuildMember

The member, as an APIInteractionGuildMember.

Examples

TypeScript
import { expect } from 'vitest'

const member = createMockRawMember({ roles: ['300000000000000001'], permissions: [PermissionFlagsBits.SendMessages] })
const command = createMockInteraction(ChatInputCommandInteraction, { guildId: '100000000000000001', member })
expect(command.inRawGuild()).toBe(true)