mini-interactions 0.0.0-stage → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/LICENSE +21 -0
  2. package/MIGRATION.md +126 -0
  3. package/README.md +253 -2
  4. package/dist/bot.d.ts +58 -0
  5. package/dist/bot.js +217 -0
  6. package/dist/builders/ActionRowBuilder.d.ts +22 -0
  7. package/dist/builders/ActionRowBuilder.js +33 -0
  8. package/dist/builders/AutomodRuleBuilder.d.ts +45 -0
  9. package/dist/builders/AutomodRuleBuilder.js +151 -0
  10. package/dist/builders/ButtonBuilder.d.ts +53 -0
  11. package/dist/builders/ButtonBuilder.js +124 -0
  12. package/dist/builders/ChannelSelectMenuBuilder.d.ts +53 -0
  13. package/dist/builders/ChannelSelectMenuBuilder.js +105 -0
  14. package/dist/builders/CheckboxBuilder.d.ts +20 -0
  15. package/dist/builders/CheckboxBuilder.js +20 -0
  16. package/dist/builders/CheckboxGroupBuilder.d.ts +25 -0
  17. package/dist/builders/CheckboxGroupBuilder.js +48 -0
  18. package/dist/builders/EmbedBuilder.d.ts +33 -0
  19. package/dist/builders/EmbedBuilder.js +103 -0
  20. package/dist/builders/FileUploadBuilder.d.ts +17 -0
  21. package/dist/builders/FileUploadBuilder.js +22 -0
  22. package/dist/builders/LabelBuilder.d.ts +16 -0
  23. package/dist/builders/LabelBuilder.js +21 -0
  24. package/dist/builders/MiniContainerBuilder.d.ts +131 -0
  25. package/dist/builders/MiniContainerBuilder.js +347 -0
  26. package/dist/builders/ModalBuilder.d.ts +16 -0
  27. package/dist/builders/ModalBuilder.js +36 -0
  28. package/dist/builders/ModalChannelSelectMenuBuilder.d.ts +29 -0
  29. package/dist/builders/ModalChannelSelectMenuBuilder.js +25 -0
  30. package/dist/builders/ModalMentionableSelectMenuBuilder.d.ts +53 -0
  31. package/dist/builders/ModalMentionableSelectMenuBuilder.js +87 -0
  32. package/dist/builders/ModalRoleSelectMenuBuilder.d.ts +27 -0
  33. package/dist/builders/ModalRoleSelectMenuBuilder.js +24 -0
  34. package/dist/builders/ModalStringSelectMenuBuilder.d.ts +62 -0
  35. package/dist/builders/ModalStringSelectMenuBuilder.js +120 -0
  36. package/dist/builders/ModalUserSelectMenuBuilder.d.ts +53 -0
  37. package/dist/builders/ModalUserSelectMenuBuilder.js +96 -0
  38. package/dist/builders/RadioBuilder.d.ts +22 -0
  39. package/dist/builders/RadioBuilder.js +36 -0
  40. package/dist/builders/RoleSelectMenuBuilder.d.ts +47 -0
  41. package/dist/builders/RoleSelectMenuBuilder.js +92 -0
  42. package/dist/builders/StringSelectMenuBuilder.d.ts +52 -0
  43. package/dist/builders/StringSelectMenuBuilder.js +104 -0
  44. package/dist/builders/StringSelectMenuOptionBuilder.d.ts +46 -0
  45. package/dist/builders/StringSelectMenuOptionBuilder.js +106 -0
  46. package/dist/builders/TextInputBuilder.d.ts +23 -0
  47. package/dist/builders/TextInputBuilder.js +26 -0
  48. package/dist/builders/index.d.ts +44 -0
  49. package/dist/builders/index.js +22 -0
  50. package/dist/builders/shared.d.ts +8 -0
  51. package/dist/builders/shared.js +11 -0
  52. package/dist/commands/CommandBuilder.d.ts +278 -0
  53. package/dist/commands/CommandBuilder.js +687 -0
  54. package/dist/commands/ContextMenuCommandBuilder.d.ts +94 -0
  55. package/dist/commands/ContextMenuCommandBuilder.js +145 -0
  56. package/dist/core/http/DiscordRestClient.d.ts +400 -0
  57. package/dist/core/http/DiscordRestClient.js +988 -0
  58. package/dist/core/interactions/InteractionContext.d.ts +33 -0
  59. package/dist/core/interactions/InteractionContext.js +61 -0
  60. package/dist/core/interactions/InteractionVerifier.d.ts +8 -0
  61. package/dist/core/interactions/InteractionVerifier.js +9 -0
  62. package/dist/core/messages/DiscordSentMessage.d.ts +32 -0
  63. package/dist/core/messages/DiscordSentMessage.js +64 -0
  64. package/dist/core/messages/message-payloads.d.ts +94 -0
  65. package/dist/core/messages/message-payloads.js +99 -0
  66. package/dist/core/webhooks/DiscordWebhook.d.ts +14 -0
  67. package/dist/core/webhooks/DiscordWebhook.js +69 -0
  68. package/dist/database/MiniDataBuilder.d.ts +61 -0
  69. package/dist/database/MiniDataBuilder.js +98 -0
  70. package/dist/database/MiniDatabase.d.ts +67 -0
  71. package/dist/database/MiniDatabase.js +222 -0
  72. package/dist/database/MiniDatabaseBuilder.d.ts +58 -0
  73. package/dist/database/MiniDatabaseBuilder.js +84 -0
  74. package/dist/database/index.d.ts +5 -0
  75. package/dist/database/index.js +3 -0
  76. package/dist/identity/ApplicationIdentityProfile.d.ts +188 -0
  77. package/dist/identity/ApplicationIdentityProfile.js +207 -0
  78. package/dist/index.d.ts +54 -0
  79. package/dist/index.js +34 -0
  80. package/dist/lobby/Lobby.d.ts +150 -0
  81. package/dist/lobby/Lobby.js +90 -0
  82. package/dist/node/MiniInteraction.d.ts +199 -0
  83. package/dist/node/MiniInteraction.js +861 -0
  84. package/dist/node/index.d.ts +2 -0
  85. package/dist/node/index.js +1 -0
  86. package/dist/oauth2/DiscordOAuth.d.ts +49 -0
  87. package/dist/oauth2/DiscordOAuth.js +113 -0
  88. package/dist/oauth2/OAuth2Builder.d.ts +296 -0
  89. package/dist/oauth2/OAuth2Builder.js +435 -0
  90. package/dist/oauth2/OAuth2Scopes.d.ts +285 -0
  91. package/dist/oauth2/OAuth2Scopes.js +438 -0
  92. package/dist/oauth2/OAuthTokenStorage.d.ts +37 -0
  93. package/dist/oauth2/OAuthTokenStorage.js +109 -0
  94. package/dist/oauth2/index.d.ts +8 -0
  95. package/dist/oauth2/index.js +4 -0
  96. package/dist/router/AutocompleteContext.d.ts +36 -0
  97. package/dist/router/AutocompleteContext.js +82 -0
  98. package/dist/router/InteractionRouter.d.ts +82 -0
  99. package/dist/router/InteractionRouter.js +225 -0
  100. package/dist/types/ButtonStyle.d.ts +16 -0
  101. package/dist/types/ButtonStyle.js +17 -0
  102. package/dist/types/ChannelType.d.ts +2 -0
  103. package/dist/types/ChannelType.js +2 -0
  104. package/dist/types/Commands.d.ts +35 -0
  105. package/dist/types/Commands.js +1 -0
  106. package/dist/types/ComponentTypes.d.ts +19 -0
  107. package/dist/types/ComponentTypes.js +1 -0
  108. package/dist/types/InteractionFlags.d.ts +5 -0
  109. package/dist/types/InteractionFlags.js +6 -0
  110. package/dist/types/PermissionFlags.d.ts +56 -0
  111. package/dist/types/PermissionFlags.js +5 -0
  112. package/dist/types/RoleConnectionMetadata.d.ts +14 -0
  113. package/dist/types/RoleConnectionMetadata.js +1 -0
  114. package/dist/types/RoleConnectionMetadataTypes.d.ts +11 -0
  115. package/dist/types/RoleConnectionMetadataTypes.js +12 -0
  116. package/dist/types/SeparatorSpacingSize.d.ts +2 -0
  117. package/dist/types/SeparatorSpacingSize.js +2 -0
  118. package/dist/types/checkbox.d.ts +16 -0
  119. package/dist/types/checkbox.js +12 -0
  120. package/dist/types/discord.d.ts +2 -0
  121. package/dist/types/discord.js +1 -0
  122. package/dist/types/radio.d.ts +12 -0
  123. package/dist/types/radio.js +10 -0
  124. package/dist/types/validation.d.ts +14 -0
  125. package/dist/types/validation.js +40 -0
  126. package/dist/utils/CommandInteractionOptions.d.ts +66 -0
  127. package/dist/utils/CommandInteractionOptions.js +364 -0
  128. package/dist/utils/ContextMenuInteraction.d.ts +76 -0
  129. package/dist/utils/ContextMenuInteraction.js +152 -0
  130. package/dist/utils/MessageComponentInteraction.d.ts +148 -0
  131. package/dist/utils/MessageComponentInteraction.js +259 -0
  132. package/dist/utils/ModalSubmitInteraction.d.ts +86 -0
  133. package/dist/utils/ModalSubmitInteraction.js +267 -0
  134. package/dist/utils/cdn.d.ts +30 -0
  135. package/dist/utils/cdn.js +60 -0
  136. package/dist/utils/formatting.d.ts +76 -0
  137. package/dist/utils/formatting.js +132 -0
  138. package/dist/utils/interactionMessageHelpers.d.ts +40 -0
  139. package/dist/utils/interactionMessageHelpers.js +118 -0
  140. package/dist/utils/localization.d.ts +25 -0
  141. package/dist/utils/localization.js +38 -0
  142. package/dist/utils/snowflake.d.ts +19 -0
  143. package/dist/utils/snowflake.js +32 -0
  144. package/dist/webhooks/WebhookEvent.d.ts +229 -0
  145. package/dist/webhooks/WebhookEvent.js +59 -0
  146. package/dist/webhooks/WebhookEventRouter.d.ts +123 -0
  147. package/dist/webhooks/WebhookEventRouter.js +160 -0
  148. package/dist/webhooks/WebhookEventVerifier.d.ts +33 -0
  149. package/dist/webhooks/WebhookEventVerifier.js +37 -0
  150. package/dist/webhooks/index.d.ts +6 -0
  151. package/dist/webhooks/index.js +3 -0
  152. package/package.json +90 -4
@@ -0,0 +1,94 @@
1
+ import { ApplicationCommandType, type LocalizationMap, type Permissions, type RESTPostAPIContextMenuApplicationCommandsJSONBody, type RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody } from "discord-api-types/v10";
2
+ import { CommandContext, IntegrationType } from "./CommandBuilder.js";
3
+ /**
4
+ * Supported non-chat command types.
5
+ */
6
+ type NonChatCommandType = ApplicationCommandType.User | ApplicationCommandType.Message | ApplicationCommandType.PrimaryEntryPoint;
7
+ type NonChatCommandPayload<T extends NonChatCommandType> = T extends ApplicationCommandType.PrimaryEntryPoint ? RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody : RESTPostAPIContextMenuApplicationCommandsJSONBody;
8
+ /**
9
+ * Base data structure for context menu and primary entry point commands.
10
+ */
11
+ type ContextMenuCommandData<T extends NonChatCommandType> = Partial<Omit<NonChatCommandPayload<T>, "contexts" | "integration_types" | "type">> & {
12
+ type: T;
13
+ contexts?: CommandContext[] | null;
14
+ integration_types?: IntegrationType[];
15
+ };
16
+ /**
17
+ * Base builder for context menu commands (User and Message commands).
18
+ */
19
+ declare abstract class BaseContextMenuCommandBuilder<T extends NonChatCommandType> {
20
+ protected readonly data: ContextMenuCommandData<T>;
21
+ constructor(type: T);
22
+ /**
23
+ * Sets the command name.
24
+ * Context menu command names can be up to 32 characters and are displayed in the UI.
25
+ */
26
+ setName(name: string): this;
27
+ /**
28
+ * Sets the localized names for the command.
29
+ */
30
+ setNameLocalizations(nameLocalizations: LocalizationMap | null): this;
31
+ /**
32
+ * Sets the default member permissions required to use this command.
33
+ */
34
+ setDefaultMemberPermissions(permissions: Permissions | null): this;
35
+ /**
36
+ * Sets whether the command is available in direct messages.
37
+ */
38
+ setDMPermission(dmPermission: boolean): this;
39
+ /**
40
+ * Marks the command as not safe for work.
41
+ */
42
+ setNSFW(nsfw: boolean): this;
43
+ /**
44
+ * Limits the contexts in which the command can appear.
45
+ */
46
+ setContexts(contexts: CommandContext[] | null): this;
47
+ /**
48
+ * Specifies the integration types supported by the command.
49
+ */
50
+ setIntegrationTypes(integrationTypes: IntegrationType[]): this;
51
+ /**
52
+ * Produces the final REST payload for the configured command.
53
+ */
54
+ toJSON(): NonChatCommandPayload<T>;
55
+ /**
56
+ * Allows the builder to be coerced into its JSON payload automatically.
57
+ */
58
+ valueOf(): NonChatCommandPayload<T>;
59
+ }
60
+ /**
61
+ * Builder for User context menu commands.
62
+ * These commands appear when right-clicking on a user.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const userCommand = new UserCommandBuilder()
67
+ * .setName('User Info')
68
+ * .toJSON();
69
+ * ```
70
+ */
71
+ export declare class UserCommandBuilder extends BaseContextMenuCommandBuilder<ApplicationCommandType.User> {
72
+ constructor();
73
+ }
74
+ /**
75
+ * Builder for Message context menu commands.
76
+ * These commands appear when right-clicking on a message.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const messageCommand = new MessageCommandBuilder()
81
+ * .setName('Report Message')
82
+ * .toJSON();
83
+ * ```
84
+ */
85
+ export declare class MessageCommandBuilder extends BaseContextMenuCommandBuilder<ApplicationCommandType.Message> {
86
+ constructor();
87
+ }
88
+ /**
89
+ * Builder for Primary Entry Point commands.
90
+ */
91
+ export declare class AppCommandBuilder extends BaseContextMenuCommandBuilder<ApplicationCommandType.PrimaryEntryPoint> {
92
+ constructor();
93
+ }
94
+ export {};
@@ -0,0 +1,145 @@
1
+ import { ApplicationCommandType, } from "discord-api-types/v10";
2
+ /**
3
+ * Base builder for context menu commands (User and Message commands).
4
+ */
5
+ class BaseContextMenuCommandBuilder {
6
+ data;
7
+ constructor(type) {
8
+ this.data = {
9
+ type,
10
+ };
11
+ }
12
+ /**
13
+ * Sets the command name.
14
+ * Context menu command names can be up to 32 characters and are displayed in the UI.
15
+ */
16
+ setName(name) {
17
+ if (!name || name.length === 0) {
18
+ throw new Error("Context menu command name cannot be empty");
19
+ }
20
+ if (name.length > 32) {
21
+ throw new RangeError("Context menu command name cannot exceed 32 characters");
22
+ }
23
+ this.data.name = name;
24
+ return this;
25
+ }
26
+ /**
27
+ * Sets the localized names for the command.
28
+ */
29
+ setNameLocalizations(nameLocalizations) {
30
+ this.data.name_localizations = nameLocalizations ?? undefined;
31
+ return this;
32
+ }
33
+ /**
34
+ * Sets the default member permissions required to use this command.
35
+ */
36
+ setDefaultMemberPermissions(permissions) {
37
+ this.data.default_member_permissions =
38
+ permissions === null ? null : String(permissions);
39
+ return this;
40
+ }
41
+ /**
42
+ * Sets whether the command is available in direct messages.
43
+ */
44
+ setDMPermission(dmPermission) {
45
+ this.data.dm_permission = dmPermission;
46
+ return this;
47
+ }
48
+ /**
49
+ * Marks the command as not safe for work.
50
+ */
51
+ setNSFW(nsfw) {
52
+ this.data.nsfw = nsfw;
53
+ return this;
54
+ }
55
+ /**
56
+ * Limits the contexts in which the command can appear.
57
+ */
58
+ setContexts(contexts) {
59
+ this.data.contexts = contexts ? [...contexts] : null;
60
+ return this;
61
+ }
62
+ /**
63
+ * Specifies the integration types supported by the command.
64
+ */
65
+ setIntegrationTypes(integrationTypes) {
66
+ this.data.integration_types = [...integrationTypes];
67
+ return this;
68
+ }
69
+ /**
70
+ * Produces the final REST payload for the configured command.
71
+ */
72
+ toJSON() {
73
+ const { name, type } = this.data;
74
+ if (!name) {
75
+ throw new Error("Context menu command name has not been set");
76
+ }
77
+ const contexts = this.data.contexts;
78
+ const integrationTypes = this.data.integration_types;
79
+ return {
80
+ ...this.data,
81
+ name,
82
+ type,
83
+ contexts: contexts === null
84
+ ? null
85
+ : Array.isArray(contexts)
86
+ ? [...contexts]
87
+ : undefined,
88
+ integration_types: Array.isArray(integrationTypes)
89
+ ? [...integrationTypes]
90
+ : integrationTypes ?? undefined,
91
+ };
92
+ }
93
+ /**
94
+ * Allows the builder to be coerced into its JSON payload automatically.
95
+ */
96
+ valueOf() {
97
+ return this.toJSON();
98
+ }
99
+ /**
100
+ * Formats the command as JSON when inspected in Node.js runtimes.
101
+ */
102
+ [Symbol.for("nodejs.util.inspect.custom")]() {
103
+ return this.toJSON();
104
+ }
105
+ }
106
+ /**
107
+ * Builder for User context menu commands.
108
+ * These commands appear when right-clicking on a user.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const userCommand = new UserCommandBuilder()
113
+ * .setName('User Info')
114
+ * .toJSON();
115
+ * ```
116
+ */
117
+ export class UserCommandBuilder extends BaseContextMenuCommandBuilder {
118
+ constructor() {
119
+ super(ApplicationCommandType.User);
120
+ }
121
+ }
122
+ /**
123
+ * Builder for Message context menu commands.
124
+ * These commands appear when right-clicking on a message.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const messageCommand = new MessageCommandBuilder()
129
+ * .setName('Report Message')
130
+ * .toJSON();
131
+ * ```
132
+ */
133
+ export class MessageCommandBuilder extends BaseContextMenuCommandBuilder {
134
+ constructor() {
135
+ super(ApplicationCommandType.Message);
136
+ }
137
+ }
138
+ /**
139
+ * Builder for Primary Entry Point commands.
140
+ */
141
+ export class AppCommandBuilder extends BaseContextMenuCommandBuilder {
142
+ constructor() {
143
+ super(ApplicationCommandType.PrimaryEntryPoint);
144
+ }
145
+ }
@@ -0,0 +1,400 @@
1
+ import type { APIBan, APIChannel, APIEmoji, APIEntitlement, APIGuild, APIGuildMember, APIMessage, APIRole, APISKU, APISticker, APIUser, APIWebhook, ApplicationCommandPermissionType, RESTPutAPIApplicationCommandPermissionsJSONBody, RESTPutAPIApplicationRoleConnectionMetadataJSONBody, RESTPutAPIApplicationRoleConnectionMetadataResult } from 'discord-api-types/v10';
2
+ import { type APIApplicationIdentity, type ApplicationIdentityProfile, type DynamicProfileField, type PrimaryProfileData, type UpdateIdentityProfileBody } from '../../identity/ApplicationIdentityProfile.js';
3
+ import type { APILobby, APILobbyInvite, APILobbyMember, APILobbyMessage, LobbyMemberInput, LobbyMemberUpdateInput, LobbyMetadata } from '../../lobby/Lobby.js';
4
+ import { DiscordSentMessage } from '../messages/DiscordSentMessage.js';
5
+ import { type BaseDiscordMessageOptions, type DiscordCreateThreadOptions, type DiscordReaction, type DiscordSendMessageOptions, type DiscordStartThreadOptions, type DiscordWebhookSendOptions } from '../messages/message-payloads.js';
6
+ import { DiscordWebhook } from '../webhooks/DiscordWebhook.js';
7
+ import type { DiscordChannelEditOptions } from '../messages/message-payloads.js';
8
+ export type DiscordMemberEditOptions = {
9
+ nick?: string | null;
10
+ roles?: string[];
11
+ /** Timeout until this ISO timestamp (max 28 days); null clears it. */
12
+ communicationDisabledUntil?: string | null;
13
+ };
14
+ export type DiscordRoleOptions = {
15
+ name?: string;
16
+ permissions?: string;
17
+ color?: number;
18
+ hoist?: boolean;
19
+ mentionable?: boolean;
20
+ unicodeEmoji?: string;
21
+ };
22
+ export type SendGameStatsOptions = {
23
+ /** The player's Discord user ID. */
24
+ userId: string;
25
+ /** The player's ID in *your* system (row id, UUID, username) — not a snowflake. */
26
+ providerIssuedUserId: string;
27
+ /** The player's username in your system (max 1024 chars). */
28
+ username?: string;
29
+ /** Pre-configured Discord stat keys (rank, playtime, wins, …). */
30
+ primary?: PrimaryProfileData;
31
+ /** Custom stats (max 30). */
32
+ dynamic?: DynamicProfileField[];
33
+ /**
34
+ * `"replace"` (default) stores exactly the stats you pass — Discord's native
35
+ * behaviour, where any omitted stat is deleted.
36
+ * `"merge"` reads the profile first and merges by key, preserving stats you
37
+ * omit. Costs one extra request.
38
+ */
39
+ mode?: 'replace' | 'merge';
40
+ /** Skip the client-side check that media URLs are reachable from Discord. */
41
+ allowPrivateMediaUrls?: boolean;
42
+ };
43
+ export type LobbyCreateOptions = {
44
+ metadata?: LobbyMetadata;
45
+ /** Up to 25 users to add on creation. Set `CanLinkLobby` here for the owner. */
46
+ members?: LobbyMemberInput[];
47
+ /** Seconds to wait before an idle lobby shuts down (5–604800). */
48
+ idleTimeoutSeconds?: number;
49
+ };
50
+ export type LobbyModifyOptions = {
51
+ metadata?: LobbyMetadata;
52
+ /** Replaces the member list; members not listed are removed. Up to 25. */
53
+ members?: LobbyMemberInput[];
54
+ idleTimeoutSeconds?: number;
55
+ };
56
+ export type LobbyCreateOrJoinOptions = {
57
+ /** Identifies the lobby. Max 250 characters. */
58
+ secret: string;
59
+ idleTimeoutSeconds?: number;
60
+ lobbyMetadata?: LobbyMetadata;
61
+ memberMetadata?: LobbyMetadata;
62
+ };
63
+ export type LobbyMessageSendOptions = {
64
+ /** Message content. Must be non-empty. */
65
+ content: string;
66
+ /**
67
+ * Delivered alongside the message to active Social SDK clients. Not persisted
68
+ * on the linked channel message.
69
+ */
70
+ metadata?: LobbyMetadata;
71
+ /** Only flags creatable by the Social SDK are accepted. */
72
+ flags?: number;
73
+ };
74
+ type FetchLike = typeof fetch;
75
+ export type DiscordRestClientOptions = {
76
+ token: string;
77
+ applicationId: string;
78
+ apiBaseUrl?: string;
79
+ maxRetries?: number;
80
+ fetchImplementation?: FetchLike;
81
+ };
82
+ export declare class DiscordRestApiError extends Error {
83
+ readonly status: number;
84
+ readonly method: string;
85
+ readonly path: string;
86
+ readonly body: string;
87
+ constructor(status: number, method: string, path: string, body: string);
88
+ }
89
+ export declare class DiscordRestClient {
90
+ private readonly options;
91
+ private readonly fetchImpl;
92
+ private readonly baseUrl;
93
+ private readonly maxRetries;
94
+ /** Bucket id -> observed remaining/reset state. */
95
+ private readonly buckets;
96
+ /** Normalised route -> bucket id, learned from X-RateLimit headers. */
97
+ private readonly routeBuckets;
98
+ constructor(options: DiscordRestClientOptions);
99
+ request<T>(path: string, init?: RequestInit & {
100
+ authenticated?: boolean;
101
+ }): Promise<T>;
102
+ /**
103
+ * Normalises a path into a stable route key: numeric ids become `:id`
104
+ * except for major parameters (channel/guild/webhook roots).
105
+ */
106
+ private routeKey;
107
+ private waitForBucket;
108
+ private updateRateLimitState;
109
+ /** Reads retry_after from the 429 body first (float seconds), then headers. */
110
+ private readRetryAfter;
111
+ private createRequestError;
112
+ createFollowup(interactionToken: string, body: unknown): Promise<unknown>;
113
+ editOriginal(interactionToken: string, body: unknown): Promise<unknown>;
114
+ /** Deletes the original interaction response. */
115
+ deleteOriginal(interactionToken: string): Promise<void>;
116
+ /** Deletes a follow-up message previously sent for this interaction. */
117
+ deleteFollowup(interactionToken: string, messageId: string): Promise<void>;
118
+ createFollowupMessage(interactionToken: string, options: BaseDiscordMessageOptions): Promise<DiscordSentMessage>;
119
+ editOriginalMessage(interactionToken: string, options: BaseDiscordMessageOptions): Promise<DiscordSentMessage>;
120
+ sendMessage(options: DiscordSendMessageOptions): Promise<DiscordSentMessage>;
121
+ send(options: DiscordSendMessageOptions): Promise<DiscordSentMessage>;
122
+ startThread(options: DiscordStartThreadOptions): Promise<APIChannel>;
123
+ /**
124
+ * Creates a thread directly in a channel (no source message), e.g. for
125
+ * forum channels or standalone public/private threads.
126
+ */
127
+ createThread(options: DiscordCreateThreadOptions): Promise<APIChannel>;
128
+ editMessage(channelId: string, messageId: string, options: BaseDiscordMessageOptions): Promise<DiscordSentMessage>;
129
+ deleteMessage(channelId: string, messageId: string, reason?: string): Promise<void>;
130
+ pinMessage(channelId: string, messageId: string, reason?: string): Promise<void>;
131
+ unpinMessage(channelId: string, messageId: string, reason?: string): Promise<void>;
132
+ crosspostMessage(channelId: string, messageId: string): Promise<APIMessage>;
133
+ /** Sends a message through an existing webhook without instantiating {@link DiscordWebhook}. */
134
+ sendWebhookMessage(webhookId: string, webhookToken: string, options: DiscordWebhookSendOptions): Promise<DiscordSentMessage>;
135
+ fetchMessage(channelId: string, messageId: string): Promise<DiscordSentMessage>;
136
+ /** Lists channel messages; at most one of before/after/around per call. */
137
+ fetchMessages(channelId: string, options?: {
138
+ limit?: number;
139
+ before?: string;
140
+ after?: string;
141
+ around?: string;
142
+ }): Promise<APIMessage[]>;
143
+ /** Bulk-deletes 2–100 messages (all must be younger than 14 days). */
144
+ bulkDeleteMessages(channelId: string, messageIds: readonly string[], reason?: string): Promise<void>;
145
+ triggerTyping(channelId: string): Promise<void>;
146
+ /** Lists the users who reacted with the given emoji (paginated). */
147
+ fetchReactors(channelId: string, messageId: string, reaction: DiscordReaction, options?: {
148
+ limit?: number;
149
+ after?: string;
150
+ type?: number;
151
+ }): Promise<APIUser[]>;
152
+ removeOwnReaction(channelId: string, messageId: string, reaction: DiscordReaction): Promise<void>;
153
+ removeUserReaction(channelId: string, messageId: string, userId: string, reaction: DiscordReaction, reason?: string): Promise<void>;
154
+ removeAllReactions(channelId: string, messageId: string, reason?: string): Promise<void>;
155
+ removeAllReactionsForEmoji(channelId: string, messageId: string, reaction: DiscordReaction, reason?: string): Promise<void>;
156
+ fetchChannel(channelId: string): Promise<APIChannel>;
157
+ /** Edits channel fields; thread-only options are sent only when provided. */
158
+ editChannel(channelId: string, options: DiscordChannelEditOptions, reason?: string): Promise<APIChannel>;
159
+ deleteChannel(channelId: string, reason?: string): Promise<void>;
160
+ /** Follows an announcement channel into the target channel. */
161
+ followAnnouncementChannel(sourceChannelId: string, targetChannelId: string, reason?: string): Promise<void>;
162
+ /** Immediately ends a poll the app authored. */
163
+ endPoll(channelId: string, messageId: string): Promise<APIMessage>;
164
+ /** Lists users who voted for a poll answer (up to 100 per call). */
165
+ fetchPollAnswerVoters(channelId: string, messageId: string, answerId: number): Promise<APIUser[]>;
166
+ fetchGuild(guildId: string, withCounts?: boolean): Promise<APIGuild>;
167
+ listGuildChannels(guildId: string): Promise<APIChannel[]>;
168
+ fetchMember(guildId: string, userId: string): Promise<APIGuildMember>;
169
+ listMembers(guildId: string, options?: {
170
+ limit?: number;
171
+ after?: string;
172
+ }): Promise<APIGuildMember[]>;
173
+ kickMember(guildId: string, userId: string, reason?: string): Promise<void>;
174
+ /** Bans a member; `deleteMessageSeconds` removes up to 7 days of messages. */
175
+ banMember(guildId: string, userId: string, options?: {
176
+ deleteMessageSeconds?: number;
177
+ reason?: string;
178
+ }): Promise<void>;
179
+ unbanMember(guildId: string, userId: string, reason?: string): Promise<void>;
180
+ listBans(guildId: string): Promise<APIBan[]>;
181
+ editMember(guildId: string, userId: string, options: DiscordMemberEditOptions, reason?: string): Promise<APIGuildMember>;
182
+ /** Times out a member for the given duration (ms); null clears the timeout. */
183
+ timeoutMember(guildId: string, userId: string, durationMs: number | null, reason?: string): Promise<APIGuildMember>;
184
+ listRoles(guildId: string): Promise<APIRole[]>;
185
+ createRole(guildId: string, options: DiscordRoleOptions, reason?: string): Promise<APIRole>;
186
+ editRole(guildId: string, roleId: string, options: DiscordRoleOptions, reason?: string): Promise<APIRole>;
187
+ deleteRole(guildId: string, roleId: string, reason?: string): Promise<void>;
188
+ /** Reorders roles; entries are `{ id, position }` pairs. */
189
+ reorderRoles(guildId: string, positions: ReadonlyArray<{
190
+ id: string;
191
+ position: number;
192
+ }>, reason?: string): Promise<APIRole[]>;
193
+ addRoleToMember(guildId: string, userId: string, roleId: string, reason?: string): Promise<void>;
194
+ removeRoleFromMember(guildId: string, userId: string, roleId: string, reason?: string): Promise<void>;
195
+ listGuildEmojis(guildId: string): Promise<APIEmoji[]>;
196
+ fetchGuildEmoji(guildId: string, emojiId: string): Promise<APIEmoji>;
197
+ /** Creates an emoji; `imageData` must be a data URI (base64). */
198
+ createGuildEmoji(guildId: string, options: {
199
+ name: string;
200
+ imageData: string;
201
+ roles?: string[];
202
+ }, reason?: string): Promise<APIEmoji>;
203
+ editGuildEmoji(guildId: string, emojiId: string, options: {
204
+ name?: string;
205
+ roles?: string[];
206
+ }, reason?: string): Promise<APIEmoji>;
207
+ deleteGuildEmoji(guildId: string, emojiId: string, reason?: string): Promise<void>;
208
+ listGuildStickers(guildId: string): Promise<APISticker[]>;
209
+ fetchSticker(stickerId: string): Promise<APISticker>;
210
+ deleteGuildSticker(guildId: string, stickerId: string, reason?: string): Promise<void>;
211
+ listChannelWebhooks(channelId: string): Promise<APIWebhook[]>;
212
+ listGuildWebhooks(guildId: string): Promise<APIWebhook[]>;
213
+ createWebhook(channelId: string, options: {
214
+ name: string;
215
+ avatar?: string;
216
+ }, reason?: string): Promise<APIWebhook>;
217
+ fetchWebhook(webhookId: string): Promise<APIWebhook>;
218
+ /** Fetches a webhook using only its token — no bot auth required. */
219
+ fetchWebhookWithToken(webhookId: string, webhookToken: string): Promise<APIWebhook>;
220
+ editWebhook(webhookId: string, options: {
221
+ name?: string;
222
+ avatar?: string | null;
223
+ channelId?: string;
224
+ }, reason?: string): Promise<APIWebhook>;
225
+ deleteWebhook(webhookId: string, reason?: string): Promise<void>;
226
+ listSKUs(): Promise<APISKU[]>;
227
+ listEntitlements(options?: {
228
+ userId?: string;
229
+ skuIds?: readonly string[];
230
+ guildId?: string;
231
+ before?: string;
232
+ after?: string;
233
+ limit?: number;
234
+ excludeEnded?: boolean;
235
+ }): Promise<APIEntitlement[]>;
236
+ /** Consumes a one-time-purchase entitlement. */
237
+ consumeEntitlement(entitlementId: string): Promise<void>;
238
+ getCommandPermissions(guildId: string, commandId: string): Promise<RESTPutAPIApplicationCommandPermissionsJSONBody>;
239
+ /** Fully replaces a command's permission overrides for a guild. */
240
+ setCommandPermissions(guildId: string, commandId: string, permissions: ReadonlyArray<{
241
+ id: string;
242
+ type: ApplicationCommandPermissionType;
243
+ permission: boolean;
244
+ }>, reason?: string): Promise<void>;
245
+ addReaction(channelId: string, messageId: string, reaction: DiscordReaction): Promise<void>;
246
+ webhook(id: string, token: string): DiscordWebhook;
247
+ putApplicationRoleConnectionMetadata(body: RESTPutAPIApplicationRoleConnectionMetadataJSONBody): Promise<RESTPutAPIApplicationRoleConnectionMetadataResult>;
248
+ /**
249
+ * Writes a player's Game Stats profile.
250
+ *
251
+ * `data` is **fully replaced** whenever it is present, so omitting a stat
252
+ * deletes it; omit `data` entirely to leave stored stats untouched. Prefer
253
+ * {@link sendGameStats} with `mode: "merge"` when patching individual stats.
254
+ *
255
+ * Requires a bot token, the `application_identities.write` OAuth2 scope on
256
+ * the target user, and a *claimed* game with a configured widget.
257
+ *
258
+ * @returns the created profile on the first write (201), `undefined` on
259
+ * subsequent updates (204).
260
+ * @see {@link https://docs.discord.com/developers/resources/application-identity-profile}
261
+ */
262
+ updateIdentityProfile(userId: string, providerIssuedUserId: string, body: UpdateIdentityProfileBody): Promise<ApplicationIdentityProfile | undefined>;
263
+ /**
264
+ * Reads a player's stored Game Stats profile.
265
+ *
266
+ * `metadata` is returned by reads; the documented update parameters are only
267
+ * `username` and `data`.
268
+ */
269
+ getIdentityProfile(userId: string, providerIssuedUserId: string): Promise<ApplicationIdentityProfile>;
270
+ /** Lists a user's application identities for this application (no profile data). */
271
+ listIdentitiesByUserId(userId: string): Promise<APIApplicationIdentity[]>;
272
+ /** Resolves the Discord user behind one of your external IDs (no profile data). */
273
+ listIdentitiesByExternalId(providerType: string, providerIssuedUserId: string, providerId?: string): Promise<APIApplicationIdentity[]>;
274
+ /**
275
+ * Deletes one application identity and its profile data.
276
+ *
277
+ * Blocked when it would remove the user's last account-linking identity.
278
+ * Useful when a stale `provider_issued_user_id` prevents writing stats.
279
+ */
280
+ deleteIdentity(userId: string, providerType: string, providerIssuedUserId: string, providerId?: string): Promise<void>;
281
+ /**
282
+ * Sends Game Stats for a player, validating Discord's limits client-side.
283
+ *
284
+ * ```ts
285
+ * await rest.sendGameStats({
286
+ * userId, // Discord user id
287
+ * providerIssuedUserId, // your own player id
288
+ * primary: { season: 'Season 3', rank_name: 'Silver', playtime_hours: 69.41 },
289
+ * dynamic: [{ type: 2, name: 'win_streak', value: 5 }],
290
+ * });
291
+ * ```
292
+ *
293
+ * Resolves with `undefined` **without issuing any request** when there is
294
+ * nothing to write — no `username`, `primary` or `dynamic`. An empty PATCH
295
+ * would otherwise still create the Application Identity record.
296
+ *
297
+ * @throws {ApplicationIdentityProfileError} when the payload would exceed the
298
+ * 10 KB / 30-field / length limits, or references a media URL Discord cannot fetch.
299
+ */
300
+ sendGameStats(options: SendGameStatsOptions): Promise<ApplicationIdentityProfile | undefined>;
301
+ /**
302
+ * Reads a profile for merge mode, treating a missing identity (404) as empty
303
+ * rather than surfacing an error. Branches on the typed status instead of the
304
+ * error message so a message-format change cannot break merge mode.
305
+ */
306
+ private readIdentityProfileOrUndefined;
307
+ private identityPath;
308
+ /**
309
+ * Creates a lobby. Social SDK clients cannot join a lobby created this way —
310
+ * see {@link createOrJoinLobby} for the SDK-compatible flow.
311
+ *
312
+ * @see {@link https://docs.discord.com/developers/resources/lobby}
313
+ */
314
+ createLobby(options?: LobbyCreateOptions): Promise<APILobby>;
315
+ /**
316
+ * Creates a lobby for a `secret`, or joins the caller to the existing one.
317
+ *
318
+ * Needs a **Bearer** user token with the `sdk.social_layer` scope, not the bot
319
+ * token — pass it as `userToken`.
320
+ */
321
+ createOrJoinLobby(userToken: string, options: LobbyCreateOrJoinOptions): Promise<APILobby>;
322
+ /** Reads a lobby, including its `linked_channel` when one is linked. */
323
+ getLobby(lobbyId: string): Promise<APILobby>;
324
+ /** Replaces lobby metadata, its member list and/or its idle timeout. */
325
+ modifyLobby(lobbyId: string, options?: LobbyModifyOptions): Promise<APILobby>;
326
+ /** Deletes a lobby. Safe to call when it is already gone. */
327
+ deleteLobby(lobbyId: string): Promise<void>;
328
+ /**
329
+ * Adds a user to a lobby, or updates them when they are already a member.
330
+ *
331
+ * Pass `flags: LobbyMemberFlags.CanLinkLobby` to let that user configure the
332
+ * lobby's linked channel — grant it only to the lobby owner/administrator.
333
+ */
334
+ addLobbyMember(lobbyId: string, userId: string, options?: Omit<LobbyMemberInput, 'id'>): Promise<APILobbyMember>;
335
+ /**
336
+ * Upserts or removes up to 25 members in one request.
337
+ *
338
+ * Members are upserted unless `remove_member: true`. Users failing permission
339
+ * checks — or already at the per-application lobby cap and not already a
340
+ * member — are **silently dropped**, so treat the response as authoritative.
341
+ */
342
+ bulkUpdateLobbyMembers(lobbyId: string, members: LobbyMemberUpdateInput[]): Promise<APILobbyMember[]>;
343
+ /** Removes a member. Safe when they already left, but fails if the lobby is gone. */
344
+ removeLobbyMember(lobbyId: string, userId: string): Promise<void>;
345
+ /**
346
+ * Links a guild text channel to a lobby.
347
+ *
348
+ * - Needs a **Bearer** user token: the acting user must be a lobby member with
349
+ * {@link LobbyMemberFlags.CanLinkLobby}.
350
+ * - The channel must be a guild text channel, not age-restricted, and not
351
+ * already linked to another lobby.
352
+ * - **Every lobby member can read and post** in the linked channel in-game,
353
+ * even when it is private in Discord. Warn the user performing the link.
354
+ * - Capped at 20 calls per 2 hours per application in development.
355
+ *
356
+ * @returns the lobby, with `linked_channel` populated.
357
+ */
358
+ linkChannelToLobby(lobbyId: string, channelId: string, userToken: string): Promise<APILobby>;
359
+ /**
360
+ * Unlinks the lobby's channel by sending the same endpoint an empty body.
361
+ *
362
+ * Needs a **Bearer** user token whose user has the `CanLinkLobby` flag — but
363
+ * **no** Discord-side channel permissions.
364
+ */
365
+ unlinkChannelFromLobby(lobbyId: string, userToken: string): Promise<APILobby>;
366
+ /**
367
+ * Sends a message to a lobby. Forwarded to the linked channel when one is
368
+ * linked; if forwarding fails (e.g. AutoMod) the lobby message is still
369
+ * delivered to other members.
370
+ *
371
+ * Needs a **Bearer** user token — the caller must be a lobby member.
372
+ */
373
+ sendLobbyMessage(lobbyId: string, options: LobbyMessageSendOptions, userToken: string): Promise<APILobbyMessage>;
374
+ /** Lists recent lobby messages (1–200, default 50) for a member of the lobby. */
375
+ getLobbyMessages(lobbyId: string, userToken: string, options?: {
376
+ limit?: number;
377
+ }): Promise<APILobbyMessage[]>;
378
+ /**
379
+ * Creates a single-use invite to the lobby's linked channel for the calling
380
+ * user — the equivalent of the SDK's `JoinLinkedLobbyGuild`.
381
+ *
382
+ * Needs a **Bearer** user token and a linked channel. Expires after one hour.
383
+ * Only users with a real linked Discord account can join; provisional accounts
384
+ * must link first. Note that server admins cannot restrict who may join this
385
+ * way — any lobby member can mint an invite.
386
+ */
387
+ createLobbyChannelInviteForSelf(lobbyId: string, userToken: string): Promise<APILobbyInvite>;
388
+ /** Creates a linked-channel invite on behalf of the application, for one user. */
389
+ createLobbyChannelInviteForUser(lobbyId: string, userId: string): Promise<APILobbyInvite>;
390
+ /**
391
+ * Switches authenticated requests to a **Bearer** user token.
392
+ *
393
+ * Lobby operations acting on behalf of a user need the user's token with the
394
+ * `sdk.social_layer` scope; the default bot token is rejected. `authenticated:
395
+ * false` suppresses the `Authorization: Bot …` header, and the explicit header
396
+ * is merged last so it wins.
397
+ */
398
+ private asUser;
399
+ }
400
+ export {};