LogoRobo.js
Packages@robojs/mock

Session

Class: Session

Represents an isolated test session with its own state

Implements

Constructors

new Session()

new Session(options?): Session

Parameters

ParameterType
options?CreateSessionOptions

Returns

Session

Properties

PropertyModifierTypeDescription
config?readonlySessionConfig-
connectionsreadonlyMap<string, ConnectionState>-
createdAtreadonlynumber-
expiresAtreadonlynumber-
idreadonlystring-
logRecorderreadonlyLogRecorder-
name?readonlystring-
recorderreadonlyActionRecorder-
scenarioManagerreadonlyScenarioManager-
statereadonlyMockServerState-
tokenreadonlystring-
voiceServersreadonlyMap<string, VoiceServerState>Voice server state by guild ID Tracks active voice connections for @discordjs/voice support

Accessors

actionCount

Get Signature

get actionCount(): number

Get the number of recorded actions

Returns

number


heartbeatInterval

Get Signature

get heartbeatInterval(): null | number

Get the heartbeat interval for this session. Returns null if using the global gateway default.

Returns

null | number

Set Signature

set heartbeatInterval(interval): void

Set the heartbeat interval for new connections in this session. Set to null to use the global gateway default. Only affects NEW connections - existing connections keep their original interval.

Parameters
ParameterTypeDescription
intervalnull | numberHeartbeat interval in milliseconds (100-120000), or null for default
Returns

void


isEnding

Get Signature

get isEnding(): boolean

Check if session is ending

Returns

boolean

Implementation of

ISession.isEnding


isExpired

Get Signature

get isExpired(): boolean

Check if session has expired

Returns

boolean

Implementation of

ISession.isExpired


isLoopDetected

Get Signature

get isLoopDetected(): boolean

Check if a loop is currently detected (in cooldown)

Returns

boolean


isRateLimitSimulationActive

Get Signature

get isRateLimitSimulationActive(): boolean

Check if rate limit simulation is currently active (without consuming it)

Returns

boolean


loopProtectionEnabled

Get Signature

get loopProtectionEnabled(): boolean

Check if loop protection is enabled

Returns

boolean

Set Signature

set loopProtectionEnabled(enabled): void

Enable or disable loop protection. When disabled, the server will not detect or prevent event loops.

Parameters
ParameterType
enabledboolean
Returns

void


permissionEnforcement

Get Signature

get permissionEnforcement(): "none" | "basic" | "strict"

Get the current permission enforcement level. Falls back to config value if not set at runtime.

Returns

"none" | "basic" | "strict"

Set Signature

set permissionEnforcement(level): void

Set the permission enforcement level at runtime. Set to null to use the config default.

Parameters
ParameterType
levelnull | "none" | "basic" | "strict"
Returns

void


rateLimitConfig

Get Signature

get rateLimitConfig(): {
  enabled: boolean;
  persistent: boolean;
  retryAfter: number;
  scope: "all" | "messages" | "interactions" | "guilds" | "channels";
  triggeredCount: number;
}

Get the current rate limit configuration

Returns
{
  enabled: boolean;
  persistent: boolean;
  retryAfter: number;
  scope: "all" | "messages" | "interactions" | "guilds" | "channels";
  triggeredCount: number;
}
NameType
enabledboolean
persistentboolean
retryAfternumber
scope"all" | "messages" | "interactions" | "guilds" | "channels"
triggeredCountnumber

Methods

addPermissionOverride()

addPermissionOverride(override): PermissionOverride

Add a new permission override

Parameters

ParameterTypeDescription
overrideOmit<PermissionOverride, "id" | "createdAt"> & { id: string; }The override to add (id will be generated if not provided)

Returns

PermissionOverride

The added override with generated ID


asUser()

asUser<T>(userId, action): Promise<T>

Perform an action as a specific user (temporary switch) Restores the original current user after the action completes

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
userIdstringThe user ID to act as
action() => T | Promise<T>The action to perform

Returns

Promise<T>

The result of the action


checkRateLimit()

checkRateLimit(endpoint?): 
  | null
  | {
  retryAfter: number;
}

Check if rate limit simulation should trigger for a given endpoint If triggered, returns the retry-after value and optionally disables simulation Returns null if not simulating rate limit or endpoint doesn't match scope

Parameters

ParameterTypeDescription
endpoint?stringOptional endpoint path to check against scope

Returns

| null | { retryAfter: number; }

Implementation of

ISession.checkRateLimit


clearActionContext()

clearActionContext(): void

Clear the action context.

Returns

void

Implementation of

ISession.clearActionContext


clearActions()

clearActions(): void

Clear recorded actions without resetting state

Returns

void

Implementation of

ISession.clearActions


clearLogs()

clearLogs(): void

Clear recorded logs without resetting state

Returns

void

Implementation of

ISession.clearLogs


clearPermissionDeniedEvents()

clearPermissionDeniedEvents(): void

Clear permission denied events history

Returns

void


clearPermissionOverrides()

clearPermissionOverrides(): void

Clear all permission overrides

Returns

void


clickButtonAs()

clickButtonAs(
   userId, 
   messageId, 
customId): Promise<MockInteraction>

Click a button as a specific user

Parameters

ParameterTypeDescription
userIdstringThe user ID to click as
messageIdstringThe message containing the button
customIdstringThe button's custom ID

Returns

Promise<MockInteraction>

The created interaction


createUser()

createUser(config, setAsCurrent): MockUser

Create a new user and optionally set as current

Parameters

ParameterTypeDefault valueDescription
config{ avatar: null | string; bot: boolean; status: "online" | "offline" | "idle" | "dnd"; username: string; }undefinedUser configuration
config.avatar?null | stringundefined-
config.bot?booleanundefined-
config.status?"online" | "offline" | "idle" | "dnd"undefined-
config.usernamestringundefined-
setAsCurrentbooleanfalseWhether to set this user as the current user (default: false)

Returns

MockUser

The created user


dispatch()

dispatch(event, data): Promise<void>

Dispatch an event to all connections in this session Sends the event via WebSocket to connected bots

Parameters

ParameterType
eventstring
dataunknown

Returns

Promise<void>

Implementation of

ISession.dispatch


dispatchAutocomplete()

dispatchAutocomplete(options): Promise<MockInteraction>

Dispatch an INTERACTION_CREATE event for autocomplete Creates an autocomplete interaction for testing bot autocomplete handlers

Parameters

ParameterTypeDescription
optionsDispatchAutocompleteOptionsAutocomplete options including focused option

Returns

Promise<MockInteraction>

The created interaction


dispatchAutoModerationActionExecution()

dispatchAutoModerationActionExecution(options): Promise<void>

Dispatch AUTO_MODERATION_ACTION_EXECUTION event

Parameters

ParameterTypeDescription
options{ action: MockAutoModAction; channelId: string; content: string; guildId: string; matchedContent: string; matchedKeyword: string; messageId: string; ruleId: string; ruleTriggerType: AutoModerationTriggerType; userId: string; }The action execution details
options.actionMockAutoModAction-
options.channelId?string-
options.contentstring-
options.guildIdstring-
options.matchedContent?string-
options.matchedKeyword?string-
options.messageId?string-
options.ruleIdstring-
options.ruleTriggerTypeAutoModerationTriggerType-
options.userIdstring-

Returns

Promise<void>


dispatchAutoModerationRuleCreate()

dispatchAutoModerationRuleCreate(rule): Promise<void>

Dispatch AUTO_MODERATION_RULE_CREATE event

Parameters

ParameterTypeDescription
ruleMockAutoModRuleThe auto-mod rule that was created

Returns

Promise<void>


dispatchAutoModerationRuleDelete()

dispatchAutoModerationRuleDelete(rule): Promise<void>

Dispatch AUTO_MODERATION_RULE_DELETE event

Parameters

ParameterTypeDescription
ruleMockAutoModRuleThe auto-mod rule that was deleted

Returns

Promise<void>


dispatchAutoModerationRuleUpdate()

dispatchAutoModerationRuleUpdate(rule): Promise<void>

Dispatch AUTO_MODERATION_RULE_UPDATE event

Parameters

ParameterTypeDescription
ruleMockAutoModRuleThe auto-mod rule that was updated

Returns

Promise<void>


dispatchButtonClick()

dispatchButtonClick(options): Promise<MockInteraction>

Dispatch an INTERACTION_CREATE event for a button click Creates an interaction in state and dispatches it to connected bots

Parameters

ParameterTypeDescription
optionsDispatchButtonClickOptionsButton click options

Returns

Promise<MockInteraction>

The created interaction


dispatchContextMenu()

dispatchContextMenu(options): Promise<MockInteraction>

Dispatch an INTERACTION_CREATE event for a context menu command Creates an interaction in state and dispatches it to connected bots

Parameters

ParameterTypeDescription
optionsDispatchContextMenuOptionsContext menu command options

Returns

Promise<MockInteraction>

The created interaction


dispatchGuildBanAdd()

dispatchGuildBanAdd(guildId, user): Promise<void>

Dispatch GUILD_BAN_ADD event when a user is banned

Parameters

ParameterTypeDescription
guildIdstringThe guild where the user was banned
userMockUserThe user who was banned

Returns

Promise<void>


dispatchGuildBanRemove()

dispatchGuildBanRemove(guildId, user): Promise<void>

Dispatch GUILD_BAN_REMOVE event when a user is unbanned

Parameters

ParameterTypeDescription
guildIdstringThe guild where the user was unbanned
userMockUserThe user who was unbanned

Returns

Promise<void>


dispatchGuildEmojisUpdate()

dispatchGuildEmojisUpdate(guildId): Promise<void>

Dispatch GUILD_EMOJIS_UPDATE event when emojis change

Parameters

ParameterTypeDescription
guildIdstringThe guild whose emojis changed

Returns

Promise<void>


dispatchGuildMemberAdd()

dispatchGuildMemberAdd(
   guildId, 
   member, 
user): Promise<void>

Dispatch GUILD_MEMBER_ADD event when a member joins a guild

Parameters

ParameterTypeDescription
guildIdstringThe guild where the member joined
memberMockGuildMemberThe member who joined
userMockUserThe user associated with the member

Returns

Promise<void>


dispatchGuildMemberRemove()

dispatchGuildMemberRemove(guildId, user): Promise<void>

Dispatch GUILD_MEMBER_REMOVE event when a member leaves or is removed from a guild

Parameters

ParameterTypeDescription
guildIdstringThe guild where the member was removed
userMockUserThe user who was removed

Returns

Promise<void>


dispatchGuildMemberUpdate()

dispatchGuildMemberUpdate(
   guildId, 
   member, 
user): Promise<void>

Dispatch GUILD_MEMBER_UPDATE event when a member is updated

Parameters

ParameterTypeDescription
guildIdstringThe guild where the member was updated
memberMockGuildMemberThe updated member
userMockUserThe user associated with the member

Returns

Promise<void>


dispatchGuildRoleCreate()

dispatchGuildRoleCreate(guildId, role): Promise<void>

Dispatch GUILD_ROLE_CREATE event when a role is created

Parameters

ParameterTypeDescription
guildIdstringThe guild where the role was created
roleMockRoleThe created role

Returns

Promise<void>


dispatchGuildRoleDelete()

dispatchGuildRoleDelete(guildId, roleId): Promise<void>

Dispatch GUILD_ROLE_DELETE event when a role is deleted

Parameters

ParameterTypeDescription
guildIdstringThe guild where the role was deleted
roleIdstringThe ID of the deleted role

Returns

Promise<void>


dispatchGuildRoleUpdate()

dispatchGuildRoleUpdate(guildId, role): Promise<void>

Dispatch GUILD_ROLE_UPDATE event when a role is updated

Parameters

ParameterTypeDescription
guildIdstringThe guild where the role was updated
roleMockRoleThe updated role

Returns

Promise<void>


dispatchGuildScheduledEventCreate()

dispatchGuildScheduledEventCreate(event): Promise<void>

Dispatch GUILD_SCHEDULED_EVENT_CREATE event

Parameters

ParameterTypeDescription
eventMockScheduledEventThe scheduled event that was created

Returns

Promise<void>


dispatchGuildScheduledEventDelete()

dispatchGuildScheduledEventDelete(event): Promise<void>

Dispatch GUILD_SCHEDULED_EVENT_DELETE event

Parameters

ParameterTypeDescription
eventMockScheduledEventThe scheduled event that was deleted

Returns

Promise<void>


dispatchGuildScheduledEventUpdate()

dispatchGuildScheduledEventUpdate(event): Promise<void>

Dispatch GUILD_SCHEDULED_EVENT_UPDATE event

Parameters

ParameterTypeDescription
eventMockScheduledEventThe scheduled event that was updated

Returns

Promise<void>


dispatchGuildScheduledEventUserAdd()

dispatchGuildScheduledEventUserAdd(
   guildId, 
   eventId, 
userId): Promise<void>

Dispatch GUILD_SCHEDULED_EVENT_USER_ADD event

Parameters

ParameterTypeDescription
guildIdstringThe guild ID
eventIdstringThe scheduled event ID
userIdstringThe user ID who subscribed

Returns

Promise<void>


dispatchGuildScheduledEventUserRemove()

dispatchGuildScheduledEventUserRemove(
   guildId, 
   eventId, 
userId): Promise<void>

Dispatch GUILD_SCHEDULED_EVENT_USER_REMOVE event

Parameters

ParameterTypeDescription
guildIdstringThe guild ID
eventIdstringThe scheduled event ID
userIdstringThe user ID who unsubscribed

Returns

Promise<void>


dispatchGuildStickersUpdate()

dispatchGuildStickersUpdate(guildId): Promise<void>

Dispatch GUILD_STICKERS_UPDATE event when stickers change

Parameters

ParameterTypeDescription
guildIdstringThe guild whose stickers changed

Returns

Promise<void>


dispatchInviteCreate()

dispatchInviteCreate(invite): Promise<void>

Dispatch INVITE_CREATE event

Parameters

ParameterTypeDescription
inviteMockInviteThe invite that was created

Returns

Promise<void>


dispatchInviteDelete()

dispatchInviteDelete(invite): Promise<void>

Dispatch INVITE_DELETE event

Parameters

ParameterTypeDescription
inviteMockInviteThe invite that was deleted

Returns

Promise<void>


dispatchMessage()

dispatchMessage(options): Promise<MockMessage>

Dispatch a MESSAGE_CREATE event Creates a message in state and dispatches it to connected bots

Parameters

ParameterTypeDescription
options{ attachments: MockAttachment[]; author: Partial<MockUser> & { id: string; username: string; }; call: { ended_timestamp: null | string; participants: string[]; }; channelId: string; components: unknown[]; content: string; embeds: unknown[]; guildId: string; id: string; mentions: string[]; messageReference: { channel_id: string; guild_id: string; message_id: string; }; position: number; reactions: { count: number; emoji: { id: null | string; name: string; }; me: boolean; }[]; roleSubscriptionData: { isRenewal: boolean; roleSubscriptionListingId: string; tierName: string; totalMonthsSubscribed: number; }; type: number; }Message creation options
options.attachments?MockAttachment[]-
options.author?Partial<MockUser> & { id: string; username: string; }-
options.call?{ ended_timestamp: null | string; participants: string[]; }Call info for DM call messages (MessageType.Call = 3)
options.call.ended_timestamp?null | string-
options.call.participantsstring[]-
options.channelIdstring-
options.components?unknown[]-
options.content?string-
options.embeds?unknown[]-
options.guildId?string-
options.id?stringOptional message ID - if not provided, one will be generated
options.mentions?string[]User IDs that are mentioned in this message
options.messageReference?{ channel_id: string; guild_id: string; message_id: string; }Reference to another message (for replies)
options.messageReference.channel_id?string-
options.messageReference.guild_id?string-
options.messageReference.message_id?string-
options.position?numberMessage position (for threads/forums)
options.reactions?{ count: number; emoji: { id: null | string; name: string; }; me: boolean; }[]Reactions to apply to the message after creation
options.roleSubscriptionData?{ isRenewal: boolean; roleSubscriptionListingId: string; tierName: string; totalMonthsSubscribed: number; }Role subscription data for subscription purchase messages (MessageType.RoleSubscriptionPurchase = 25)
options.roleSubscriptionData.isRenewalboolean-
options.roleSubscriptionData.roleSubscriptionListingIdstring-
options.roleSubscriptionData.tierNamestring-
options.roleSubscriptionData.totalMonthsSubscribednumber-
options.type?numberMessage type (default 0 = DEFAULT, 7 = USER_JOIN, 8 = GUILD_BOOST, etc.)

Returns

Promise<MockMessage>

The created message


dispatchModalSubmit()

dispatchModalSubmit(options): Promise<MockInteraction>

Dispatch an INTERACTION_CREATE event for a modal submit Creates an interaction in state and dispatches it to connected bots

Parameters

ParameterTypeDescription
optionsDispatchModalSubmitOptionsModal submit options

Returns

Promise<MockInteraction>

The created interaction


dispatchPollVote()

dispatchPollVote(options): Promise<boolean>

Dispatch a MESSAGE_POLL_VOTE_ADD or MESSAGE_POLL_VOTE_REMOVE event Adds/removes a vote from a poll and dispatches the event to connected bots

Parameters

ParameterTypeDescription
options{ action: "add" | "remove"; answerId: number; messageId: string; userId: string; }Poll vote options
options.action"add" | "remove"-
options.answerIdnumber-
options.messageIdstring-
options.userIdstring-

Returns

Promise<boolean>

true if the vote was successfully added/removed


dispatchReaction()

dispatchReaction(options): Promise<boolean>

Dispatch a MESSAGE_REACTION_ADD or MESSAGE_REACTION_REMOVE event Updates state and dispatches to connected bots and Stage UI

Parameters

ParameterTypeDescription
options{ action: "add" | "remove"; channelId: string; emoji: { id: null | string; name: string; }; guildId: string; messageId: string; userId: string; }Reaction options
options.action"add" | "remove"-
options.channelIdstring-
options.emoji{ id: null | string; name: string; }-
options.emoji.idnull | string-
options.emoji.namestring-
options.guildId?string-
options.messageIdstring-
options.userIdstring-

Returns

Promise<boolean>

true if successful, false if message not found


dispatchSelectMenu()

dispatchSelectMenu(options): Promise<MockInteraction>

Dispatch an INTERACTION_CREATE event for a select menu interaction Creates an interaction in state and dispatches it to connected bots

Parameters

ParameterTypeDescription
optionsDispatchSelectMenuOptionsSelect menu options

Returns

Promise<MockInteraction>

The created interaction


dispatchSlashCommand()

dispatchSlashCommand(options): Promise<MockInteraction>

Dispatch an INTERACTION_CREATE event for a slash command Creates an interaction in state and dispatches it to connected bots

Parameters

ParameterTypeDescription
optionsDispatchSlashCommandOptionsSlash command options

Returns

Promise<MockInteraction>

The created interaction


dispatchThreadCreate()

dispatchThreadCreate(options): Promise<MockThread>

Dispatch a THREAD_CREATE event Creates a thread in state and dispatches it to connected bots

Parameters

ParameterTypeDescription
optionsDispatchThreadCreateOptionsThread creation options

Returns

Promise<MockThread>

The created thread


dispatchThreadDelete()

dispatchThreadDelete(threadId): Promise<void>

Dispatch a THREAD_DELETE event Deletes a thread and dispatches the event

Parameters

ParameterTypeDescription
threadIdstringID of the thread to delete

Returns

Promise<void>


dispatchThreadJoin()

dispatchThreadJoin(threadId): Promise<void>

Dispatch THREAD_MEMBER_UPDATE for bot joining a thread

Parameters

ParameterTypeDescription
threadIdstringID of the thread to join

Returns

Promise<void>


dispatchThreadLeave()

dispatchThreadLeave(threadId): Promise<void>

Dispatch THREAD_MEMBER_UPDATE for bot leaving a thread

Parameters

ParameterTypeDescription
threadIdstringID of the thread to leave

Returns

Promise<void>


dispatchThreadListSync()

dispatchThreadListSync(guildId, channelIds?): Promise<void>

Dispatch THREAD_LIST_SYNC for syncing active threads Sent when bot gains access to channels

Parameters

ParameterTypeDescription
guildIdstringID of the guild
channelIds?string[]Optional specific channel IDs to sync (if not provided, syncs all)

Returns

Promise<void>


dispatchThreadMemberAdd()

dispatchThreadMemberAdd(threadId, userId): Promise<void>

Dispatch THREAD_MEMBERS_UPDATE for adding a user to a thread This is for testing - simulates another user being added

Parameters

ParameterTypeDescription
threadIdstringID of the thread
userIdstringID of the user to add

Returns

Promise<void>


dispatchThreadMemberRemove()

dispatchThreadMemberRemove(threadId, userId): Promise<void>

Dispatch THREAD_MEMBERS_UPDATE for removing a user from a thread This is for testing - simulates another user being removed

Parameters

ParameterTypeDescription
threadIdstringID of the thread
userIdstringID of the user to remove

Returns

Promise<void>


dispatchThreadUpdate()

dispatchThreadUpdate(threadId, updates): Promise<MockThread>

Dispatch a THREAD_UPDATE event Updates thread metadata and dispatches the change

Parameters

ParameterTypeDescription
threadIdstringID of the thread to update
updates{ archived: boolean; autoArchiveDuration: 60 | 1440 | 4320 | 10080; invitable: boolean; locked: boolean; name: string; }Thread updates (name, archived, locked, etc.)
updates.archived?boolean-
updates.autoArchiveDuration?60 | 1440 | 4320 | 10080-
updates.invitable?boolean-
updates.locked?boolean-
updates.name?string-

Returns

Promise<MockThread>

The updated thread


end()

end(): Promise<void>

End the session and clean up resources

Returns

Promise<void>


exportRecording()

exportRecording(): SessionRecording

Export the session as a recording object Returns a JSON-serializable recording with metadata and all actions

Returns

SessionRecording

Implementation of

ISession.exportRecording


getActionContext()

getActionContext(): null | ActionContext

Get the current action context.

Returns

null | ActionContext

Implementation of

ISession.getActionContext


getActions()

getActions(): RecordedAction[]

Get all recorded actions for test assertions

Returns

RecordedAction[]

Implementation of

ISession.getActions


getActionsByType()

getActionsByType(type): RecordedAction[]

Get actions by type

Parameters

ParameterType
typeActionType

Returns

RecordedAction[]

Implementation of

ISession.getActionsByType


getActionsSince()

getActionsSince(timestamp): RecordedAction[]

Get actions since a specific timestamp

Parameters

ParameterType
timestampnumber

Returns

RecordedAction[]

Implementation of

ISession.getActionsSince


getCurrentUser()

getCurrentUser(): MockUser

Get the current acting user

Returns

MockUser


getDispatches()

getDispatches(): RecordedAction[]

Get dispatch events (server → client)

Returns

RecordedAction[]

Implementation of

ISession.getDispatches


getGatewayMessages()

getGatewayMessages(): RecordedAction[]

Get all Gateway WebSocket message actions (client → server)

Returns

RecordedAction[]

Implementation of

ISession.getGatewayMessages


getInteractionResponses()

getInteractionResponses(): RecordedAction[]

Get all interaction response actions

Returns

RecordedAction[]

Implementation of

ISession.getInteractionResponses


getLogs()

getLogs(): SessionLogEntry[]

Get all captured logs

Returns

SessionLogEntry[]

Implementation of

ISession.getLogs


getLogsSince()

getLogsSince(timestamp): SessionLogEntry[]

Get logs since a timestamp

Parameters

ParameterType
timestampnumber

Returns

SessionLogEntry[]

Implementation of

ISession.getLogsSince


getMessagesSent()

getMessagesSent(): RecordedAction[]

Get message_sent actions

Returns

RecordedAction[]

Implementation of

ISession.getMessagesSent


getPermissionDeniedEvents()

getPermissionDeniedEvents(): PermissionDeniedEvent[]

Get recent permission denied events

Returns

PermissionDeniedEvent[]


getPermissionOverride()

getPermissionOverride(id): undefined | PermissionOverride

Get a specific permission override by ID

Parameters

ParameterType
idstring

Returns

undefined | PermissionOverride


getPermissionOverrides()

getPermissionOverrides(): PermissionOverride[]

Get all permission overrides

Returns

PermissionOverride[]


getRestRequests()

getRestRequests(): RecordedAction[]

Get all REST request actions

Returns

RecordedAction[]

Implementation of

ISession.getRestRequests


getUser()

getUser(userId): undefined | MockUser

Get a specific user by ID

Parameters

ParameterType
userIdstring

Returns

undefined | MockUser


getUsers()

getUsers(): MockUser[]

Get all users in the session

Returns

MockUser[]


invokeCommandAs()

invokeCommandAs(
   userId, 
   commandName, 
options?): Promise<MockInteraction>

Invoke a command as a specific user

Parameters

ParameterTypeDescription
userIdstringThe user ID to invoke as
commandNamestringThe command name
options?Record<string, string | number | boolean>Optional command options

Returns

Promise<MockInteraction>

The created interaction


recordAction()

recordAction(
   type, 
   data, 
   options?): RecordedAction

Record an action from the bot (REST API call, Gateway message, etc.) Automatically merges in the current action context if metadata/triggeredBy not provided.

Parameters

ParameterType
typeActionType
dataunknown
options?RecordActionOptions

Returns

RecordedAction

Implementation of

ISession.recordAction


recordLog()

recordLog(entry): SessionLogEntry

Record a log entry from a connected bot

Parameters

ParameterTypeDescription
entryOmit<SessionLogEntry, "id">The log entry (without id, which will be generated)

Returns

SessionLogEntry

Implementation of

ISession.recordLog


recordPermissionDenied()

recordPermissionDenied(event): PermissionDeniedEvent

Record a permission denied event (for Stage UI display)

Parameters

ParameterType
eventOmit<PermissionDeniedEvent, "timestamp" | "sessionId">

Returns

PermissionDeniedEvent


removePermissionOverride()

removePermissionOverride(id): boolean

Remove a permission override by ID

Parameters

ParameterType
idstring

Returns

boolean

true if the override was removed, false if not found


reset()

reset(): void

Reset session state (clear guilds, channels, etc. but keep bot user)

Returns

void

Implementation of

ISession.reset


runAutoArchiveCheck()

runAutoArchiveCheck(): Promise<string[]>

Manually run auto-archive check and dispatch THREAD_UPDATE for archived threads

Returns

Promise<string[]>

Array of archived thread IDs


saveRecording()

saveRecording(filePath): Promise<void>

Save the recording to a JSON file

Parameters

ParameterTypeDescription
filePathstringPath to save the recording

Returns

Promise<void>


sendMessageAs()

sendMessageAs(
   userId, 
   channelId, 
content): Promise<MockMessage>

Send a message as a specific user

Parameters

ParameterTypeDescription
userIdstringThe user ID to send as
channelIdstringThe channel to send to
contentstringThe message content

Returns

Promise<MockMessage>

The created message


setActionContext()

setActionContext(context): void

Set the action context for metadata propagation. Actions recorded while this context is active will inherit the metadata.

Parameters

ParameterType
contextnull | ActionContext

Returns

void

Implementation of

ISession.setActionContext


setCurrentUser()

setCurrentUser(userId): undefined | MockUser

Set the current acting user by ID (switches to existing user)

Parameters

ParameterType
userIdstring

Returns

undefined | MockUser

The switched user, or undefined if not found


setRateLimitSimulation()

setRateLimitSimulation(config, retryAfter): void

Enable rate limit simulation for testing When enabled, matching API requests will return a 429 response

Parameters

ParameterTypeDefault valueDescription
config| boolean | { enabled: boolean; persistent: boolean; retryAfter: number; scope: "all" | "messages" | "interactions" | "guilds" | "channels"; }undefinedRate limit configuration or simple enabled boolean for backward compatibility
retryAfternumber1Retry-After value in seconds (only used when config is boolean)

Returns

void

Implementation of

ISession.setRateLimitSimulation


startAutoArchive()

startAutoArchive(intervalMs): void

Start automatic thread archiving based on auto_archive_duration

Parameters

ParameterTypeDefault valueDescription
intervalMsnumber60000How often to check for inactive threads (default: 60000ms / 1 minute)

Returns

void

Implementation of

ISession.startAutoArchive


stopAutoArchive()

stopAutoArchive(): void

Stop automatic thread archiving

Returns

void

Implementation of

ISession.stopAutoArchive


updateUser()

updateUser(userId, updates): undefined | MockUser

Update a user's properties

Parameters

ParameterTypeDescription
userIdstringThe user ID to update
updatesPartial<{ avatar: null | string; status: "online" | "offline" | "idle" | "dnd"; username: string; }>The properties to update

Returns

undefined | MockUser

The updated user, or undefined if not found

On this page

Class: Session
Implements
Constructors
new Session()
Parameters
Returns
Properties
Accessors
actionCount
Get Signature
Returns
heartbeatInterval
Get Signature
Returns
Set Signature
Parameters
Returns
isEnding
Get Signature
Returns
Implementation of
isExpired
Get Signature
Returns
Implementation of
isLoopDetected
Get Signature
Returns
isRateLimitSimulationActive
Get Signature
Returns
loopProtectionEnabled
Get Signature
Returns
Set Signature
Parameters
Returns
permissionEnforcement
Get Signature
Returns
Set Signature
Parameters
Returns
rateLimitConfig
Get Signature
Returns
Methods
addPermissionOverride()
Parameters
Returns
asUser()
Type Parameters
Parameters
Returns
checkRateLimit()
Parameters
Returns
Implementation of
clearActionContext()
Returns
Implementation of
clearActions()
Returns
Implementation of
clearLogs()
Returns
Implementation of
clearPermissionDeniedEvents()
Returns
clearPermissionOverrides()
Returns
clickButtonAs()
Parameters
Returns
createUser()
Parameters
Returns
dispatch()
Parameters
Returns
Implementation of
dispatchAutocomplete()
Parameters
Returns
dispatchAutoModerationActionExecution()
Parameters
Returns
dispatchAutoModerationRuleCreate()
Parameters
Returns
dispatchAutoModerationRuleDelete()
Parameters
Returns
dispatchAutoModerationRuleUpdate()
Parameters
Returns
dispatchButtonClick()
Parameters
Returns
dispatchContextMenu()
Parameters
Returns
dispatchGuildBanAdd()
Parameters
Returns
dispatchGuildBanRemove()
Parameters
Returns
dispatchGuildEmojisUpdate()
Parameters
Returns
dispatchGuildMemberAdd()
Parameters
Returns
dispatchGuildMemberRemove()
Parameters
Returns
dispatchGuildMemberUpdate()
Parameters
Returns
dispatchGuildRoleCreate()
Parameters
Returns
dispatchGuildRoleDelete()
Parameters
Returns
dispatchGuildRoleUpdate()
Parameters
Returns
dispatchGuildScheduledEventCreate()
Parameters
Returns
dispatchGuildScheduledEventDelete()
Parameters
Returns
dispatchGuildScheduledEventUpdate()
Parameters
Returns
dispatchGuildScheduledEventUserAdd()
Parameters
Returns
dispatchGuildScheduledEventUserRemove()
Parameters
Returns
dispatchGuildStickersUpdate()
Parameters
Returns
dispatchInviteCreate()
Parameters
Returns
dispatchInviteDelete()
Parameters
Returns
dispatchMessage()
Parameters
Returns
dispatchModalSubmit()
Parameters
Returns
dispatchPollVote()
Parameters
Returns
dispatchReaction()
Parameters
Returns
dispatchSelectMenu()
Parameters
Returns
dispatchSlashCommand()
Parameters
Returns
dispatchThreadCreate()
Parameters
Returns
dispatchThreadDelete()
Parameters
Returns
dispatchThreadJoin()
Parameters
Returns
dispatchThreadLeave()
Parameters
Returns
dispatchThreadListSync()
Parameters
Returns
dispatchThreadMemberAdd()
Parameters
Returns
dispatchThreadMemberRemove()
Parameters
Returns
dispatchThreadUpdate()
Parameters
Returns
end()
Returns
exportRecording()
Returns
Implementation of
getActionContext()
Returns
Implementation of
getActions()
Returns
Implementation of
getActionsByType()
Parameters
Returns
Implementation of
getActionsSince()
Parameters
Returns
Implementation of
getCurrentUser()
Returns
getDispatches()
Returns
Implementation of
getGatewayMessages()
Returns
Implementation of
getInteractionResponses()
Returns
Implementation of
getLogs()
Returns
Implementation of
getLogsSince()
Parameters
Returns
Implementation of
getMessagesSent()
Returns
Implementation of
getPermissionDeniedEvents()
Returns
getPermissionOverride()
Parameters
Returns
getPermissionOverrides()
Returns
getRestRequests()
Returns
Implementation of
getUser()
Parameters
Returns
getUsers()
Returns
invokeCommandAs()
Parameters
Returns
recordAction()
Parameters
Returns
Implementation of
recordLog()
Parameters
Returns
Implementation of
recordPermissionDenied()
Parameters
Returns
removePermissionOverride()
Parameters
Returns
reset()
Returns
Implementation of
runAutoArchiveCheck()
Returns
saveRecording()
Parameters
Returns
sendMessageAs()
Parameters
Returns
setActionContext()
Parameters
Returns
Implementation of
setCurrentUser()
Parameters
Returns
setRateLimitSimulation()
Parameters
Returns
Implementation of
startAutoArchive()
Parameters
Returns
Implementation of
stopAutoArchive()
Returns
Implementation of
updateUser()
Parameters
Returns