Skip to content

SupCaller

The SupCaller object provides information about what invoked the current patch — either a user running it directly or another patch calling it via patch.run() or patch.public.

Access it via sup.caller.

Example
// Check who called this patch
if (sup.caller.type === 'user') {
return `Run by ${sup.caller.user.username}`;
} else {
return `Called by patch ${sup.caller.patch.name}`;
}
// Check if this is a preview invocation
if (sup.caller.isPreview) {
return "This is a preview — not yet shared with chat";
}

Properties

type

type: 'user' | 'patch'

'user' when the patch was invoked directly by a user, 'patch' when called by another patch (via patch.run() or patch.public).

isPreview

type: boolean

Whether this invocation is a preview (unsent draft). When true, the message has not been shared with the chat yet — the user sees a “Share with chat” button.

user

type: SupUser optional

The user who invoked this patch. Only set when type === 'user', otherwise undefined.

if (sup.caller.type === 'user') {
const username = sup.caller.user.username;
const pfp = sup.caller.user.pfp;
}

patch

type: SupPatch optional

The patch that called this patch. Only set when type === 'patch', otherwise undefined.

if (sup.caller.type === 'patch') {
const callerName = sup.caller.patch.name;
const callerAuthor = sup.caller.patch.author.username;
}