Skip to content
GitHub

createMockGuild

function in meocord/testing Since 4.0.0

createMockGuild(overrides?: MockGuildOverrides): DeepMocked<Guild>

Creates a mock Guild, with the members, channels, roles and bans managers ready to stub.

Use it for the server a message or an interaction came from, with the members, roles and channels a handler looks up in it.

Parameters

NameTypeSinceDescription
overrides?MockGuildOverrides4.1.0

The guild's id, name and preferred locale, and the members, roles and channels in its caches; see MockGuildOverrides.

overrides.id?string4.1.0

The guild's id.

overrides.name?string4.1.0

The guild's name, 'Guild' unless given.

overrides.preferredLocale?Locale4.1.0

The language the guild's community set, 'en-US' unless given; t.forGuild() reads it.

overrides.members?readonly GuildMember[]4.1.0

Members in members.cache, by their id.

overrides.roles?readonly Role[]4.1.0

Roles in roles.cache, by their id.

overrides.channels?readonly GuildBasedChannel[]4.1.0

Channels in channels.cache, by their id.

Returns

DeepMocked<Guild>

Examples

TypeScript
const target = createMock<GuildMember>({ id: '111111111111111111' })
const guild = createMockGuild({ members: [target] })
const message = createMockMessage({ content: '!ban 111111111111111111 spam', guild })