MockServerState
Class: MockServerState
Centralized state management for a mock session. Provides CRUD methods for all mock entities.
Implements
Constructors
new MockServerState()
new MockServerState(options?): MockServerStateParameters
| Parameter | Type |
|---|---|
options? | StateOptions |
Returns
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
applicationEmojis | readonly | Map<string, MockEmoji> | - |
applicationId | readonly | string | - |
attachmentStorage | readonly | MemoryAttachmentStorage | Attachment storage backend. See - AttachmentStorage for the interface - MemoryAttachmentStorage for the default implementation |
auditLogs | readonly | Map<string, MockAuditLogEntry[]> | - |
autoModRules | readonly | Map<string, MockAutoModRule> | - |
bans | readonly | Map<string, MockBan> | - |
botUser | readonly | MockUser | - |
channels | readonly | Map<string, MockChannel> | - |
commandPermissions | readonly | Map<string, MockCommandPermission[]> | - |
commands | readonly | Map<string, MockApplicationCommand> | - |
dmChannels | readonly | Map<string, MockChannel> | - |
emojis | readonly | Map<string, MockEmoji> | - |
guildMembers | readonly | Map<string, MockGuildMember> | - |
guilds | readonly | Map<string, MockGuild> | - |
interactions | readonly | Map<string, MockInteraction> | - |
invites | readonly | Map<string, MockInvite> | - |
messages | readonly | Map<string, MockMessage> | - |
pollVotes | readonly | Map<string, Map<string, number[]>> | - |
roles | readonly | Map<string, MockRole> | - |
scheduledEvents | readonly | Map<string, MockScheduledEvent> | - |
stageInstances | readonly | Map<string, MockStageInstance> | - |
stickers | readonly | Map<string, MockSticker> | - |
threadMembers | readonly | Map<string, Map<string, MockThreadMember>> | - |
users | readonly | Map<string, MockUser> | - |
voiceStates | readonly | Map<string, MockVoiceState> | - |
webhooks | readonly | Map<string, MockWebhook> | - |
Accessors
currentUser
Get Signature
get currentUser(): MockUserGet the current acting user for Stage UI interactions. Creates a default user on first access if none is set.
Returns
Set Signature
set currentUser(user): voidSet the current acting user.
Parameters
| Parameter | Type |
|---|---|
user | MockUser |
Returns
void
Current "acting" user for Stage UI interactions (separate from botUser)
Implementation of
sequence
Get Signature
get sequence(): numberReturns
number
Set Signature
set sequence(value): voidParameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Implementation of
Methods
addChannel()
addChannel(channel): voidAdd a channel to the state
Parameters
| Parameter | Type |
|---|---|
channel | MockChannel |
Returns
void
Implementation of
addChannelToGuild()
addChannelToGuild(guildId, channel): voidAdd a channel to a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
channel | MockChannel |
Returns
void
Implementation of
SessionState.addChannelToGuild
addForumTag()
addForumTag(channelId, tag): undefined | MockForumTagAdd a tag to a forum channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
tag | Omit<MockForumTag, "id"> |
Returns
undefined | MockForumTag
Implementation of
addGuild()
addGuild(guild): voidAdd a guild to the state
Parameters
| Parameter | Type |
|---|---|
guild | MockGuild |
Returns
void
Implementation of
addInteraction()
addInteraction(interaction): voidAdd an interaction to the state
Parameters
| Parameter | Type |
|---|---|
interaction | MockInteraction |
Returns
void
Implementation of
addMemberRole()
addMemberRole(
guildId,
userId,
roleId): booleanAdd a role to a member
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
roleId | string |
Returns
boolean
true if added, false if member/role not found or already has role
Implementation of
addMemberToGuild()
addMemberToGuild(
guildId,
userId,
config?): voidAdd a user as a member to a guild. Creates the guild member entry if it doesn't exist.
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
config? | Partial<MockGuildMemberConfig> |
Returns
void
addPollVote()
addPollVote(
messageId,
userId,
answerId): booleanAdd a vote to a poll
Parameters
| Parameter | Type |
|---|---|
messageId | string |
userId | string |
answerId | number |
Returns
boolean
true if vote was added, false if already voted (single-select) or invalid
Implementation of
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
| Parameter | Type |
|---|---|
messageId | string |
userId | string |
emoji | { id: null | string; name: string; } |
emoji.id | null | string |
emoji.name | string |
Returns
undefined | MockReaction[]
Implementation of
addScheduledEventSubscriber()
addScheduledEventSubscriber(
guildId,
eventId,
userId): booleanAdd a subscriber to a scheduled event
Parameters
| Parameter | Type |
|---|---|
guildId | string |
eventId | string |
userId | string |
Returns
boolean
true if added, false if event not found
Implementation of
SessionState.addScheduledEventSubscriber
addSticker()
addSticker(sticker): voidAdd a sticker directly to state (for control API) This allows adding standard/nitro stickers without a guild
Parameters
| Parameter | Type |
|---|---|
sticker | MockSticker |
Returns
void
Implementation of
addThreadMember()
addThreadMember(threadId, userId): undefined | MockThreadMemberAdd a member to a thread
Parameters
| Parameter | Type |
|---|---|
threadId | string |
userId | string |
Returns
undefined | MockThreadMember
Implementation of
addUser()
addUser(user): voidAdd a user to the state
Parameters
| Parameter | Type |
|---|---|
user | MockUser |
Returns
void
Implementation of
bulkOverwriteCommands()
bulkOverwriteCommands(configs, guildId?): null | MockApplicationCommand[]Bulk overwrite commands for a scope (global or guild) Replaces all existing commands with the provided ones
Parameters
| Parameter | Type |
|---|---|
configs | MockApplicationCommandConfig[] |
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): booleanCheck if a poll has expired and finalize it
Parameters
| Parameter | Type |
|---|---|
messageId | string |
Returns
boolean
true if poll was expired
Implementation of
cleanupExpiredInteractions()
cleanupExpiredInteractions(): voidCleanup expired interactions (older than 15 minutes)
Returns
void
Implementation of
SessionState.cleanupExpiredInteractions
createAuditLogEntry()
createAuditLogEntry(guildId, config): MockAuditLogEntryCreate an audit log entry for a guild
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild ID |
config | MockAuditLogEntryConfig | The audit log entry configuration |
Returns
MockAuditLogEntry
The created audit log entry
Implementation of
SessionState.createAuditLogEntry
createAutoModRule()
createAutoModRule(
guildId,
config,
creatorId): null | MockAutoModRuleCreate an auto-mod rule
Parameters
| Parameter | Type |
|---|---|
guildId | string |
config | MockAutoModRuleConfig |
creatorId | string |
Returns
null | MockAutoModRule
The created rule, or null if validation fails
Implementation of
SessionState.createAutoModRule
createBan()
createBan(
guildId,
userId,
config?): null | MockBanCreate a ban for a user in a guild Also removes the member from the guild if they're a member
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
config? | MockBanConfig |
Returns
null | MockBan
The created ban, or null if guild doesn't exist
Implementation of
createCommand()
createCommand(config, guildId?): null | MockApplicationCommandCreate a new application command
Parameters
| Parameter | Type |
|---|---|
config | MockApplicationCommandConfig |
guildId? | string |
Returns
null | MockApplicationCommand
The created command, or null if validation fails
Implementation of
createEveryoneRole()
createEveryoneRole(guildId): MockRoleCreate the
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
Everyone
role for a guild Called automatically when a guild is created
Implementation of
SessionState.createEveryoneRole
createForumChannel()
createForumChannel(config): MockForumChannelCreate a forum or media channel
Parameters
| Parameter | Type |
|---|---|
config | MockForumChannelConfig |
Returns
Implementation of
SessionState.createForumChannel
createForumPost()
createForumPost(config): {
message: MockMessage;
thread: MockForumThread;
}Create a forum post (thread with initial message)
Parameters
| Parameter | Type |
|---|---|
config | MockForumPostConfig |
Returns
{
message: MockMessage;
thread: MockForumThread;
}| Name | Type |
|---|---|
message | MockMessage |
thread | MockForumThread |
Implementation of
createGuildEmoji()
createGuildEmoji(
guildId,
config,
uploaderId): null | MockEmojiCreate a guild emoji
Parameters
| Parameter | Type |
|---|---|
guildId | string |
config | MockEmojiConfig |
uploaderId | string |
Returns
null | MockEmoji
The created emoji, or null if guild doesn't exist or limit reached
Implementation of
createGuildMember()
createGuildMember(
guildId,
userId,
config?): null | MockGuildMemberCreate or add a member to a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
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 | MockRoleCreate a new role in a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
config? | MockRoleConfig |
Returns
null | MockRole
The created role, or null if guild doesn't exist or limit reached
Implementation of
createGuildSticker()
createGuildSticker(
guildId,
config,
uploaderId): null | MockStickerCreate a guild sticker
Parameters
| Parameter | Type |
|---|---|
guildId | string |
config | MockStickerConfig |
uploaderId | string |
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 | MockInviteCreate an invite for a channel
Parameters
| Parameter | Type |
|---|---|
guildId | string |
channelId | string |
config | MockInviteConfig |
inviterId | string |
Returns
null | MockInvite
The created invite, or null if channel doesn't exist
Implementation of
createMessage()
createMessage(config): MockMessageCreate and store a message
Parameters
| Parameter | Type |
|---|---|
config | MockMessageConfig |
Returns
Implementation of
createScheduledEvent()
createScheduledEvent(
guildId,
config,
creatorId): null | MockScheduledEventCreate a scheduled event
Parameters
| Parameter | Type |
|---|---|
guildId | string |
config | MockScheduledEventConfig |
creatorId | string |
Returns
null | MockScheduledEvent
The created event, or null if validation fails
Implementation of
SessionState.createScheduledEvent
createStageInstance()
createStageInstance(guildId, config): null | MockStageInstanceCreate a stage instance
Parameters
| Parameter | Type |
|---|---|
guildId | string |
config | MockStageInstanceConfig |
Returns
null | MockStageInstance
The created stage instance, or null if validation fails
Implementation of
SessionState.createStageInstance
createThread()
createThread(config): MockThreadCreate a thread channel
Parameters
| Parameter | Type |
|---|---|
config | MockThreadConfig |
Returns
Implementation of
createWebhook()
createWebhook(
channelId,
config,
creatorId): null | MockWebhookCreate a webhook
Parameters
| Parameter | Type |
|---|---|
channelId | string |
config | MockWebhookConfig |
creatorId | string |
Returns
null | MockWebhook
The created webhook, or null if channel doesn't exist or limit reached
Implementation of
deleteAttachment()
deleteAttachment(id): booleanDelete an attachment by ID.
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
Implementation of
deleteAutoModRule()
deleteAutoModRule(guildId, ruleId): null | MockAutoModRuleDelete an auto-mod rule
Parameters
| Parameter | Type |
|---|---|
guildId | string |
ruleId | string |
Returns
null | MockAutoModRule
The deleted rule, or null if not found
Implementation of
SessionState.deleteAutoModRule
deleteChannelOverwrite()
deleteChannelOverwrite(channelId, overwriteId): booleanDelete a permission overwrite from a channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
overwriteId | string |
Returns
boolean
true if deleted, false if not found
Implementation of
SessionState.deleteChannelOverwrite
deleteCommand()
deleteCommand(commandId): booleanDelete a command by ID
Parameters
| Parameter | Type |
|---|---|
commandId | string |
Returns
boolean
true if deleted, false if not found
Implementation of
deleteGuildEmoji()
deleteGuildEmoji(emojiId): booleanDelete a guild emoji
Parameters
| Parameter | Type |
|---|---|
emojiId | string |
Returns
boolean
true if deleted, false if not found
Implementation of
deleteGuildRole()
deleteGuildRole(
guildId,
roleId,
reason?): booleanDelete a role from a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
roleId | string |
reason? | string |
Returns
boolean
true if deleted, false if not found or cannot delete
Everyone
Implementation of
deleteGuildSticker()
deleteGuildSticker(stickerId): booleanDelete a guild sticker
Parameters
| Parameter | Type |
|---|---|
stickerId | string |
Returns
boolean
true if deleted, false if not found
Implementation of
SessionState.deleteGuildSticker
deleteInvite()
deleteInvite(code): null | MockInviteDelete an invite by code
Parameters
| Parameter | Type |
|---|---|
code | string |
Returns
null | MockInvite
The deleted invite, or null if not found
Implementation of
deleteMessage()
deleteMessage(id): booleanDelete a message and its associated attachments
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
Implementation of
deleteScheduledEvent()
deleteScheduledEvent(guildId, eventId): booleanDelete a scheduled event
Parameters
| Parameter | Type |
|---|---|
guildId | string |
eventId | string |
Returns
boolean
true if deleted, false if not found
Implementation of
SessionState.deleteScheduledEvent
deleteStageInstance()
deleteStageInstance(channelId): null | MockStageInstanceDelete a stage instance
Parameters
| Parameter | Type |
|---|---|
channelId | string |
Returns
null | MockStageInstance
The deleted stage instance, or null if not found
Implementation of
SessionState.deleteStageInstance
deleteThread()
deleteThread(threadId): booleanDelete a thread
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
boolean
Implementation of
deleteWebhook()
deleteWebhook(webhookId): booleanDelete a webhook
Parameters
| Parameter | Type |
|---|---|
webhookId | string |
Returns
boolean
true if deleted, false if not found
Implementation of
expirePoll()
expirePoll(messageId): booleanExpire (finalize) a poll
Parameters
| Parameter | Type |
|---|---|
messageId | string |
Returns
boolean
true if poll was expired, false if already expired or no poll
Implementation of
findCommandByName()
findCommandByName(name, guildId?): undefined | MockApplicationCommandFind a command by name within a scope (global or guild)
Parameters
| Parameter | Type |
|---|---|
name | string |
guildId? | string |
Returns
undefined | MockApplicationCommand
Implementation of
SessionState.findCommandByName
getActiveThreadsForGuild()
getActiveThreadsForGuild(guildId): MockThread[]Get all active (non-archived) threads in a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
Implementation of
SessionState.getActiveThreadsForGuild
getAttachment()
getAttachment(id): undefined | StoredAttachmentGet an attachment by ID.
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | StoredAttachment
Implementation of
getAttachmentsForMessage()
getAttachmentsForMessage(messageId): StoredAttachment[]Get all attachments for a message.
Parameters
| Parameter | Type |
|---|---|
messageId | string |
Returns
Implementation of
SessionState.getAttachmentsForMessage
getAuditLogEntries()
getAuditLogEntries(guildId, options?): MockAuditLogEntry[]Get audit log entries for a guild with optional filtering
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The 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 | MockAutoModRuleGet an auto-mod rule by ID
Parameters
| Parameter | Type |
|---|---|
guildId | string |
ruleId | string |
Returns
undefined | MockAutoModRule
Implementation of
getBan()
getBan(guildId, userId): undefined | MockBanGet a ban for a specific user in a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
Returns
undefined | MockBan
Implementation of
getChannel()
getChannel(id): undefined | MockChannelGet a channel by ID (includes guild channels and DM channels)
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockChannel
Implementation of
getChannelInvites()
getChannelInvites(channelId): MockInvite[]Get all invites for a channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
Returns
MockInvite[]
Implementation of
SessionState.getChannelInvites
getChannelOverwrites()
getChannelOverwrites(channelId): MockChannelOverwrite[]Get permission overwrites for a channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
Returns
Implementation of
SessionState.getChannelOverwrites
getChannelsForGuild()
getChannelsForGuild(guildId): MockChannel[]Get all channels for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
Implementation of
SessionState.getChannelsForGuild
getCommand()
getCommand(commandId): undefined | MockApplicationCommandGet a command by ID
Parameters
| Parameter | Type |
|---|---|
commandId | string |
Returns
undefined | MockApplicationCommand
Implementation of
getDMChannel()
getDMChannel(recipientId): undefined | MockChannelGet a DM channel by recipient user ID (uses currentUser as the other participant)
Parameters
| Parameter | Type |
|---|---|
recipientId | string |
Returns
undefined | MockChannel
Implementation of
getEmoji()
getEmoji(emojiId): undefined | MockEmojiGet an emoji by ID
Parameters
| Parameter | Type |
|---|---|
emojiId | string |
Returns
undefined | MockEmoji
Implementation of
getForumChannel()
getForumChannel(id): undefined | MockForumChannelGet a forum channel by ID (returns undefined if not a forum/media channel)
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockForumChannel
Implementation of
getForumChannelsForGuild()
getForumChannelsForGuild(guildId): MockForumChannel[]Get all forum/media channels in a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
Implementation of
SessionState.getForumChannelsForGuild
getForumPosts()
getForumPosts(forumChannelId, options?): MockForumThread[]Get posts (threads) in a forum channel
Parameters
| Parameter | Type |
|---|---|
forumChannelId | string |
options? | { archived: boolean; } |
options.archived? | boolean |
Returns
Implementation of
getForumThread()
getForumThread(id): undefined | MockForumThreadGet a forum thread by ID (returns undefined if not a forum thread)
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockForumThread
Implementation of
getGlobalCommands()
getGlobalCommands(): MockApplicationCommand[]Get all global commands (no guild_id)
Returns
MockApplicationCommand[]
Implementation of
SessionState.getGlobalCommands
getGuild()
getGuild(id): undefined | MockGuildGet a guild by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockGuild
Implementation of
getGuildAutoModRules()
getGuildAutoModRules(guildId): MockAutoModRule[]Get all auto-mod rules for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockAutoModRule[]
Implementation of
SessionState.getGuildAutoModRules
getGuildBans()
getGuildBans(guildId): MockBan[]Get all bans for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockBan[]
Implementation of
getGuildCommands()
getGuildCommands(guildId): MockApplicationCommand[]Get all commands for a specific guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockApplicationCommand[]
Implementation of
getGuildEmojis()
getGuildEmojis(guildId): MockEmoji[]Get all emojis for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockEmoji[]
Implementation of
getGuildInvites()
getGuildInvites(guildId): MockInvite[]Get all invites for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockInvite[]
Implementation of
getGuildMember()
getGuildMember(guildId, userId): undefined | MockGuildMemberGet a guild member
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
Returns
undefined | MockGuildMember
Implementation of
getGuildMembers()
getGuildMembers(guildId): MockGuildMember[]Get all members of a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
Implementation of
getGuildRole()
getGuildRole(guildId, roleId): undefined | MockRoleGet a role by ID within a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
roleId | string |
Returns
undefined | MockRole
Implementation of
getGuildRoles()
getGuildRoles(guildId): MockRole[]Get all roles for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockRole[]
Implementation of
getGuildScheduledEvents()
getGuildScheduledEvents(guildId): MockScheduledEvent[]Get all scheduled events for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockScheduledEvent[]
Implementation of
SessionState.getGuildScheduledEvents
getGuildStageInstances()
getGuildStageInstances(guildId): MockStageInstance[]Get all stage instances for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockStageInstance[]
Implementation of
SessionState.getGuildStageInstances
getGuildStickers()
getGuildStickers(guildId): MockSticker[]Get all stickers for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
MockSticker[]
Implementation of
getInteraction()
getInteraction(id): undefined | MockInteractionGet an interaction by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockInteraction
Implementation of
getInteractionByToken()
getInteractionByToken(token): undefined | MockInteractionGet an interaction by token
Parameters
| Parameter | Type |
|---|---|
token | string |
Returns
undefined | MockInteraction
Implementation of
SessionState.getInteractionByToken
getInvite()
getInvite(code): undefined | MockInviteGet an invite by code
Parameters
| Parameter | Type |
|---|---|
code | string |
Returns
undefined | MockInvite
Implementation of
getMessage()
getMessage(id): undefined | MockMessageGet a message by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockMessage
Implementation of
getMessagesForChannel()
getMessagesForChannel(channelId, limit?): MockMessage[]Get messages for a channel, optionally limited
Parameters
| Parameter | Type |
|---|---|
channelId | string |
limit? | number |
Returns
Implementation of
SessionState.getMessagesForChannel
getOrCreateDMChannel()
getOrCreateDMChannel(recipientId): MockChannelGet or create a DM channel for a recipient (uses currentUser as the other participant)
Parameters
| Parameter | Type |
|---|---|
recipientId | string |
Returns
Implementation of
SessionState.getOrCreateDMChannel
getOrCreateTestUser()
getOrCreateTestUser(userId?): MockUserGet or create a default test user for dispatching messages This creates a consistent "TestUser" that can be used when no author is specified
Parameters
| Parameter | Type |
|---|---|
userId? | string |
Returns
Implementation of
SessionState.getOrCreateTestUser
getPollVoters()
getPollVoters(messageId, answerId): string[]Get all users who voted for a specific answer
Parameters
| Parameter | Type |
|---|---|
messageId | string |
answerId | number |
Returns
string[]
Implementation of
getRole()
getRole(roleId): undefined | MockRoleGet a role by ID
Parameters
| Parameter | Type |
|---|---|
roleId | string |
Returns
undefined | MockRole
Implementation of
getScheduledEvent()
getScheduledEvent(guildId, eventId): undefined | MockScheduledEventGet a scheduled event by ID
Parameters
| Parameter | Type |
|---|---|
guildId | string |
eventId | string |
Returns
undefined | MockScheduledEvent
Implementation of
SessionState.getScheduledEvent
getScheduledEventSubscribers()
getScheduledEventSubscribers(
guildId,
eventId,
options?): {
member: MockGuildMember;
user: MockUser;
}[]Get subscribers for a scheduled event
Parameters
| Parameter | Type |
|---|---|
guildId | string |
eventId | string |
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 | MockStageInstanceGet a stage instance by channel ID
Parameters
| Parameter | Type |
|---|---|
channelId | string |
Returns
undefined | MockStageInstance
Implementation of
getSticker()
getSticker(stickerId): undefined | MockStickerGet a sticker by ID
Parameters
| Parameter | Type |
|---|---|
stickerId | string |
Returns
undefined | MockSticker
Implementation of
getThread()
getThread(id): undefined | MockThreadGet a thread by ID (returns undefined if not a thread)
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockThread
Implementation of
getThreadMember()
getThreadMember(threadId, userId): undefined | MockThreadMemberGet a thread member
Parameters
| Parameter | Type |
|---|---|
threadId | string |
userId | string |
Returns
undefined | MockThreadMember
Implementation of
getThreadMembers()
getThreadMembers(threadId): MockThreadMember[]Get all members of a thread
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
Implementation of
getThreadsForChannel()
getThreadsForChannel(channelId, options?): MockThread[]Get all threads for a parent channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
options? | { archived: boolean; } |
options.archived? | boolean |
Returns
Implementation of
SessionState.getThreadsForChannel
getUser()
getUser(id): undefined | MockUserGet a user by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | MockUser
Implementation of
getUserPollVotes()
getUserPollVotes(messageId, userId): number[]Get all votes for a user on a poll
Parameters
| Parameter | Type |
|---|---|
messageId | string |
userId | string |
Returns
number[]
Implementation of
getWebhook()
getWebhook(webhookId): undefined | MockWebhookGet a webhook by ID
Parameters
| Parameter | Type |
|---|---|
webhookId | string |
Returns
undefined | MockWebhook
Implementation of
getWebhookByToken()
getWebhookByToken(token): undefined | MockWebhookGet a webhook by its token
Parameters
| Parameter | Type |
|---|---|
token | string |
Returns
undefined | MockWebhook
Implementation of
SessionState.getWebhookByToken
getWebhooksForChannel()
getWebhooksForChannel(channelId): MockWebhook[]Get all webhooks for a channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
Returns
Implementation of
SessionState.getWebhooksForChannel
getWebhooksForGuild()
getWebhooksForGuild(guildId): MockWebhook[]Get all webhooks for a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
Returns
Implementation of
SessionState.getWebhooksForGuild
incrementThreadMessageCount()
incrementThreadMessageCount(threadId): voidIncrement thread message count and update activity timestamp
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
void
Implementation of
SessionState.incrementThreadMessageCount
isBanned()
isBanned(guildId, userId): booleanCheck if a user is banned from a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
Returns
boolean
Implementation of
isForumChannel()
isForumChannel(channelId): booleanCheck if a channel is a forum or media channel (type 15 or 16)
Parameters
| Parameter | Type |
|---|---|
channelId | string |
Returns
boolean
Implementation of
isForumThread()
isForumThread(threadId): booleanCheck if a thread is a forum thread (has applied_tags)
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
boolean
Implementation of
isThread()
isThread(channelId): booleanCheck if a channel is a thread type (10, 11, or 12)
Parameters
| Parameter | Type |
|---|---|
channelId | string |
Returns
boolean
Implementation of
nextSequence()
nextSequence(): numberGet and increment the sequence number
Returns
number
Implementation of
removeBan()
removeBan(guildId, userId): booleanRemove a ban for a user in a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
Returns
boolean
true if removed, false if not found
Implementation of
removeChannel()
removeChannel(id): booleanRemove a channel from the state
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
Implementation of
removeForumTag()
removeForumTag(channelId, tagId): booleanRemove a tag from a forum channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
tagId | string |
Returns
boolean
Implementation of
removeGuild()
removeGuild(id): booleanRemove a guild from the state
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
Implementation of
removeGuildMember()
removeGuildMember(guildId, userId): booleanRemove a member from a guild
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
Returns
boolean
true if removed, false if not found
Implementation of
SessionState.removeGuildMember
removeInteraction()
removeInteraction(id): booleanRemove an interaction from the state
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
Implementation of
SessionState.removeInteraction
removeMemberRole()
removeMemberRole(
guildId,
userId,
roleId): booleanRemove a role from a member
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
roleId | string |
Returns
boolean
true if removed, false if member not found or doesn't have role
Implementation of
removePollVote()
removePollVote(
messageId,
userId,
answerId): booleanRemove a vote from a poll (only for multiselect polls)
Parameters
| Parameter | Type |
|---|---|
messageId | string |
userId | string |
answerId | number |
Returns
boolean
true if vote was removed, false if not voted or invalid
Implementation of
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
| Parameter | Type |
|---|---|
messageId | string |
userId | string |
emoji | { id: null | string; name: string; } |
emoji.id | null | string |
emoji.name | string |
Returns
undefined | MockReaction[]
Implementation of
removeScheduledEventSubscriber()
removeScheduledEventSubscriber(
guildId,
eventId,
userId): booleanRemove a subscriber from a scheduled event
Parameters
| Parameter | Type |
|---|---|
guildId | string |
eventId | string |
userId | string |
Returns
boolean
true if removed, false if event not found or user wasn't subscribed
Implementation of
SessionState.removeScheduledEventSubscriber
removeThreadMember()
removeThreadMember(threadId, userId): booleanRemove a member from a thread
Parameters
| Parameter | Type |
|---|---|
threadId | string |
userId | string |
Returns
boolean
Implementation of
SessionState.removeThreadMember
removeUser()
removeUser(id): booleanRemove a user from the state (cannot remove bot user)
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
Implementation of
reset()
reset(): voidReset state to initial values (keeps bot user)
Returns
void
Implementation of
serialize()
serialize(): SerializedSessionStateSerialize state for API responses
Returns
Implementation of
setChannelOverwrite()
setChannelOverwrite(channelId, overwrite): booleanSet a permission overwrite on a channel Creates or updates the overwrite for the given role/member ID
Parameters
| Parameter | Type |
|---|---|
channelId | string |
overwrite | MockChannelOverwrite |
Returns
boolean
Implementation of
SessionState.setChannelOverwrite
storeAttachment()
storeAttachment(attachment): voidStore an attachment using the configured storage backend.
Parameters
| Parameter | Type |
|---|---|
attachment | StoredAttachment |
Returns
void
Implementation of
switchCurrentUser()
switchCurrentUser(userId): undefined | MockUserSwitch to a different user as the current user. Returns the user if found, undefined otherwise.
Parameters
| Parameter | Type |
|---|---|
userId | string |
Returns
undefined | MockUser
Implementation of
SessionState.switchCurrentUser
updateAutoModRule()
updateAutoModRule(
guildId,
ruleId,
updates): null | MockAutoModRuleUpdate an auto-mod rule
Parameters
| Parameter | Type |
|---|---|
guildId | string |
ruleId | string |
updates | MockAutoModRuleUpdateConfig |
Returns
null | MockAutoModRule
The updated rule, or null if not found
Implementation of
SessionState.updateAutoModRule
updateCommand()
updateCommand(commandId, updates): null | MockApplicationCommandUpdate an existing command
Parameters
| Parameter | Type |
|---|---|
commandId | string |
updates | Partial<MockApplicationCommandConfig> |
Returns
null | MockApplicationCommand
The updated command, or null if not found
Implementation of
updateCurrentUser()
updateCurrentUser(updates): MockUserUpdate the current user's properties without changing their ID.
Parameters
| Parameter | Type |
|---|---|
updates | Partial<Omit<MockUser, "id">> |
Returns
Implementation of
SessionState.updateCurrentUser
updateForumTag()
updateForumTag(
channelId,
tagId,
updates): undefined | MockForumTagUpdate a tag in a forum channel
Parameters
| Parameter | Type |
|---|---|
channelId | string |
tagId | string |
updates | Partial<Omit<MockForumTag, "id">> |
Returns
undefined | MockForumTag
Implementation of
updateForumThreadTags()
updateForumThreadTags(threadId, appliedTags): undefined | MockForumThreadUpdate applied tags on a forum thread
Parameters
| Parameter | Type |
|---|---|
threadId | string |
appliedTags | string[] |
Returns
undefined | MockForumThread
Implementation of
SessionState.updateForumThreadTags
updateGuildEmoji()
updateGuildEmoji(emojiId, updates): null | MockEmojiUpdate a guild emoji
Parameters
| Parameter | Type |
|---|---|
emojiId | string |
updates | { name: string; roles: string[]; } |
updates.name? | string |
updates.roles? | string[] |
Returns
null | MockEmoji
The updated emoji, or null if not found
Implementation of
updateGuildMember()
updateGuildMember(
guildId,
userId,
updates): null | MockGuildMemberUpdate a guild member
Parameters
| Parameter | Type |
|---|---|
guildId | string |
userId | string |
updates | Partial<MockGuildMemberConfig> |
Returns
null | MockGuildMember
The updated member, or null if not found
Implementation of
SessionState.updateGuildMember
updateGuildRole()
updateGuildRole(
guildId,
roleId,
updates,
reason?): null | MockRoleUpdate a role
Parameters
| Parameter | Type |
|---|---|
guildId | string |
roleId | string |
updates | Partial<MockRoleConfig> |
reason? | string |
Returns
null | MockRole
The updated role, or null if not found
Implementation of
updateGuildRolePositions()
updateGuildRolePositions(guildId, positions): MockRole[]Update role positions in batch
Parameters
| Parameter | Type |
|---|---|
guildId | string |
positions | { id: string; position: number; }[] |
Returns
MockRole[]
The updated roles
Implementation of
SessionState.updateGuildRolePositions
updateGuildSticker()
updateGuildSticker(stickerId, updates): null | MockStickerUpdate a guild sticker
Parameters
| Parameter | Type |
|---|---|
stickerId | string |
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 | MockMessageUpdate a message
Parameters
| Parameter | Type |
|---|---|
id | string |
updates | Partial<MockMessage> |
Returns
undefined | MockMessage
Implementation of
updatePollResults()
updatePollResults(messageId): voidUpdate poll results based on current votes
Parameters
| Parameter | Type |
|---|---|
messageId | string |
Returns
void
Implementation of
SessionState.updatePollResults
updateScheduledEvent()
updateScheduledEvent(
guildId,
eventId,
updates): null | MockScheduledEventUpdate a scheduled event
Parameters
| Parameter | Type |
|---|---|
guildId | string |
eventId | string |
updates | MockScheduledEventUpdateConfig |
Returns
null | MockScheduledEvent
The updated event, or null if not found
Implementation of
SessionState.updateScheduledEvent
updateStageInstance()
updateStageInstance(channelId, updates): null | MockStageInstanceUpdate a stage instance
Parameters
| Parameter | Type |
|---|---|
channelId | string |
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 | MockThreadUpdate thread metadata
Parameters
| Parameter | Type |
|---|---|
threadId | string |
updates | Partial<{ archived: boolean; auto_archive_duration: 60 | 1440 | 4320 | 10080; invitable: boolean; locked: boolean; name: string; rateLimitPerUser: number; }> |
Returns
undefined | MockThread
Implementation of
updateWebhook()
updateWebhook(webhookId, updates): null | MockWebhookUpdate a webhook
Parameters
| Parameter | Type |
|---|---|
webhookId | string |
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
useInvite()
useInvite(code): booleanIncrement invite use count (when someone joins via invite)
Parameters
| Parameter | Type |
|---|---|
code | string |
Returns
boolean
true if invite is still valid, false if expired/maxed out
