LogoRobo.js
Packages@robojs/mock

MockServerState

Class: MockServerState

Centralized state management for a mock session. Provides CRUD methods for all mock entities.

Implements

Constructors

new MockServerState()

new MockServerState(options?): MockServerState

Parameters

ParameterType
options?StateOptions

Returns

MockServerState

Properties

PropertyModifierTypeDescription
applicationEmojisreadonlyMap<string, MockEmoji>-
applicationIdreadonlystring-
attachmentStoragereadonlyMemoryAttachmentStorageAttachment storage backend. See - AttachmentStorage for the interface - MemoryAttachmentStorage for the default implementation
auditLogsreadonlyMap<string, MockAuditLogEntry[]>-
autoModRulesreadonlyMap<string, MockAutoModRule>-
bansreadonlyMap<string, MockBan>-
botUserreadonlyMockUser-
channelsreadonlyMap<string, MockChannel>-
commandPermissionsreadonlyMap<string, MockCommandPermission[]>-
commandsreadonlyMap<string, MockApplicationCommand>-
dmChannelsreadonlyMap<string, MockChannel>-
emojisreadonlyMap<string, MockEmoji>-
guildMembersreadonlyMap<string, MockGuildMember>-
guildsreadonlyMap<string, MockGuild>-
interactionsreadonlyMap<string, MockInteraction>-
invitesreadonlyMap<string, MockInvite>-
messagesreadonlyMap<string, MockMessage>-
pollVotesreadonlyMap<string, Map<string, number[]>>-
rolesreadonlyMap<string, MockRole>-
scheduledEventsreadonlyMap<string, MockScheduledEvent>-
stageInstancesreadonlyMap<string, MockStageInstance>-
stickersreadonlyMap<string, MockSticker>-
threadMembersreadonlyMap<string, Map<string, MockThreadMember>>-
usersreadonlyMap<string, MockUser>-
voiceStatesreadonlyMap<string, MockVoiceState>-
webhooksreadonlyMap<string, MockWebhook>-

Accessors

currentUser

Get Signature

get currentUser(): MockUser

Get the current acting user for Stage UI interactions. Creates a default user on first access if none is set.

Returns

MockUser

Set Signature

set currentUser(user): void

Set the current acting user.

Parameters
ParameterType
userMockUser
Returns

void

Current "acting" user for Stage UI interactions (separate from botUser)

Implementation of

SessionState.currentUser


sequence

Get Signature

get sequence(): number
Returns

number

Set Signature

set sequence(value): void
Parameters
ParameterType
valuenumber
Returns

void

Implementation of

SessionState.sequence

Methods

addChannel()

addChannel(channel): void

Add a channel to the state

Parameters

ParameterType
channelMockChannel

Returns

void

Implementation of

SessionState.addChannel


addChannelToGuild()

addChannelToGuild(guildId, channel): void

Add a channel to a guild

Parameters

ParameterType
guildIdstring
channelMockChannel

Returns

void

Implementation of

SessionState.addChannelToGuild


addForumTag()

addForumTag(channelId, tag): undefined | MockForumTag

Add a tag to a forum channel

Parameters

ParameterType
channelIdstring
tagOmit<MockForumTag, "id">

Returns

undefined | MockForumTag

Implementation of

SessionState.addForumTag


addGuild()

addGuild(guild): void

Add a guild to the state

Parameters

ParameterType
guildMockGuild

Returns

void

Implementation of

SessionState.addGuild


addInteraction()

addInteraction(interaction): void

Add an interaction to the state

Parameters

ParameterType
interactionMockInteraction

Returns

void

Implementation of

SessionState.addInteraction


addMemberRole()

addMemberRole(
   guildId, 
   userId, 
   roleId): boolean

Add a role to a member

Parameters

ParameterType
guildIdstring
userIdstring
roleIdstring

Returns

boolean

true if added, false if member/role not found or already has role

Implementation of

SessionState.addMemberRole


addMemberToGuild()

addMemberToGuild(
   guildId, 
   userId, 
   config?): void

Add a user as a member to a guild. Creates the guild member entry if it doesn't exist.

Parameters

ParameterType
guildIdstring
userIdstring
config?Partial<MockGuildMemberConfig>

Returns

void


addPollVote()

addPollVote(
   messageId, 
   userId, 
   answerId): boolean

Add a vote to a poll

Parameters

ParameterType
messageIdstring
userIdstring
answerIdnumber

Returns

boolean

true if vote was added, false if already voted (single-select) or invalid

Implementation of

SessionState.addPollVote


addReaction()

addReaction(
   messageId, 
   userId, 
   emoji): undefined | MockReaction[]

Add a reaction to a message Returns the updated reactions array or undefined if message not found

Parameters

ParameterType
messageIdstring
userIdstring
emoji{ id: null | string; name: string; }
emoji.idnull | string
emoji.namestring

Returns

undefined | MockReaction[]

Implementation of

SessionState.addReaction


addScheduledEventSubscriber()

addScheduledEventSubscriber(
   guildId, 
   eventId, 
   userId): boolean

Add a subscriber to a scheduled event

Parameters

ParameterType
guildIdstring
eventIdstring
userIdstring

Returns

boolean

true if added, false if event not found

Implementation of

SessionState.addScheduledEventSubscriber


addSticker()

addSticker(sticker): void

Add a sticker directly to state (for control API) This allows adding standard/nitro stickers without a guild

Parameters

ParameterType
stickerMockSticker

Returns

void

Implementation of

SessionState.addSticker


addThreadMember()

addThreadMember(threadId, userId): undefined | MockThreadMember

Add a member to a thread

Parameters

ParameterType
threadIdstring
userIdstring

Returns

undefined | MockThreadMember

Implementation of

SessionState.addThreadMember


addUser()

addUser(user): void

Add a user to the state

Parameters

ParameterType
userMockUser

Returns

void

Implementation of

SessionState.addUser


bulkOverwriteCommands()

bulkOverwriteCommands(configs, guildId?): null | MockApplicationCommand[]

Bulk overwrite commands for a scope (global or guild) Replaces all existing commands with the provided ones

Parameters

ParameterType
configsMockApplicationCommandConfig[]
guildId?string

Returns

null | MockApplicationCommand[]

Array of created commands, or null if validation fails

Implementation of

SessionState.bulkOverwriteCommands


checkAutoArchiveThreads()

checkAutoArchiveThreads(): string[]

Check and archive inactive threads based on auto_archive_duration Returns array of thread IDs that were archived

Returns

string[]

Implementation of

SessionState.checkAutoArchiveThreads


checkPollExpiry()

checkPollExpiry(messageId): boolean

Check if a poll has expired and finalize it

Parameters

ParameterType
messageIdstring

Returns

boolean

true if poll was expired

Implementation of

SessionState.checkPollExpiry


cleanupExpiredInteractions()

cleanupExpiredInteractions(): void

Cleanup expired interactions (older than 15 minutes)

Returns

void

Implementation of

SessionState.cleanupExpiredInteractions


createAuditLogEntry()

createAuditLogEntry(guildId, config): MockAuditLogEntry

Create an audit log entry for a guild

Parameters

ParameterTypeDescription
guildIdstringThe guild ID
configMockAuditLogEntryConfigThe audit log entry configuration

Returns

MockAuditLogEntry

The created audit log entry

Implementation of

SessionState.createAuditLogEntry


createAutoModRule()

createAutoModRule(
   guildId, 
   config, 
   creatorId): null | MockAutoModRule

Create an auto-mod rule

Parameters

ParameterType
guildIdstring
configMockAutoModRuleConfig
creatorIdstring

Returns

null | MockAutoModRule

The created rule, or null if validation fails

Implementation of

SessionState.createAutoModRule


createBan()

createBan(
   guildId, 
   userId, 
   config?): null | MockBan

Create a ban for a user in a guild Also removes the member from the guild if they're a member

Parameters

ParameterType
guildIdstring
userIdstring
config?MockBanConfig

Returns

null | MockBan

The created ban, or null if guild doesn't exist

Implementation of

SessionState.createBan


createCommand()

createCommand(config, guildId?): null | MockApplicationCommand

Create a new application command

Parameters

ParameterType
configMockApplicationCommandConfig
guildId?string

Returns

null | MockApplicationCommand

The created command, or null if validation fails

Implementation of

SessionState.createCommand


createEveryoneRole()

createEveryoneRole(guildId): MockRole

Create the

Parameters

ParameterType
guildIdstring

Returns

MockRole

Everyone

role for a guild Called automatically when a guild is created

Implementation of

SessionState.createEveryoneRole


createForumChannel()

createForumChannel(config): MockForumChannel

Create a forum or media channel

Parameters

ParameterType
configMockForumChannelConfig

Returns

MockForumChannel

Implementation of

SessionState.createForumChannel


createForumPost()

createForumPost(config): {
  message: MockMessage;
  thread: MockForumThread;
}

Create a forum post (thread with initial message)

Parameters

ParameterType
configMockForumPostConfig

Returns

{
  message: MockMessage;
  thread: MockForumThread;
}
NameType
messageMockMessage
threadMockForumThread

Implementation of

SessionState.createForumPost


createGuildEmoji()

createGuildEmoji(
   guildId, 
   config, 
   uploaderId): null | MockEmoji

Create a guild emoji

Parameters

ParameterType
guildIdstring
configMockEmojiConfig
uploaderIdstring

Returns

null | MockEmoji

The created emoji, or null if guild doesn't exist or limit reached

Implementation of

SessionState.createGuildEmoji


createGuildMember()

createGuildMember(
   guildId, 
   userId, 
   config?): null | MockGuildMember

Create or add a member to a guild

Parameters

ParameterType
guildIdstring
userIdstring
config?MockGuildMemberConfig

Returns

null | MockGuildMember

The created/existing member, or null if guild doesn't exist

Implementation of

SessionState.createGuildMember


createGuildRole()

createGuildRole(guildId, config?): null | MockRole

Create a new role in a guild

Parameters

ParameterType
guildIdstring
config?MockRoleConfig

Returns

null | MockRole

The created role, or null if guild doesn't exist or limit reached

Implementation of

SessionState.createGuildRole


createGuildSticker()

createGuildSticker(
   guildId, 
   config, 
   uploaderId): null | MockSticker

Create a guild sticker

Parameters

ParameterType
guildIdstring
configMockStickerConfig
uploaderIdstring

Returns

null | MockSticker

The created sticker, or null if guild doesn't exist or limit reached

Implementation of

SessionState.createGuildSticker


createInvite()

createInvite(
   guildId, 
   channelId, 
   config, 
   inviterId): null | MockInvite

Create an invite for a channel

Parameters

ParameterType
guildIdstring
channelIdstring
configMockInviteConfig
inviterIdstring

Returns

null | MockInvite

The created invite, or null if channel doesn't exist

Implementation of

SessionState.createInvite


createMessage()

createMessage(config): MockMessage

Create and store a message

Parameters

ParameterType
configMockMessageConfig

Returns

MockMessage

Implementation of

SessionState.createMessage


createScheduledEvent()

createScheduledEvent(
   guildId, 
   config, 
   creatorId): null | MockScheduledEvent

Create a scheduled event

Parameters

ParameterType
guildIdstring
configMockScheduledEventConfig
creatorIdstring

Returns

null | MockScheduledEvent

The created event, or null if validation fails

Implementation of

SessionState.createScheduledEvent


createStageInstance()

createStageInstance(guildId, config): null | MockStageInstance

Create a stage instance

Parameters

ParameterType
guildIdstring
configMockStageInstanceConfig

Returns

null | MockStageInstance

The created stage instance, or null if validation fails

Implementation of

SessionState.createStageInstance


createThread()

createThread(config): MockThread

Create a thread channel

Parameters

ParameterType
configMockThreadConfig

Returns

MockThread

Implementation of

SessionState.createThread


createWebhook()

createWebhook(
   channelId, 
   config, 
   creatorId): null | MockWebhook

Create a webhook

Parameters

ParameterType
channelIdstring
configMockWebhookConfig
creatorIdstring

Returns

null | MockWebhook

The created webhook, or null if channel doesn't exist or limit reached

Implementation of

SessionState.createWebhook


deleteAttachment()

deleteAttachment(id): boolean

Delete an attachment by ID.

Parameters

ParameterType
idstring

Returns

boolean

Implementation of

SessionState.deleteAttachment


deleteAutoModRule()

deleteAutoModRule(guildId, ruleId): null | MockAutoModRule

Delete an auto-mod rule

Parameters

ParameterType
guildIdstring
ruleIdstring

Returns

null | MockAutoModRule

The deleted rule, or null if not found

Implementation of

SessionState.deleteAutoModRule


deleteChannelOverwrite()

deleteChannelOverwrite(channelId, overwriteId): boolean

Delete a permission overwrite from a channel

Parameters

ParameterType
channelIdstring
overwriteIdstring

Returns

boolean

true if deleted, false if not found

Implementation of

SessionState.deleteChannelOverwrite


deleteCommand()

deleteCommand(commandId): boolean

Delete a command by ID

Parameters

ParameterType
commandIdstring

Returns

boolean

true if deleted, false if not found

Implementation of

SessionState.deleteCommand


deleteGuildEmoji()

deleteGuildEmoji(emojiId): boolean

Delete a guild emoji

Parameters

ParameterType
emojiIdstring

Returns

boolean

true if deleted, false if not found

Implementation of

SessionState.deleteGuildEmoji


deleteGuildRole()

deleteGuildRole(
   guildId, 
   roleId, 
   reason?): boolean

Delete a role from a guild

Parameters

ParameterType
guildIdstring
roleIdstring
reason?string

Returns

boolean

true if deleted, false if not found or cannot delete

Everyone

Implementation of

SessionState.deleteGuildRole


deleteGuildSticker()

deleteGuildSticker(stickerId): boolean

Delete a guild sticker

Parameters

ParameterType
stickerIdstring

Returns

boolean

true if deleted, false if not found

Implementation of

SessionState.deleteGuildSticker


deleteInvite()

deleteInvite(code): null | MockInvite

Delete an invite by code

Parameters

ParameterType
codestring

Returns

null | MockInvite

The deleted invite, or null if not found

Implementation of

SessionState.deleteInvite


deleteMessage()

deleteMessage(id): boolean

Delete a message and its associated attachments

Parameters

ParameterType
idstring

Returns

boolean

Implementation of

SessionState.deleteMessage


deleteScheduledEvent()

deleteScheduledEvent(guildId, eventId): boolean

Delete a scheduled event

Parameters

ParameterType
guildIdstring
eventIdstring

Returns

boolean

true if deleted, false if not found

Implementation of

SessionState.deleteScheduledEvent


deleteStageInstance()

deleteStageInstance(channelId): null | MockStageInstance

Delete a stage instance

Parameters

ParameterType
channelIdstring

Returns

null | MockStageInstance

The deleted stage instance, or null if not found

Implementation of

SessionState.deleteStageInstance


deleteThread()

deleteThread(threadId): boolean

Delete a thread

Parameters

ParameterType
threadIdstring

Returns

boolean

Implementation of

SessionState.deleteThread


deleteWebhook()

deleteWebhook(webhookId): boolean

Delete a webhook

Parameters

ParameterType
webhookIdstring

Returns

boolean

true if deleted, false if not found

Implementation of

SessionState.deleteWebhook


expirePoll()

expirePoll(messageId): boolean

Expire (finalize) a poll

Parameters

ParameterType
messageIdstring

Returns

boolean

true if poll was expired, false if already expired or no poll

Implementation of

SessionState.expirePoll


findCommandByName()

findCommandByName(name, guildId?): undefined | MockApplicationCommand

Find a command by name within a scope (global or guild)

Parameters

ParameterType
namestring
guildId?string

Returns

undefined | MockApplicationCommand

Implementation of

SessionState.findCommandByName


getActiveThreadsForGuild()

getActiveThreadsForGuild(guildId): MockThread[]

Get all active (non-archived) threads in a guild

Parameters

ParameterType
guildIdstring

Returns

MockThread[]

Implementation of

SessionState.getActiveThreadsForGuild


getAttachment()

getAttachment(id): undefined | StoredAttachment

Get an attachment by ID.

Parameters

ParameterType
idstring

Returns

undefined | StoredAttachment

Implementation of

SessionState.getAttachment


getAttachmentsForMessage()

getAttachmentsForMessage(messageId): StoredAttachment[]

Get all attachments for a message.

Parameters

ParameterType
messageIdstring

Returns

StoredAttachment[]

Implementation of

SessionState.getAttachmentsForMessage


getAuditLogEntries()

getAuditLogEntries(guildId, options?): MockAuditLogEntry[]

Get audit log entries for a guild with optional filtering

Parameters

ParameterTypeDescription
guildIdstringThe guild ID
options?{ actionType: AuditLogEvent; before: string; limit: number; userId: string; }Filtering options
options.actionType?AuditLogEvent-
options.before?string-
options.limit?number-
options.userId?string-

Returns

MockAuditLogEntry[]

Array of audit log entries

Implementation of

SessionState.getAuditLogEntries


getAutoModRule()

getAutoModRule(guildId, ruleId): undefined | MockAutoModRule

Get an auto-mod rule by ID

Parameters

ParameterType
guildIdstring
ruleIdstring

Returns

undefined | MockAutoModRule

Implementation of

SessionState.getAutoModRule


getBan()

getBan(guildId, userId): undefined | MockBan

Get a ban for a specific user in a guild

Parameters

ParameterType
guildIdstring
userIdstring

Returns

undefined | MockBan

Implementation of

SessionState.getBan


getChannel()

getChannel(id): undefined | MockChannel

Get a channel by ID (includes guild channels and DM channels)

Parameters

ParameterType
idstring

Returns

undefined | MockChannel

Implementation of

SessionState.getChannel


getChannelInvites()

getChannelInvites(channelId): MockInvite[]

Get all invites for a channel

Parameters

ParameterType
channelIdstring

Returns

MockInvite[]

Implementation of

SessionState.getChannelInvites


getChannelOverwrites()

getChannelOverwrites(channelId): MockChannelOverwrite[]

Get permission overwrites for a channel

Parameters

ParameterType
channelIdstring

Returns

MockChannelOverwrite[]

Implementation of

SessionState.getChannelOverwrites


getChannelsForGuild()

getChannelsForGuild(guildId): MockChannel[]

Get all channels for a guild

Parameters

ParameterType
guildIdstring

Returns

MockChannel[]

Implementation of

SessionState.getChannelsForGuild


getCommand()

getCommand(commandId): undefined | MockApplicationCommand

Get a command by ID

Parameters

ParameterType
commandIdstring

Returns

undefined | MockApplicationCommand

Implementation of

SessionState.getCommand


getDMChannel()

getDMChannel(recipientId): undefined | MockChannel

Get a DM channel by recipient user ID (uses currentUser as the other participant)

Parameters

ParameterType
recipientIdstring

Returns

undefined | MockChannel

Implementation of

SessionState.getDMChannel


getEmoji()

getEmoji(emojiId): undefined | MockEmoji

Get an emoji by ID

Parameters

ParameterType
emojiIdstring

Returns

undefined | MockEmoji

Implementation of

SessionState.getEmoji


getForumChannel()

getForumChannel(id): undefined | MockForumChannel

Get a forum channel by ID (returns undefined if not a forum/media channel)

Parameters

ParameterType
idstring

Returns

undefined | MockForumChannel

Implementation of

SessionState.getForumChannel


getForumChannelsForGuild()

getForumChannelsForGuild(guildId): MockForumChannel[]

Get all forum/media channels in a guild

Parameters

ParameterType
guildIdstring

Returns

MockForumChannel[]

Implementation of

SessionState.getForumChannelsForGuild


getForumPosts()

getForumPosts(forumChannelId, options?): MockForumThread[]

Get posts (threads) in a forum channel

Parameters

ParameterType
forumChannelIdstring
options?{ archived: boolean; }
options.archived?boolean

Returns

MockForumThread[]

Implementation of

SessionState.getForumPosts


getForumThread()

getForumThread(id): undefined | MockForumThread

Get a forum thread by ID (returns undefined if not a forum thread)

Parameters

ParameterType
idstring

Returns

undefined | MockForumThread

Implementation of

SessionState.getForumThread


getGlobalCommands()

getGlobalCommands(): MockApplicationCommand[]

Get all global commands (no guild_id)

Returns

MockApplicationCommand[]

Implementation of

SessionState.getGlobalCommands


getGuild()

getGuild(id): undefined | MockGuild

Get a guild by ID

Parameters

ParameterType
idstring

Returns

undefined | MockGuild

Implementation of

SessionState.getGuild


getGuildAutoModRules()

getGuildAutoModRules(guildId): MockAutoModRule[]

Get all auto-mod rules for a guild

Parameters

ParameterType
guildIdstring

Returns

MockAutoModRule[]

Implementation of

SessionState.getGuildAutoModRules


getGuildBans()

getGuildBans(guildId): MockBan[]

Get all bans for a guild

Parameters

ParameterType
guildIdstring

Returns

MockBan[]

Implementation of

SessionState.getGuildBans


getGuildCommands()

getGuildCommands(guildId): MockApplicationCommand[]

Get all commands for a specific guild

Parameters

ParameterType
guildIdstring

Returns

MockApplicationCommand[]

Implementation of

SessionState.getGuildCommands


getGuildEmojis()

getGuildEmojis(guildId): MockEmoji[]

Get all emojis for a guild

Parameters

ParameterType
guildIdstring

Returns

MockEmoji[]

Implementation of

SessionState.getGuildEmojis


getGuildInvites()

getGuildInvites(guildId): MockInvite[]

Get all invites for a guild

Parameters

ParameterType
guildIdstring

Returns

MockInvite[]

Implementation of

SessionState.getGuildInvites


getGuildMember()

getGuildMember(guildId, userId): undefined | MockGuildMember

Get a guild member

Parameters

ParameterType
guildIdstring
userIdstring

Returns

undefined | MockGuildMember

Implementation of

SessionState.getGuildMember


getGuildMembers()

getGuildMembers(guildId): MockGuildMember[]

Get all members of a guild

Parameters

ParameterType
guildIdstring

Returns

MockGuildMember[]

Implementation of

SessionState.getGuildMembers


getGuildRole()

getGuildRole(guildId, roleId): undefined | MockRole

Get a role by ID within a guild

Parameters

ParameterType
guildIdstring
roleIdstring

Returns

undefined | MockRole

Implementation of

SessionState.getGuildRole


getGuildRoles()

getGuildRoles(guildId): MockRole[]

Get all roles for a guild

Parameters

ParameterType
guildIdstring

Returns

MockRole[]

Implementation of

SessionState.getGuildRoles


getGuildScheduledEvents()

getGuildScheduledEvents(guildId): MockScheduledEvent[]

Get all scheduled events for a guild

Parameters

ParameterType
guildIdstring

Returns

MockScheduledEvent[]

Implementation of

SessionState.getGuildScheduledEvents


getGuildStageInstances()

getGuildStageInstances(guildId): MockStageInstance[]

Get all stage instances for a guild

Parameters

ParameterType
guildIdstring

Returns

MockStageInstance[]

Implementation of

SessionState.getGuildStageInstances


getGuildStickers()

getGuildStickers(guildId): MockSticker[]

Get all stickers for a guild

Parameters

ParameterType
guildIdstring

Returns

MockSticker[]

Implementation of

SessionState.getGuildStickers


getInteraction()

getInteraction(id): undefined | MockInteraction

Get an interaction by ID

Parameters

ParameterType
idstring

Returns

undefined | MockInteraction

Implementation of

SessionState.getInteraction


getInteractionByToken()

getInteractionByToken(token): undefined | MockInteraction

Get an interaction by token

Parameters

ParameterType
tokenstring

Returns

undefined | MockInteraction

Implementation of

SessionState.getInteractionByToken


getInvite()

getInvite(code): undefined | MockInvite

Get an invite by code

Parameters

ParameterType
codestring

Returns

undefined | MockInvite

Implementation of

SessionState.getInvite


getMessage()

getMessage(id): undefined | MockMessage

Get a message by ID

Parameters

ParameterType
idstring

Returns

undefined | MockMessage

Implementation of

SessionState.getMessage


getMessagesForChannel()

getMessagesForChannel(channelId, limit?): MockMessage[]

Get messages for a channel, optionally limited

Parameters

ParameterType
channelIdstring
limit?number

Returns

MockMessage[]

Implementation of

SessionState.getMessagesForChannel


getOrCreateDMChannel()

getOrCreateDMChannel(recipientId): MockChannel

Get or create a DM channel for a recipient (uses currentUser as the other participant)

Parameters

ParameterType
recipientIdstring

Returns

MockChannel

Implementation of

SessionState.getOrCreateDMChannel


getOrCreateTestUser()

getOrCreateTestUser(userId?): MockUser

Get or create a default test user for dispatching messages This creates a consistent "TestUser" that can be used when no author is specified

Parameters

ParameterType
userId?string

Returns

MockUser

Implementation of

SessionState.getOrCreateTestUser


getPollVoters()

getPollVoters(messageId, answerId): string[]

Get all users who voted for a specific answer

Parameters

ParameterType
messageIdstring
answerIdnumber

Returns

string[]

Implementation of

SessionState.getPollVoters


getRole()

getRole(roleId): undefined | MockRole

Get a role by ID

Parameters

ParameterType
roleIdstring

Returns

undefined | MockRole

Implementation of

SessionState.getRole


getScheduledEvent()

getScheduledEvent(guildId, eventId): undefined | MockScheduledEvent

Get a scheduled event by ID

Parameters

ParameterType
guildIdstring
eventIdstring

Returns

undefined | MockScheduledEvent

Implementation of

SessionState.getScheduledEvent


getScheduledEventSubscribers()

getScheduledEventSubscribers(
   guildId, 
   eventId, 
   options?): {
  member: MockGuildMember;
  user: MockUser;
 }[]

Get subscribers for a scheduled event

Parameters

ParameterType
guildIdstring
eventIdstring
options?{ after: string; before: string; limit: number; withMember: boolean; }
options.after?string
options.before?string
options.limit?number
options.withMember?boolean

Returns

{ member: MockGuildMember; user: MockUser; }[]

Implementation of

SessionState.getScheduledEventSubscribers


getStageInstance()

getStageInstance(channelId): undefined | MockStageInstance

Get a stage instance by channel ID

Parameters

ParameterType
channelIdstring

Returns

undefined | MockStageInstance

Implementation of

SessionState.getStageInstance


getSticker()

getSticker(stickerId): undefined | MockSticker

Get a sticker by ID

Parameters

ParameterType
stickerIdstring

Returns

undefined | MockSticker

Implementation of

SessionState.getSticker


getThread()

getThread(id): undefined | MockThread

Get a thread by ID (returns undefined if not a thread)

Parameters

ParameterType
idstring

Returns

undefined | MockThread

Implementation of

SessionState.getThread


getThreadMember()

getThreadMember(threadId, userId): undefined | MockThreadMember

Get a thread member

Parameters

ParameterType
threadIdstring
userIdstring

Returns

undefined | MockThreadMember

Implementation of

SessionState.getThreadMember


getThreadMembers()

getThreadMembers(threadId): MockThreadMember[]

Get all members of a thread

Parameters

ParameterType
threadIdstring

Returns

MockThreadMember[]

Implementation of

SessionState.getThreadMembers


getThreadsForChannel()

getThreadsForChannel(channelId, options?): MockThread[]

Get all threads for a parent channel

Parameters

ParameterType
channelIdstring
options?{ archived: boolean; }
options.archived?boolean

Returns

MockThread[]

Implementation of

SessionState.getThreadsForChannel


getUser()

getUser(id): undefined | MockUser

Get a user by ID

Parameters

ParameterType
idstring

Returns

undefined | MockUser

Implementation of

SessionState.getUser


getUserPollVotes()

getUserPollVotes(messageId, userId): number[]

Get all votes for a user on a poll

Parameters

ParameterType
messageIdstring
userIdstring

Returns

number[]

Implementation of

SessionState.getUserPollVotes


getWebhook()

getWebhook(webhookId): undefined | MockWebhook

Get a webhook by ID

Parameters

ParameterType
webhookIdstring

Returns

undefined | MockWebhook

Implementation of

SessionState.getWebhook


getWebhookByToken()

getWebhookByToken(token): undefined | MockWebhook

Get a webhook by its token

Parameters

ParameterType
tokenstring

Returns

undefined | MockWebhook

Implementation of

SessionState.getWebhookByToken


getWebhooksForChannel()

getWebhooksForChannel(channelId): MockWebhook[]

Get all webhooks for a channel

Parameters

ParameterType
channelIdstring

Returns

MockWebhook[]

Implementation of

SessionState.getWebhooksForChannel


getWebhooksForGuild()

getWebhooksForGuild(guildId): MockWebhook[]

Get all webhooks for a guild

Parameters

ParameterType
guildIdstring

Returns

MockWebhook[]

Implementation of

SessionState.getWebhooksForGuild


incrementThreadMessageCount()

incrementThreadMessageCount(threadId): void

Increment thread message count and update activity timestamp

Parameters

ParameterType
threadIdstring

Returns

void

Implementation of

SessionState.incrementThreadMessageCount


isBanned()

isBanned(guildId, userId): boolean

Check if a user is banned from a guild

Parameters

ParameterType
guildIdstring
userIdstring

Returns

boolean

Implementation of

SessionState.isBanned


isForumChannel()

isForumChannel(channelId): boolean

Check if a channel is a forum or media channel (type 15 or 16)

Parameters

ParameterType
channelIdstring

Returns

boolean

Implementation of

SessionState.isForumChannel


isForumThread()

isForumThread(threadId): boolean

Check if a thread is a forum thread (has applied_tags)

Parameters

ParameterType
threadIdstring

Returns

boolean

Implementation of

SessionState.isForumThread


isThread()

isThread(channelId): boolean

Check if a channel is a thread type (10, 11, or 12)

Parameters

ParameterType
channelIdstring

Returns

boolean

Implementation of

SessionState.isThread


nextSequence()

nextSequence(): number

Get and increment the sequence number

Returns

number

Implementation of

SessionState.nextSequence


removeBan()

removeBan(guildId, userId): boolean

Remove a ban for a user in a guild

Parameters

ParameterType
guildIdstring
userIdstring

Returns

boolean

true if removed, false if not found

Implementation of

SessionState.removeBan


removeChannel()

removeChannel(id): boolean

Remove a channel from the state

Parameters

ParameterType
idstring

Returns

boolean

Implementation of

SessionState.removeChannel


removeForumTag()

removeForumTag(channelId, tagId): boolean

Remove a tag from a forum channel

Parameters

ParameterType
channelIdstring
tagIdstring

Returns

boolean

Implementation of

SessionState.removeForumTag


removeGuild()

removeGuild(id): boolean

Remove a guild from the state

Parameters

ParameterType
idstring

Returns

boolean

Implementation of

SessionState.removeGuild


removeGuildMember()

removeGuildMember(guildId, userId): boolean

Remove a member from a guild

Parameters

ParameterType
guildIdstring
userIdstring

Returns

boolean

true if removed, false if not found

Implementation of

SessionState.removeGuildMember


removeInteraction()

removeInteraction(id): boolean

Remove an interaction from the state

Parameters

ParameterType
idstring

Returns

boolean

Implementation of

SessionState.removeInteraction


removeMemberRole()

removeMemberRole(
   guildId, 
   userId, 
   roleId): boolean

Remove a role from a member

Parameters

ParameterType
guildIdstring
userIdstring
roleIdstring

Returns

boolean

true if removed, false if member not found or doesn't have role

Implementation of

SessionState.removeMemberRole


removePollVote()

removePollVote(
   messageId, 
   userId, 
   answerId): boolean

Remove a vote from a poll (only for multiselect polls)

Parameters

ParameterType
messageIdstring
userIdstring
answerIdnumber

Returns

boolean

true if vote was removed, false if not voted or invalid

Implementation of

SessionState.removePollVote


removeReaction()

removeReaction(
   messageId, 
   userId, 
   emoji): undefined | MockReaction[]

Remove a reaction from a message Returns the updated reactions array or undefined if message/reaction not found

Parameters

ParameterType
messageIdstring
userIdstring
emoji{ id: null | string; name: string; }
emoji.idnull | string
emoji.namestring

Returns

undefined | MockReaction[]

Implementation of

SessionState.removeReaction


removeScheduledEventSubscriber()

removeScheduledEventSubscriber(
   guildId, 
   eventId, 
   userId): boolean

Remove a subscriber from a scheduled event

Parameters

ParameterType
guildIdstring
eventIdstring
userIdstring

Returns

boolean

true if removed, false if event not found or user wasn't subscribed

Implementation of

SessionState.removeScheduledEventSubscriber


removeThreadMember()

removeThreadMember(threadId, userId): boolean

Remove a member from a thread

Parameters

ParameterType
threadIdstring
userIdstring

Returns

boolean

Implementation of

SessionState.removeThreadMember


removeUser()

removeUser(id): boolean

Remove a user from the state (cannot remove bot user)

Parameters

ParameterType
idstring

Returns

boolean

Implementation of

SessionState.removeUser


reset()

reset(): void

Reset state to initial values (keeps bot user)

Returns

void

Implementation of

SessionState.reset


serialize()

serialize(): SerializedSessionState

Serialize state for API responses

Returns

SerializedSessionState

Implementation of

SessionState.serialize


setChannelOverwrite()

setChannelOverwrite(channelId, overwrite): boolean

Set a permission overwrite on a channel Creates or updates the overwrite for the given role/member ID

Parameters

ParameterType
channelIdstring
overwriteMockChannelOverwrite

Returns

boolean

Implementation of

SessionState.setChannelOverwrite


storeAttachment()

storeAttachment(attachment): void

Store an attachment using the configured storage backend.

Parameters

ParameterType
attachmentStoredAttachment

Returns

void

Implementation of

SessionState.storeAttachment


switchCurrentUser()

switchCurrentUser(userId): undefined | MockUser

Switch to a different user as the current user. Returns the user if found, undefined otherwise.

Parameters

ParameterType
userIdstring

Returns

undefined | MockUser

Implementation of

SessionState.switchCurrentUser


updateAutoModRule()

updateAutoModRule(
   guildId, 
   ruleId, 
   updates): null | MockAutoModRule

Update an auto-mod rule

Parameters

ParameterType
guildIdstring
ruleIdstring
updatesMockAutoModRuleUpdateConfig

Returns

null | MockAutoModRule

The updated rule, or null if not found

Implementation of

SessionState.updateAutoModRule


updateCommand()

updateCommand(commandId, updates): null | MockApplicationCommand

Update an existing command

Parameters

ParameterType
commandIdstring
updatesPartial<MockApplicationCommandConfig>

Returns

null | MockApplicationCommand

The updated command, or null if not found

Implementation of

SessionState.updateCommand


updateCurrentUser()

updateCurrentUser(updates): MockUser

Update the current user's properties without changing their ID.

Parameters

ParameterType
updatesPartial<Omit<MockUser, "id">>

Returns

MockUser

Implementation of

SessionState.updateCurrentUser


updateForumTag()

updateForumTag(
   channelId, 
   tagId, 
   updates): undefined | MockForumTag

Update a tag in a forum channel

Parameters

ParameterType
channelIdstring
tagIdstring
updatesPartial<Omit<MockForumTag, "id">>

Returns

undefined | MockForumTag

Implementation of

SessionState.updateForumTag


updateForumThreadTags()

updateForumThreadTags(threadId, appliedTags): undefined | MockForumThread

Update applied tags on a forum thread

Parameters

ParameterType
threadIdstring
appliedTagsstring[]

Returns

undefined | MockForumThread

Implementation of

SessionState.updateForumThreadTags


updateGuildEmoji()

updateGuildEmoji(emojiId, updates): null | MockEmoji

Update a guild emoji

Parameters

ParameterType
emojiIdstring
updates{ name: string; roles: string[]; }
updates.name?string
updates.roles?string[]

Returns

null | MockEmoji

The updated emoji, or null if not found

Implementation of

SessionState.updateGuildEmoji


updateGuildMember()

updateGuildMember(
   guildId, 
   userId, 
   updates): null | MockGuildMember

Update a guild member

Parameters

ParameterType
guildIdstring
userIdstring
updatesPartial<MockGuildMemberConfig>

Returns

null | MockGuildMember

The updated member, or null if not found

Implementation of

SessionState.updateGuildMember


updateGuildRole()

updateGuildRole(
   guildId, 
   roleId, 
   updates, 
   reason?): null | MockRole

Update a role

Parameters

ParameterType
guildIdstring
roleIdstring
updatesPartial<MockRoleConfig>
reason?string

Returns

null | MockRole

The updated role, or null if not found

Implementation of

SessionState.updateGuildRole


updateGuildRolePositions()

updateGuildRolePositions(guildId, positions): MockRole[]

Update role positions in batch

Parameters

ParameterType
guildIdstring
positions{ id: string; position: number; }[]

Returns

MockRole[]

The updated roles

Implementation of

SessionState.updateGuildRolePositions


updateGuildSticker()

updateGuildSticker(stickerId, updates): null | MockSticker

Update a guild sticker

Parameters

ParameterType
stickerIdstring
updates{ description: string; name: string; tags: string; }
updates.description?string
updates.name?string
updates.tags?string

Returns

null | MockSticker

The updated sticker, or null if not found

Implementation of

SessionState.updateGuildSticker


updateMessage()

updateMessage(id, updates): undefined | MockMessage

Update a message

Parameters

ParameterType
idstring
updatesPartial<MockMessage>

Returns

undefined | MockMessage

Implementation of

SessionState.updateMessage


updatePollResults()

updatePollResults(messageId): void

Update poll results based on current votes

Parameters

ParameterType
messageIdstring

Returns

void

Implementation of

SessionState.updatePollResults


updateScheduledEvent()

updateScheduledEvent(
   guildId, 
   eventId, 
   updates): null | MockScheduledEvent

Update a scheduled event

Parameters

ParameterType
guildIdstring
eventIdstring
updatesMockScheduledEventUpdateConfig

Returns

null | MockScheduledEvent

The updated event, or null if not found

Implementation of

SessionState.updateScheduledEvent


updateStageInstance()

updateStageInstance(channelId, updates): null | MockStageInstance

Update a stage instance

Parameters

ParameterType
channelIdstring
updates{ privacyLevel: StageInstancePrivacyLevel; topic: string; }
updates.privacyLevel?StageInstancePrivacyLevel
updates.topic?string

Returns

null | MockStageInstance

The updated stage instance, or null if not found

Implementation of

SessionState.updateStageInstance


updateThread()

updateThread(threadId, updates): undefined | MockThread

Update thread metadata

Parameters

ParameterType
threadIdstring
updatesPartial<{ archived: boolean; auto_archive_duration: 60 | 1440 | 4320 | 10080; invitable: boolean; locked: boolean; name: string; rateLimitPerUser: number; }>

Returns

undefined | MockThread

Implementation of

SessionState.updateThread


updateWebhook()

updateWebhook(webhookId, updates): null | MockWebhook

Update a webhook

Parameters

ParameterType
webhookIdstring
updates{ avatar: null | string; channel_id: string; name: string; }
updates.avatar?null | string
updates.channel_id?string
updates.name?string

Returns

null | MockWebhook

The updated webhook, or null if not found

Implementation of

SessionState.updateWebhook


useInvite()

useInvite(code): boolean

Increment invite use count (when someone joins via invite)

Parameters

ParameterType
codestring

Returns

boolean

true if invite is still valid, false if expired/maxed out

Implementation of

SessionState.useInvite

On this page

Class: MockServerState
Implements
Constructors
new MockServerState()
Parameters
Returns
Properties
Accessors
currentUser
Get Signature
Returns
Set Signature
Parameters
Returns
Implementation of
sequence
Get Signature
Returns
Set Signature
Parameters
Returns
Implementation of
Methods
addChannel()
Parameters
Returns
Implementation of
addChannelToGuild()
Parameters
Returns
Implementation of
addForumTag()
Parameters
Returns
Implementation of
addGuild()
Parameters
Returns
Implementation of
addInteraction()
Parameters
Returns
Implementation of
addMemberRole()
Parameters
Returns
Implementation of
addMemberToGuild()
Parameters
Returns
addPollVote()
Parameters
Returns
Implementation of
addReaction()
Parameters
Returns
Implementation of
addScheduledEventSubscriber()
Parameters
Returns
Implementation of
addSticker()
Parameters
Returns
Implementation of
addThreadMember()
Parameters
Returns
Implementation of
addUser()
Parameters
Returns
Implementation of
bulkOverwriteCommands()
Parameters
Returns
Implementation of
checkAutoArchiveThreads()
Returns
Implementation of
checkPollExpiry()
Parameters
Returns
Implementation of
cleanupExpiredInteractions()
Returns
Implementation of
createAuditLogEntry()
Parameters
Returns
Implementation of
createAutoModRule()
Parameters
Returns
Implementation of
createBan()
Parameters
Returns
Implementation of
createCommand()
Parameters
Returns
Implementation of
createEveryoneRole()
Parameters
Returns
Everyone
Implementation of
createForumChannel()
Parameters
Returns
Implementation of
createForumPost()
Parameters
Returns
Implementation of
createGuildEmoji()
Parameters
Returns
Implementation of
createGuildMember()
Parameters
Returns
Implementation of
createGuildRole()
Parameters
Returns
Implementation of
createGuildSticker()
Parameters
Returns
Implementation of
createInvite()
Parameters
Returns
Implementation of
createMessage()
Parameters
Returns
Implementation of
createScheduledEvent()
Parameters
Returns
Implementation of
createStageInstance()
Parameters
Returns
Implementation of
createThread()
Parameters
Returns
Implementation of
createWebhook()
Parameters
Returns
Implementation of
deleteAttachment()
Parameters
Returns
Implementation of
deleteAutoModRule()
Parameters
Returns
Implementation of
deleteChannelOverwrite()
Parameters
Returns
Implementation of
deleteCommand()
Parameters
Returns
Implementation of
deleteGuildEmoji()
Parameters
Returns
Implementation of
deleteGuildRole()
Parameters
Returns
Everyone
Implementation of
deleteGuildSticker()
Parameters
Returns
Implementation of
deleteInvite()
Parameters
Returns
Implementation of
deleteMessage()
Parameters
Returns
Implementation of
deleteScheduledEvent()
Parameters
Returns
Implementation of
deleteStageInstance()
Parameters
Returns
Implementation of
deleteThread()
Parameters
Returns
Implementation of
deleteWebhook()
Parameters
Returns
Implementation of
expirePoll()
Parameters
Returns
Implementation of
findCommandByName()
Parameters
Returns
Implementation of
getActiveThreadsForGuild()
Parameters
Returns
Implementation of
getAttachment()
Parameters
Returns
Implementation of
getAttachmentsForMessage()
Parameters
Returns
Implementation of
getAuditLogEntries()
Parameters
Returns
Implementation of
getAutoModRule()
Parameters
Returns
Implementation of
getBan()
Parameters
Returns
Implementation of
getChannel()
Parameters
Returns
Implementation of
getChannelInvites()
Parameters
Returns
Implementation of
getChannelOverwrites()
Parameters
Returns
Implementation of
getChannelsForGuild()
Parameters
Returns
Implementation of
getCommand()
Parameters
Returns
Implementation of
getDMChannel()
Parameters
Returns
Implementation of
getEmoji()
Parameters
Returns
Implementation of
getForumChannel()
Parameters
Returns
Implementation of
getForumChannelsForGuild()
Parameters
Returns
Implementation of
getForumPosts()
Parameters
Returns
Implementation of
getForumThread()
Parameters
Returns
Implementation of
getGlobalCommands()
Returns
Implementation of
getGuild()
Parameters
Returns
Implementation of
getGuildAutoModRules()
Parameters
Returns
Implementation of
getGuildBans()
Parameters
Returns
Implementation of
getGuildCommands()
Parameters
Returns
Implementation of
getGuildEmojis()
Parameters
Returns
Implementation of
getGuildInvites()
Parameters
Returns
Implementation of
getGuildMember()
Parameters
Returns
Implementation of
getGuildMembers()
Parameters
Returns
Implementation of
getGuildRole()
Parameters
Returns
Implementation of
getGuildRoles()
Parameters
Returns
Implementation of
getGuildScheduledEvents()
Parameters
Returns
Implementation of
getGuildStageInstances()
Parameters
Returns
Implementation of
getGuildStickers()
Parameters
Returns
Implementation of
getInteraction()
Parameters
Returns
Implementation of
getInteractionByToken()
Parameters
Returns
Implementation of
getInvite()
Parameters
Returns
Implementation of
getMessage()
Parameters
Returns
Implementation of
getMessagesForChannel()
Parameters
Returns
Implementation of
getOrCreateDMChannel()
Parameters
Returns
Implementation of
getOrCreateTestUser()
Parameters
Returns
Implementation of
getPollVoters()
Parameters
Returns
Implementation of
getRole()
Parameters
Returns
Implementation of
getScheduledEvent()
Parameters
Returns
Implementation of
getScheduledEventSubscribers()
Parameters
Returns
Implementation of
getStageInstance()
Parameters
Returns
Implementation of
getSticker()
Parameters
Returns
Implementation of
getThread()
Parameters
Returns
Implementation of
getThreadMember()
Parameters
Returns
Implementation of
getThreadMembers()
Parameters
Returns
Implementation of
getThreadsForChannel()
Parameters
Returns
Implementation of
getUser()
Parameters
Returns
Implementation of
getUserPollVotes()
Parameters
Returns
Implementation of
getWebhook()
Parameters
Returns
Implementation of
getWebhookByToken()
Parameters
Returns
Implementation of
getWebhooksForChannel()
Parameters
Returns
Implementation of
getWebhooksForGuild()
Parameters
Returns
Implementation of
incrementThreadMessageCount()
Parameters
Returns
Implementation of
isBanned()
Parameters
Returns
Implementation of
isForumChannel()
Parameters
Returns
Implementation of
isForumThread()
Parameters
Returns
Implementation of
isThread()
Parameters
Returns
Implementation of
nextSequence()
Returns
Implementation of
removeBan()
Parameters
Returns
Implementation of
removeChannel()
Parameters
Returns
Implementation of
removeForumTag()
Parameters
Returns
Implementation of
removeGuild()
Parameters
Returns
Implementation of
removeGuildMember()
Parameters
Returns
Implementation of
removeInteraction()
Parameters
Returns
Implementation of
removeMemberRole()
Parameters
Returns
Implementation of
removePollVote()
Parameters
Returns
Implementation of
removeReaction()
Parameters
Returns
Implementation of
removeScheduledEventSubscriber()
Parameters
Returns
Implementation of
removeThreadMember()
Parameters
Returns
Implementation of
removeUser()
Parameters
Returns
Implementation of
reset()
Returns
Implementation of
serialize()
Returns
Implementation of
setChannelOverwrite()
Parameters
Returns
Implementation of
storeAttachment()
Parameters
Returns
Implementation of
switchCurrentUser()
Parameters
Returns
Implementation of
updateAutoModRule()
Parameters
Returns
Implementation of
updateCommand()
Parameters
Returns
Implementation of
updateCurrentUser()
Parameters
Returns
Implementation of
updateForumTag()
Parameters
Returns
Implementation of
updateForumThreadTags()
Parameters
Returns
Implementation of
updateGuildEmoji()
Parameters
Returns
Implementation of
updateGuildMember()
Parameters
Returns
Implementation of
updateGuildRole()
Parameters
Returns
Implementation of
updateGuildRolePositions()
Parameters
Returns
Implementation of
updateGuildSticker()
Parameters
Returns
Implementation of
updateMessage()
Parameters
Returns
Implementation of
updatePollResults()
Parameters
Returns
Implementation of
updateScheduledEvent()
Parameters
Returns
Implementation of
updateStageInstance()
Parameters
Returns
Implementation of
updateThread()
Parameters
Returns
Implementation of
updateWebhook()
Parameters
Returns
Implementation of
useInvite()
Parameters
Returns
Implementation of