PluginContext
Defined in: plugins/holocron-plugin-discord/src/index.ts:33
The shared state the Discord plugin’s capability and probes are built from.
Properties
Section titled “Properties”bot: () =>
object
Defined in: plugins/holocron-plugin-discord/src/index.ts:44
Memoized — resolves the bot token on the first provisioning call, or when holocron doctor checks a provider that has a guildId; send() and describe() never touch it.
Returns
Section titled “Returns”object
application
Section titled “application”application:
object
application.get
Section titled “application.get”get: () =>
Promise<DiscordApplication>
GET /applications/@me — the bot’s own application: description, tags, install settings, URLs.
Returns
Section titled “Returns”Promise<DiscordApplication>
application.modify
Section titled “application.modify”modify: (
body) =>Promise<DiscordApplication>
PATCH /applications/@me — only what is in the body changes.
Parameters
Section titled “Parameters”ModifyApplicationInput
Returns
Section titled “Returns”Promise<DiscordApplication>
channels
Section titled “channels”channels:
object
channels.addReaction
Section titled “channels.addReaction”addReaction: (
channelId,messageId,emoji) =>Promise<void>
PUT /channels/:id/messages/:id/reactions/:emoji/@me — the bot reacts; a reaction it already has is a no-op. emoji is a Unicode emoji or name:id for a custom one.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
string
Returns
Section titled “Returns”Promise<void>
channels.createInvite
Section titled “channels.createInvite”createInvite: (
channelId,body?) =>Promise<DiscordInvite>
POST /channels/:id/invites — a join link for the server, e.g. to hand over a newly created one.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
CreateInviteInput
Returns
Section titled “Returns”Promise<DiscordInvite>
channels.createMessage
Section titled “channels.createMessage”createMessage: (
channelId,body) =>Promise<DiscordMessage>
POST /channels/:id/messages as the bot. Mentions are off unless allowed_mentions asks for them.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
CreateMessageInput
Returns
Section titled “Returns”Promise<DiscordMessage>
channels.createWebhook
Section titled “channels.createWebhook”createWebhook: (
channelId,body) =>Promise<DiscordChannelWebhook>
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
string
Returns
Section titled “Returns”Promise<DiscordChannelWebhook>
channels.deleteMessage
Section titled “channels.deleteMessage”deleteMessage: (
channelId,messageId) =>Promise<void>
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<void>
channels.editMessage
Section titled “channels.editMessage”editMessage: (
channelId,messageId,body) =>Promise<DiscordMessage>
PATCH /channels/:id/messages/:id — a message this bot posted. Mentions are off unless allowed_mentions asks for them.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
EditMessageInput
Returns
Section titled “Returns”Promise<DiscordMessage>
channels.message
Section titled “channels.message”message: (
channelId,messageId) =>Promise<DiscordChannelMessage>
GET /channels/:id/messages/:id — one message, e.g. the first message of a forum post (its id is the post’s).
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<DiscordChannelMessage>
channels.messages
Section titled “channels.messages”messages: (
channelId,limit?,before?) =>Promise<DiscordChannelMessage[]>
GET /channels/:id/messages — the newest messages first, to read a post back. before is a message id: read the page older than it.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
limit?
Section titled “limit?”number
before?
Section titled “before?”string
Returns
Section titled “Returns”Promise<DiscordChannelMessage[]>
channels.modify
Section titled “channels.modify”modify: (
channelId,body) =>Promise<DiscordChannel>
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
ModifyChannelInput
Returns
Section titled “Returns”Promise<DiscordChannel>
channels.pin
Section titled “channels.pin”pin: (
channelId,messageId) =>Promise<void>
PUT /channels/:id/pins/:id — pins a message; one already pinned is a no-op.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<void>
channels.startThread
Section titled “channels.startThread”startThread: (
channelId,messageId,body) =>Promise<DiscordThread>
POST /channels/:id/messages/:id/threads — starts a public thread on a message of a text channel, as the bot.
Not idempotent (a message has one thread; a second try is a 400): read the message’s thread first. A 403
says the bot needs Create Public Threads (and Send Messages in Threads to post in it).
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
StartThreadInput
Returns
Section titled “Returns”Promise<DiscordThread>
channels.webhooks
Section titled “channels.webhooks”webhooks: (
channelId) =>Promise<DiscordChannelWebhook[]>
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”Promise<DiscordChannelWebhook[]>
guilds
Section titled “guilds”guilds:
object
guilds.addMemberRole
Section titled “guilds.addMemberRole”addMemberRole: (
guildId,userId,roleId) =>Promise<void>
PUT /guilds/:id/members/:id/roles/:id — gives the member the role; giving one they have is a no-op.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
userId
Section titled “userId”string
roleId
Section titled “roleId”string
Returns
Section titled “Returns”Promise<void>
guilds.channels
Section titled “guilds.channels”channels: (
guildId) =>Promise<DiscordChannel[]>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<DiscordChannel[]>
guilds.create
Section titled “guilds.create”create: (
body) =>Promise<DiscordGuild>
POST /guilds — a new server the bot owns. Not idempotent: look one up by name (users.guilds) before retrying.
Parameters
Section titled “Parameters”CreateGuildInput
Returns
Section titled “Returns”Promise<DiscordGuild>
guilds.createChannel
Section titled “guilds.createChannel”createChannel: (
guildId,body) =>Promise<DiscordChannel>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
CreateChannelInput
Returns
Section titled “Returns”Promise<DiscordChannel>
guilds.createEmoji
Section titled “guilds.createEmoji”createEmoji: (
guildId,body) =>Promise<DiscordEmoji>
POST /guilds/:id/emojis — makes a custom emoji from image, a data: URI (at most 256 KiB: JPEG, PNG, GIF,
WebP or AVIF). Needs Create Guild Expressions. Discord does not apply the usual rate limit headers to it.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
CreateEmojiInput
Returns
Section titled “Returns”Promise<DiscordEmoji>
guilds.createRole
Section titled “guilds.createRole”createRole: (
guildId,body) =>Promise<DiscordRole>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
CreateRoleInput
Returns
Section titled “Returns”Promise<DiscordRole>
guilds.delete
Section titled “guilds.delete”delete: (
guildId) =>Promise<void>
DELETE /guilds/:id — only the owner may; a 404 counts as done.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<void>
guilds.deleteEmoji
Section titled “guilds.deleteEmoji”deleteEmoji: (
guildId,emojiId) =>Promise<void>
DELETE /guilds/:id/emojis/:id — deletes a custom emoji, and so every reaction made with it. The bot may delete
an emoji it made with Create Guild Expressions; one made by someone else needs Manage Guild Expressions.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
emojiId
Section titled “emojiId”string
Returns
Section titled “Returns”Promise<void>
guilds.emojis
Section titled “guilds.emojis”emojis: (
guildId) =>Promise<DiscordEmoji[]>
GET /guilds/:id/emojis — custom emoji, for welcome screen and onboarding ids.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<DiscordEmoji[]>
guilds.get
Section titled “guilds.get”get: (
guildId) =>Promise<DiscordGuild>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<DiscordGuild>
guilds.member
Section titled “guilds.member”member: (
guildId,userId) =>Promise<DiscordGuildMember>
GET /guilds/:id/members/:id — one member and the roles they hold. A 404 means either they are not in the server or the guild id is unknown; read the error body to tell them apart.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<DiscordGuildMember>
guilds.members
Section titled “guilds.members”members: (
guildId,opts?) =>Promise<DiscordGuildMember[]>
GET /guilds/:id/members — one page. Needs the privileged Server Members Intent, switched on in the
developer portal; without it Discord answers 403.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
ListMembersInput
Returns
Section titled “Returns”Promise<DiscordGuildMember[]>
guilds.membersWithRole
Section titled “guilds.membersWithRole”membersWithRole: (
guildId,roleId) =>Promise<DiscordGuildMember[]>
Every member holding the role, read page by page; needs the same intent as members.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
roleId
Section titled “roleId”string
Returns
Section titled “Returns”Promise<DiscordGuildMember[]>
guilds.modify
Section titled “guilds.modify”modify: (
guildId,body) =>Promise<DiscordGuild>
PATCH /guilds/:id — verification, notification defaults, content filter, system channels.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
ModifyGuildInput
Returns
Section titled “Returns”Promise<DiscordGuild>
guilds.modifyOnboarding
Section titled “guilds.modifyOnboarding”modifyOnboarding: (
guildId,body) =>Promise<DiscordOnboarding>
PUT replaces the whole onboarding config, so send every prompt you want to keep. Discord has no
conditional write: two callers that read, edit and PUT at once, the later one wins.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Omit<DiscordOnboarding, "guild_id">
Returns
Section titled “Returns”Promise<DiscordOnboarding>
guilds.modifyRole
Section titled “guilds.modifyRole”modifyRole: (
guildId,roleId,body) =>Promise<DiscordRole>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
roleId
Section titled “roleId”string
ModifyRoleInput
Returns
Section titled “Returns”Promise<DiscordRole>
guilds.modifyWelcomeScreen
Section titled “guilds.modifyWelcomeScreen”modifyWelcomeScreen: (
guildId,body) =>Promise<DiscordWelcomeScreen>
Needs the community features on.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
ModifyWelcomeScreenInput
Returns
Section titled “Returns”Promise<DiscordWelcomeScreen>
guilds.onboarding
Section titled “guilds.onboarding”onboarding: (
guildId) =>Promise<DiscordOnboarding>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<DiscordOnboarding>
guilds.removeMemberRole
Section titled “guilds.removeMemberRole”removeMemberRole: (
guildId,userId,roleId) =>Promise<void>
DELETE /guilds/:id/members/:id/roles/:id — takes the role away; taking one they lack is a no-op.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
userId
Section titled “userId”string
roleId
Section titled “roleId”string
Returns
Section titled “Returns”Promise<void>
guilds.renameEmoji
Section titled “guilds.renameEmoji”renameEmoji: (
guildId,emojiId,name) =>Promise<DiscordEmoji>
PATCH /guilds/:id/emojis/:id — renames a custom emoji (the image cannot change). The bot may change an emoji it
made with Create Guild Expressions; one made by someone else needs Manage Guild Expressions.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
emojiId
Section titled “emojiId”string
string
Returns
Section titled “Returns”Promise<DiscordEmoji>
guilds.roles
Section titled “guilds.roles”roles: (
guildId) =>Promise<DiscordRole[]>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<DiscordRole[]>
guilds.welcomeScreen
Section titled “guilds.welcomeScreen”welcomeScreen: (
guildId) =>Promise<DiscordWelcomeScreen>
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<DiscordWelcomeScreen>
threads
Section titled “threads”threads:
object
threads.active
Section titled “threads.active”active: (
guildId) =>Promise<DiscordThread[]>
GET /guilds/:id/threads/active — every active thread in the server, across channels.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”Promise<DiscordThread[]>
threads.archived
Section titled “threads.archived”archived: (
channelId,opts?) =>Promise<DiscordArchivedThreads>
GET /channels/:id/threads/archived/public — one page of a channel’s archived threads, newest archived first.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
ListArchivedThreadsInput
Returns
Section titled “Returns”Promise<DiscordArchivedThreads>
threads.createForumPost
Section titled “threads.createForumPost”createForumPost: (
channelId,body) =>Promise<DiscordForumPost>
POST /channels/:id/threads in a forum channel — a new post with its first message. Not idempotent: look
the post up (inChannel) before retrying. Mentions in the first message are off unless asked for.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
CreateForumPostInput
Returns
Section titled “Returns”Promise<DiscordForumPost>
threads.delete
Section titled “threads.delete”delete: (
threadId) =>Promise<void>
DELETE /channels/:id on a thread — deletes the thread and its messages. A 404 counts as done, as when a retry follows a lost response.
Parameters
Section titled “Parameters”threadId
Section titled “threadId”string
Returns
Section titled “Returns”Promise<void>
threads.inChannel
Section titled “threads.inChannel”inChannel: (
guildId,channelId) =>Promise<DiscordThread[]>
Every post in a forum channel, active and archived: Discord hides a post that has been quiet for a while, so
a lookup that read only the active ones would miss it and make it again. Reads every page; to look for one
post, read pages and stop at it.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
channelId
Section titled “channelId”string
Returns
Section titled “Returns”Promise<DiscordThread[]>
threads.messages
Section titled “threads.messages”messages: (
threadId) =>Promise<DiscordChannelMessage[]>
Every message of a thread, oldest first, read in pages of 100 (at most MAX_THREAD_PAGES pages).
Parameters
Section titled “Parameters”threadId
Section titled “threadId”string
Returns
Section titled “Returns”Promise<DiscordChannelMessage[]>
threads.modify
Section titled “threads.modify”modify: (
threadId,body) =>Promise<DiscordThread>
PATCH /channels/:id on a thread — its title, tags, archived or locked state. Writing to an archived post unarchives it.
Parameters
Section titled “Parameters”threadId
Section titled “threadId”string
ModifyThreadInput
Returns
Section titled “Returns”Promise<DiscordThread>
threads.pages
Section titled “threads.pages”pages: (
guildId,channelId) =>AsyncGenerator<DiscordThread[]>
The posts of a forum channel in pages, newest first: the active ones (one call, for the whole server), then each archived page (100 a call, newest archived first). A caller that stops reading stops the calls, so a lookup that finds its post near the top costs a call or two and not the whole archive.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
channelId
Section titled “channelId”string
Returns
Section titled “Returns”AsyncGenerator<DiscordThread[]>
threads.post
Section titled “threads.post”post: (
threadId,body) =>Promise<DiscordMessage>
Posts a message in a thread (the thread’s id is the channel id its messages go to), as the bot. Mentions are off unless asked for. A 403 says the bot needs Send Messages in Threads.
Parameters
Section titled “Parameters”threadId
Section titled “threadId”string
CreateMessageInput
Returns
Section titled “Returns”Promise<DiscordMessage>
users:
object
users.get
Section titled “users.get”get: (
userId) =>Promise<DiscordUser>
GET /users/:id — a user’s name, for reports that would otherwise show a bare id.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<DiscordUser>
users.guilds
Section titled “users.guilds”guilds: (
opts?) =>Promise<DiscordUserGuild[]>
GET /users/@me/guilds — one page of the servers the bot is in, each with whether it owns it. This is
how a retry finds a server guilds.create already made, since that call is not idempotent.
Parameters
Section titled “Parameters”ListUserGuildsInput
Returns
Section titled “Returns”Promise<DiscordUserGuild[]>
users.me
Section titled “users.me”me: () =>
Promise<DiscordUser>
GET /users/@me — the bot’s own user; a cheap token check.
Returns
Section titled “Returns”Promise<DiscordUser>
webhooks
Section titled “webhooks”webhooks:
object
webhooks.delete
Section titled “webhooks.delete”delete: (
webhookId) =>Promise<void>
A 404 counts as done: the webhook is already gone, as when a retry follows a lost response.
Parameters
Section titled “Parameters”webhookId
Section titled “webhookId”string
Returns
Section titled “Returns”Promise<void>
webhooks.modify
Section titled “webhooks.modify”modify: (
webhookId,body) =>Promise<DiscordChannelWebhook>
PATCH /webhooks/:id — name and avatar of a webhook this bot manages.
Parameters
Section titled “Parameters”webhookId
Section titled “webhookId”string
ModifyWebhookInput
Returns
Section titled “Returns”Promise<DiscordChannelWebhook>
client
Section titled “client”client:
object
Defined in: plugins/holocron-plugin-discord/src/index.ts:37
The webhook client used to send messages.
webhooks
Section titled “webhooks”webhooks:
object
webhooks.deleteMessage
Section titled “webhooks.deleteMessage”deleteMessage: (
id,token,messageId) =>Promise<void>
Parameters
Section titled “Parameters”string
string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<void>
webhooks.editMessage
Section titled “webhooks.editMessage”editMessage: (
id,token,messageId,body) =>Promise<void>
Parameters
Section titled “Parameters”string
string
messageId
Section titled “messageId”string
number
Returns
Section titled “Returns”Promise<void>
webhooks.execute
Section titled “webhooks.execute”execute: (
id,token,content) =>Promise<void>
Parameters
Section titled “Parameters”string
string
content
Section titled “content”string
Returns
Section titled “Returns”Promise<void>
webhooks.executeAndWait
Section titled “webhooks.executeAndWait”executeAndWait: (
id,token,content,options?) =>Promise<{channel_id:string;id:string; }>
Parameters
Section titled “Parameters”string
string
content
Section titled “content”string
options?
Section titled “options?”suppressEmbeds?
Section titled “suppressEmbeds?”boolean
Returns
Section titled “Returns”Promise<{ channel_id: string; id: string; }>
webhooks.get
Section titled “webhooks.get”get: (
id,token) =>Promise<DiscordWebhookInfo>
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<DiscordWebhookInfo>
defaultWebhookUrl
Section titled “defaultWebhookUrl”defaultWebhookUrl: () =>
string
Defined in: plugins/holocron-plugin-discord/src/index.ts:42
Memoized — the resolved “token” IS Discord’s default webhook URL, and it is
resolved on first send(), not at plugin load. describe() never calls it.
Returns
Section titled “Returns”string
oauth: (
redirectUri) =>Promise<{authorizeUrl: (input) =>string;connections: (accessToken) =>Promise<DiscordConnection[]>;exchangeCode: (code) =>Promise<DiscordOAuthToken>;refresh: (refreshToken) =>Promise<DiscordOAuthToken>;revoke: (token) =>Promise<void>;user: (accessToken) =>Promise<DiscordOAuthUser>; }>
Defined in: plugins/holocron-plugin-discord/src/index.ts:46
Builds the OAuth client for one redirect URI; resolves the application id and the client secret on first use.
Parameters
Section titled “Parameters”redirectUri
Section titled “redirectUri”string
Returns
Section titled “Returns”Promise<{ authorizeUrl: (input) => string; connections: (accessToken) => Promise<DiscordConnection[]>; exchangeCode: (code) => Promise<DiscordOAuthToken>; refresh: (refreshToken) => Promise<DiscordOAuthToken>; revoke: (token) => Promise<void>; user: (accessToken) => Promise<DiscordOAuthUser>; }>
options
Section titled “options”options:
DiscordPluginOptions
Defined in: plugins/holocron-plugin-discord/src/index.ts:35
The options the plugin was created with.