Session
Class: Session
Represents an isolated test session with its own state
Implements
Constructors
new Session()
new Session(options?): SessionParameters
| Parameter | Type |
|---|---|
options? | CreateSessionOptions |
Returns
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
config? | readonly | SessionConfig | - |
connections | readonly | Map<string, ConnectionState> | - |
createdAt | readonly | number | - |
expiresAt | readonly | number | - |
id | readonly | string | - |
logRecorder | readonly | LogRecorder | - |
name? | readonly | string | - |
recorder | readonly | ActionRecorder | - |
scenarioManager | readonly | ScenarioManager | - |
state | readonly | MockServerState | - |
token | readonly | string | - |
voiceServers | readonly | Map<string, VoiceServerState> | Voice server state by guild ID Tracks active voice connections for @discordjs/voice support |
Accessors
actionCount
Get Signature
get actionCount(): numberGet the number of recorded actions
Returns
number
heartbeatInterval
Get Signature
get heartbeatInterval(): null | numberGet the heartbeat interval for this session. Returns null if using the global gateway default.
Returns
null | number
Set Signature
set heartbeatInterval(interval): voidSet 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
| Parameter | Type | Description |
|---|---|---|
interval | null | number | Heartbeat interval in milliseconds (100-120000), or null for default |
Returns
void
isEnding
Get Signature
get isEnding(): booleanCheck if session is ending
Returns
boolean
Implementation of
isExpired
Get Signature
get isExpired(): booleanCheck if session has expired
Returns
boolean
Implementation of
isLoopDetected
Get Signature
get isLoopDetected(): booleanCheck if a loop is currently detected (in cooldown)
Returns
boolean
isRateLimitSimulationActive
Get Signature
get isRateLimitSimulationActive(): booleanCheck if rate limit simulation is currently active (without consuming it)
Returns
boolean
loopProtectionEnabled
Get Signature
get loopProtectionEnabled(): booleanCheck if loop protection is enabled
Returns
boolean
Set Signature
set loopProtectionEnabled(enabled): voidEnable or disable loop protection. When disabled, the server will not detect or prevent event loops.
Parameters
| Parameter | Type |
|---|---|
enabled | boolean |
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): voidSet the permission enforcement level at runtime. Set to null to use the config default.
Parameters
| Parameter | Type |
|---|---|
level | null | "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;
}| Name | Type |
|---|---|
enabled | boolean |
persistent | boolean |
retryAfter | number |
scope | "all" | "messages" | "interactions" | "guilds" | "channels" |
triggeredCount | number |
Methods
addPermissionOverride()
addPermissionOverride(override): PermissionOverrideAdd a new permission override
Parameters
| Parameter | Type | Description |
|---|---|---|
override | Omit<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
| Parameter | Type | Description |
|---|---|---|
userId | string | The 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
| Parameter | Type | Description |
|---|---|---|
endpoint? | string | Optional endpoint path to check against scope |
Returns
| null
| {
retryAfter: number;
}
Implementation of
clearActionContext()
clearActionContext(): voidClear the action context.
Returns
void
Implementation of
clearActions()
clearActions(): voidClear recorded actions without resetting state
Returns
void
Implementation of
clearLogs()
clearLogs(): voidClear recorded logs without resetting state
Returns
void
Implementation of
clearPermissionDeniedEvents()
clearPermissionDeniedEvents(): voidClear permission denied events history
Returns
void
clearPermissionOverrides()
clearPermissionOverrides(): voidClear all permission overrides
Returns
void
clickButtonAs()
clickButtonAs(
userId,
messageId,
customId): Promise<MockInteraction>Click a button as a specific user
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | The user ID to click as |
messageId | string | The message containing the button |
customId | string | The button's custom ID |
Returns
Promise<MockInteraction>
The created interaction
createUser()
createUser(config, setAsCurrent): MockUserCreate a new user and optionally set as current
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
config | { avatar: null | string; bot: boolean; status: "online" | "offline" | "idle" | "dnd"; username: string; } | undefined | User configuration |
config.avatar? | null | string | undefined | - |
config.bot? | boolean | undefined | - |
config.status? | "online" | "offline" | "idle" | "dnd" | undefined | - |
config.username | string | undefined | - |
setAsCurrent | boolean | false | Whether to set this user as the current user (default: false) |
Returns
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
| Parameter | Type |
|---|---|
event | string |
data | unknown |
Returns
Promise<void>
Implementation of
dispatchAutocomplete()
dispatchAutocomplete(options): Promise<MockInteraction>Dispatch an INTERACTION_CREATE event for autocomplete Creates an autocomplete interaction for testing bot autocomplete handlers
Parameters
| Parameter | Type | Description |
|---|---|---|
options | DispatchAutocompleteOptions | Autocomplete options including focused option |
Returns
Promise<MockInteraction>
The created interaction
dispatchAutoModerationActionExecution()
dispatchAutoModerationActionExecution(options): Promise<void>Dispatch AUTO_MODERATION_ACTION_EXECUTION event
Parameters
| Parameter | Type | Description |
|---|---|---|
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.action | MockAutoModAction | - |
options.channelId? | string | - |
options.content | string | - |
options.guildId | string | - |
options.matchedContent? | string | - |
options.matchedKeyword? | string | - |
options.messageId? | string | - |
options.ruleId | string | - |
options.ruleTriggerType | AutoModerationTriggerType | - |
options.userId | string | - |
Returns
Promise<void>
dispatchAutoModerationRuleCreate()
dispatchAutoModerationRuleCreate(rule): Promise<void>Dispatch AUTO_MODERATION_RULE_CREATE event
Parameters
| Parameter | Type | Description |
|---|---|---|
rule | MockAutoModRule | The auto-mod rule that was created |
Returns
Promise<void>
dispatchAutoModerationRuleDelete()
dispatchAutoModerationRuleDelete(rule): Promise<void>Dispatch AUTO_MODERATION_RULE_DELETE event
Parameters
| Parameter | Type | Description |
|---|---|---|
rule | MockAutoModRule | The auto-mod rule that was deleted |
Returns
Promise<void>
dispatchAutoModerationRuleUpdate()
dispatchAutoModerationRuleUpdate(rule): Promise<void>Dispatch AUTO_MODERATION_RULE_UPDATE event
Parameters
| Parameter | Type | Description |
|---|---|---|
rule | MockAutoModRule | The 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
| Parameter | Type | Description |
|---|---|---|
options | DispatchButtonClickOptions | Button 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
| Parameter | Type | Description |
|---|---|---|
options | DispatchContextMenuOptions | Context 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
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the user was banned |
user | MockUser | The user who was banned |
Returns
Promise<void>
dispatchGuildBanRemove()
dispatchGuildBanRemove(guildId, user): Promise<void>Dispatch GUILD_BAN_REMOVE event when a user is unbanned
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the user was unbanned |
user | MockUser | The user who was unbanned |
Returns
Promise<void>
dispatchGuildEmojisUpdate()
dispatchGuildEmojisUpdate(guildId): Promise<void>Dispatch GUILD_EMOJIS_UPDATE event when emojis change
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The 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
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the member joined |
member | MockGuildMember | The member who joined |
user | MockUser | The 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
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the member was removed |
user | MockUser | The 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
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the member was updated |
member | MockGuildMember | The updated member |
user | MockUser | The 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
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the role was created |
role | MockRole | The created role |
Returns
Promise<void>
dispatchGuildRoleDelete()
dispatchGuildRoleDelete(guildId, roleId): Promise<void>Dispatch GUILD_ROLE_DELETE event when a role is deleted
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the role was deleted |
roleId | string | The 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
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild where the role was updated |
role | MockRole | The updated role |
Returns
Promise<void>
dispatchGuildScheduledEventCreate()
dispatchGuildScheduledEventCreate(event): Promise<void>Dispatch GUILD_SCHEDULED_EVENT_CREATE event
Parameters
| Parameter | Type | Description |
|---|---|---|
event | MockScheduledEvent | The scheduled event that was created |
Returns
Promise<void>
dispatchGuildScheduledEventDelete()
dispatchGuildScheduledEventDelete(event): Promise<void>Dispatch GUILD_SCHEDULED_EVENT_DELETE event
Parameters
| Parameter | Type | Description |
|---|---|---|
event | MockScheduledEvent | The scheduled event that was deleted |
Returns
Promise<void>
dispatchGuildScheduledEventUpdate()
dispatchGuildScheduledEventUpdate(event): Promise<void>Dispatch GUILD_SCHEDULED_EVENT_UPDATE event
Parameters
| Parameter | Type | Description |
|---|---|---|
event | MockScheduledEvent | The scheduled event that was updated |
Returns
Promise<void>
dispatchGuildScheduledEventUserAdd()
dispatchGuildScheduledEventUserAdd(
guildId,
eventId,
userId): Promise<void>Dispatch GUILD_SCHEDULED_EVENT_USER_ADD event
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild ID |
eventId | string | The scheduled event ID |
userId | string | The user ID who subscribed |
Returns
Promise<void>
dispatchGuildScheduledEventUserRemove()
dispatchGuildScheduledEventUserRemove(
guildId,
eventId,
userId): Promise<void>Dispatch GUILD_SCHEDULED_EVENT_USER_REMOVE event
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild ID |
eventId | string | The scheduled event ID |
userId | string | The user ID who unsubscribed |
Returns
Promise<void>
dispatchGuildStickersUpdate()
dispatchGuildStickersUpdate(guildId): Promise<void>Dispatch GUILD_STICKERS_UPDATE event when stickers change
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | The guild whose stickers changed |
Returns
Promise<void>
dispatchInviteCreate()
dispatchInviteCreate(invite): Promise<void>Dispatch INVITE_CREATE event
Parameters
| Parameter | Type | Description |
|---|---|---|
invite | MockInvite | The invite that was created |
Returns
Promise<void>
dispatchInviteDelete()
dispatchInviteDelete(invite): Promise<void>Dispatch INVITE_DELETE event
Parameters
| Parameter | Type | Description |
|---|---|---|
invite | MockInvite | The 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
| Parameter | Type | Description |
|---|---|---|
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.participants | string[] | - |
options.channelId | string | - |
options.components? | unknown[] | - |
options.content? | string | - |
options.embeds? | unknown[] | - |
options.guildId? | string | - |
options.id? | string | Optional 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? | number | Message 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.isRenewal | boolean | - |
options.roleSubscriptionData.roleSubscriptionListingId | string | - |
options.roleSubscriptionData.tierName | string | - |
options.roleSubscriptionData.totalMonthsSubscribed | number | - |
options.type? | number | Message 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
| Parameter | Type | Description |
|---|---|---|
options | DispatchModalSubmitOptions | Modal 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
| Parameter | Type | Description |
|---|---|---|
options | { action: "add" | "remove"; answerId: number; messageId: string; userId: string; } | Poll vote options |
options.action | "add" | "remove" | - |
options.answerId | number | - |
options.messageId | string | - |
options.userId | string | - |
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
| Parameter | Type | Description |
|---|---|---|
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.channelId | string | - |
options.emoji | { id: null | string; name: string; } | - |
options.emoji.id | null | string | - |
options.emoji.name | string | - |
options.guildId? | string | - |
options.messageId | string | - |
options.userId | string | - |
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
| Parameter | Type | Description |
|---|---|---|
options | DispatchSelectMenuOptions | Select 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
| Parameter | Type | Description |
|---|---|---|
options | DispatchSlashCommandOptions | Slash 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
| Parameter | Type | Description |
|---|---|---|
options | DispatchThreadCreateOptions | Thread 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
| Parameter | Type | Description |
|---|---|---|
threadId | string | ID of the thread to delete |
Returns
Promise<void>
dispatchThreadJoin()
dispatchThreadJoin(threadId): Promise<void>Dispatch THREAD_MEMBER_UPDATE for bot joining a thread
Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string | ID of the thread to join |
Returns
Promise<void>
dispatchThreadLeave()
dispatchThreadLeave(threadId): Promise<void>Dispatch THREAD_MEMBER_UPDATE for bot leaving a thread
Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string | ID 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
| Parameter | Type | Description |
|---|---|---|
guildId | string | ID 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
| Parameter | Type | Description |
|---|---|---|
threadId | string | ID of the thread |
userId | string | ID 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
| Parameter | Type | Description |
|---|---|---|
threadId | string | ID of the thread |
userId | string | ID 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
| Parameter | Type | Description |
|---|---|---|
threadId | string | ID 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(): SessionRecordingExport the session as a recording object Returns a JSON-serializable recording with metadata and all actions
Returns
Implementation of
getActionContext()
getActionContext(): null | ActionContextGet the current action context.
Returns
null | ActionContext
Implementation of
getActions()
getActions(): RecordedAction[]Get all recorded actions for test assertions
Returns
Implementation of
getActionsByType()
getActionsByType(type): RecordedAction[]Get actions by type
Parameters
| Parameter | Type |
|---|---|
type | ActionType |
Returns
Implementation of
getActionsSince()
getActionsSince(timestamp): RecordedAction[]Get actions since a specific timestamp
Parameters
| Parameter | Type |
|---|---|
timestamp | number |
Returns
Implementation of
getCurrentUser()
getCurrentUser(): MockUserGet the current acting user
Returns
getDispatches()
getDispatches(): RecordedAction[]Get dispatch events (server → client)
Returns
Implementation of
getGatewayMessages()
getGatewayMessages(): RecordedAction[]Get all Gateway WebSocket message actions (client → server)
Returns
Implementation of
getInteractionResponses()
getInteractionResponses(): RecordedAction[]Get all interaction response actions
Returns
Implementation of
ISession.getInteractionResponses
getLogs()
getLogs(): SessionLogEntry[]Get all captured logs
Returns
SessionLogEntry[]
Implementation of
getLogsSince()
getLogsSince(timestamp): SessionLogEntry[]Get logs since a timestamp
Parameters
| Parameter | Type |
|---|---|
timestamp | number |
Returns
SessionLogEntry[]
Implementation of
getMessagesSent()
getMessagesSent(): RecordedAction[]Get message_sent actions
Returns
Implementation of
getPermissionDeniedEvents()
getPermissionDeniedEvents(): PermissionDeniedEvent[]Get recent permission denied events
Returns
PermissionDeniedEvent[]
getPermissionOverride()
getPermissionOverride(id): undefined | PermissionOverrideGet a specific permission override by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | PermissionOverride
getPermissionOverrides()
getPermissionOverrides(): PermissionOverride[]Get all permission overrides
Returns
PermissionOverride[]
getRestRequests()
getRestRequests(): RecordedAction[]Get all REST request actions
Returns
Implementation of
getUser()
getUser(userId): undefined | MockUserGet a specific user by ID
Parameters
| Parameter | Type |
|---|---|
userId | string |
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
| Parameter | Type | Description |
|---|---|---|
userId | string | The user ID to invoke as |
commandName | string | The command name |
options? | Record<string, string | number | boolean> | Optional command options |
Returns
Promise<MockInteraction>
The created interaction
recordAction()
recordAction(
type,
data,
options?): RecordedActionRecord an action from the bot (REST API call, Gateway message, etc.) Automatically merges in the current action context if metadata/triggeredBy not provided.
Parameters
| Parameter | Type |
|---|---|
type | ActionType |
data | unknown |
options? | RecordActionOptions |
Returns
Implementation of
recordLog()
recordLog(entry): SessionLogEntryRecord a log entry from a connected bot
Parameters
| Parameter | Type | Description |
|---|---|---|
entry | Omit<SessionLogEntry, "id"> | The log entry (without id, which will be generated) |
Returns
SessionLogEntry
Implementation of
recordPermissionDenied()
recordPermissionDenied(event): PermissionDeniedEventRecord a permission denied event (for Stage UI display)
Parameters
| Parameter | Type |
|---|---|
event | Omit<PermissionDeniedEvent, "timestamp" | "sessionId"> |
Returns
PermissionDeniedEvent
removePermissionOverride()
removePermissionOverride(id): booleanRemove a permission override by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
true if the override was removed, false if not found
reset()
reset(): voidReset session state (clear guilds, channels, etc. but keep bot user)
Returns
void
Implementation of
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
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path to save the recording |
Returns
Promise<void>
sendMessageAs()
sendMessageAs(
userId,
channelId,
content): Promise<MockMessage>Send a message as a specific user
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | The user ID to send as |
channelId | string | The channel to send to |
content | string | The message content |
Returns
Promise<MockMessage>
The created message
setActionContext()
setActionContext(context): voidSet the action context for metadata propagation. Actions recorded while this context is active will inherit the metadata.
Parameters
| Parameter | Type |
|---|---|
context | null | ActionContext |
Returns
void
Implementation of
setCurrentUser()
setCurrentUser(userId): undefined | MockUserSet the current acting user by ID (switches to existing user)
Parameters
| Parameter | Type |
|---|---|
userId | string |
Returns
undefined | MockUser
The switched user, or undefined if not found
setRateLimitSimulation()
setRateLimitSimulation(config, retryAfter): voidEnable rate limit simulation for testing When enabled, matching API requests will return a 429 response
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
config | | boolean | { enabled: boolean; persistent: boolean; retryAfter: number; scope: "all" | "messages" | "interactions" | "guilds" | "channels"; } | undefined | Rate limit configuration or simple enabled boolean for backward compatibility |
retryAfter | number | 1 | Retry-After value in seconds (only used when config is boolean) |
Returns
void
Implementation of
ISession.setRateLimitSimulation
startAutoArchive()
startAutoArchive(intervalMs): voidStart automatic thread archiving based on auto_archive_duration
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
intervalMs | number | 60000 | How often to check for inactive threads (default: 60000ms / 1 minute) |
Returns
void
Implementation of
stopAutoArchive()
stopAutoArchive(): voidStop automatic thread archiving
Returns
void
Implementation of
updateUser()
updateUser(userId, updates): undefined | MockUserUpdate a user's properties
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | The user ID to update |
updates | Partial<{ 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
