@theholocron/discord-client 1.58.0-alpha.2 → 1.58.0-alpha.4
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.
- package/dist/index.d.mts +241 -2
- package/dist/index.mjs +61 -0
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/** What fetching a webhook by id and token returns. */
|
|
1
2
|
interface DiscordWebhookInfo {
|
|
3
|
+
/** The webhook id. */
|
|
2
4
|
id: string;
|
|
5
|
+
/** The webhook name. */
|
|
3
6
|
name: string;
|
|
7
|
+
/** Id of the server the webhook belongs to, when Discord includes it. */
|
|
4
8
|
guild_id?: string;
|
|
5
9
|
}
|
|
6
10
|
/** Parse a Discord webhook URL into its id and token parts. */
|
|
@@ -8,41 +12,59 @@ export declare function parseWebhookUrl(url: string): {
|
|
|
8
12
|
id: string;
|
|
9
13
|
token: string;
|
|
10
14
|
};
|
|
15
|
+
/** Options for `createDiscordClient`. */
|
|
11
16
|
interface DiscordClientOptions {
|
|
12
17
|
/** Override base URL for testing. Defaults to https://discord.com/api/v10. */
|
|
13
18
|
baseUrl?: string;
|
|
14
19
|
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
15
20
|
fetch?: typeof fetch;
|
|
16
21
|
}
|
|
22
|
+
/** Options for `createDiscordBotClient`. */
|
|
17
23
|
export interface DiscordBotClientOptions {
|
|
18
24
|
/** Bot token from the Discord developer portal (Bot → Reset Token). */
|
|
19
25
|
botToken: string;
|
|
20
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Override base URL for testing. Defaults to https://discord.com/api/v10.
|
|
28
|
+
* The bot token is sent to whatever host this names, so never derive it from untrusted input.
|
|
29
|
+
*/
|
|
21
30
|
baseUrl?: string;
|
|
22
31
|
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
23
32
|
fetch?: typeof fetch;
|
|
24
33
|
/** Per-request deadline in milliseconds. Defaults to 15000. */
|
|
25
34
|
timeoutMs?: number;
|
|
26
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Retries after a 429 (rate limit) before giving up. Defaults to 3.
|
|
37
|
+
* Each retry waits for the `Retry-After` Discord sends; a wait longer than 10 seconds fails immediately.
|
|
38
|
+
*/
|
|
27
39
|
maxRetries?: number;
|
|
28
40
|
/** Wait between rate-limit retries; a test seam. Defaults to `setTimeout`. */
|
|
29
41
|
sleep?: (ms: number) => Promise<void>;
|
|
30
42
|
}
|
|
31
43
|
/** Discord channel `type` values this client creates or reads. */
|
|
32
44
|
export declare const ChannelType: {
|
|
45
|
+
/** A text channel. */
|
|
33
46
|
readonly Text: 0;
|
|
47
|
+
/** A category that groups channels. */
|
|
34
48
|
readonly Category: 4;
|
|
49
|
+
/** An announcement channel. */
|
|
35
50
|
readonly Announcement: 5;
|
|
51
|
+
/** A forum channel. */
|
|
36
52
|
readonly Forum: 15;
|
|
37
53
|
};
|
|
54
|
+
/** A Discord account, as the API returns it. */
|
|
38
55
|
export interface DiscordUser {
|
|
56
|
+
/** The user id. */
|
|
39
57
|
id: string;
|
|
58
|
+
/** The account's username. */
|
|
40
59
|
username: string;
|
|
60
|
+
/** Whether the account is a bot. */
|
|
41
61
|
bot?: boolean;
|
|
42
62
|
}
|
|
43
63
|
/** A server as `GET /users/@me/guilds` lists it: a summary, not the full guild. */
|
|
44
64
|
export interface DiscordUserGuild {
|
|
65
|
+
/** The server id. */
|
|
45
66
|
id: string;
|
|
67
|
+
/** The server name. */
|
|
46
68
|
name: string;
|
|
47
69
|
/** Whether the caller (here, the bot) owns the server. */
|
|
48
70
|
owner: boolean;
|
|
@@ -51,13 +73,16 @@ export interface DiscordUserGuild {
|
|
|
51
73
|
}
|
|
52
74
|
/** Page options for `users.guilds`; Discord allows a `limit` of 1–200; values outside that are clamped. */
|
|
53
75
|
export interface ListUserGuildsInput {
|
|
76
|
+
/** How many servers to return, 1 to 200. */
|
|
54
77
|
limit?: number;
|
|
55
78
|
/** Return servers after this server id. */
|
|
56
79
|
after?: string;
|
|
57
80
|
}
|
|
58
81
|
/** Guild fields `guilds.modify` can change; the numeric enums are Discord's own. */
|
|
59
82
|
export interface DiscordGuild {
|
|
83
|
+
/** The server id. */
|
|
60
84
|
id: string;
|
|
85
|
+
/** The server name. */
|
|
61
86
|
name: string;
|
|
62
87
|
/** 0 none, 1 low, 2 medium, 3 high, 4 very high. */
|
|
63
88
|
verification_level?: number;
|
|
@@ -65,84 +90,136 @@ export interface DiscordGuild {
|
|
|
65
90
|
default_message_notifications?: number;
|
|
66
91
|
/** 0 disabled, 1 members without roles, 2 all members. */
|
|
67
92
|
explicit_content_filter?: number;
|
|
93
|
+
/** Id of the channel for system messages, or `null` for none. */
|
|
68
94
|
system_channel_id?: string | null;
|
|
69
95
|
/** Bitfield of system-channel messages to suppress. */
|
|
70
96
|
system_channel_flags?: number;
|
|
97
|
+
/** Id of the rules channel, or `null` for none. */
|
|
71
98
|
rules_channel_id?: string | null;
|
|
99
|
+
/** Id of the channel for Discord's community updates, or `null` for none. */
|
|
72
100
|
public_updates_channel_id?: string | null;
|
|
101
|
+
/** The server's preferred locale, such as `en-US`. */
|
|
73
102
|
preferred_locale?: string;
|
|
103
|
+
/** The server description, or `null` when unset. */
|
|
74
104
|
description?: string | null;
|
|
75
105
|
/** `COMMUNITY` here means the community features (welcome screen, onboarding) are available. */
|
|
76
106
|
features?: string[];
|
|
77
107
|
}
|
|
108
|
+
/** What `PATCH /guilds/{id}` takes; a field left out is left alone. */
|
|
78
109
|
export interface ModifyGuildInput {
|
|
110
|
+
/** A new server name. */
|
|
79
111
|
name?: string;
|
|
80
112
|
/** Hands the server to another user; only the current owner (never a bot that does not own it) may. */
|
|
81
113
|
owner_id?: string;
|
|
114
|
+
/** Verification level: 0 none, 1 low, 2 medium, 3 high, 4 very high. */
|
|
82
115
|
verification_level?: number;
|
|
116
|
+
/** Notification default: 0 all messages, 1 only @mentions. */
|
|
83
117
|
default_message_notifications?: number;
|
|
118
|
+
/** Content filter: 0 disabled, 1 members without roles, 2 all members. */
|
|
84
119
|
explicit_content_filter?: number;
|
|
120
|
+
/** Id of the channel for system messages, or `null` for none. */
|
|
85
121
|
system_channel_id?: string | null;
|
|
122
|
+
/** Bitfield of system-channel messages to suppress. */
|
|
86
123
|
system_channel_flags?: number;
|
|
124
|
+
/** Id of the rules channel, or `null` for none. */
|
|
87
125
|
rules_channel_id?: string | null;
|
|
126
|
+
/** Id of the channel for Discord's community updates, or `null` for none. */
|
|
88
127
|
public_updates_channel_id?: string | null;
|
|
128
|
+
/** The server's preferred locale, such as `en-US`. */
|
|
89
129
|
preferred_locale?: string;
|
|
130
|
+
/** The server description, or `null` to clear it. */
|
|
90
131
|
description?: string | null;
|
|
91
132
|
/** The full list of mutable guild features (for example `COMMUNITY`); Discord ignores the ones it manages itself. */
|
|
92
133
|
features?: string[];
|
|
93
134
|
}
|
|
135
|
+
/** A channel featured on a server's welcome screen. */
|
|
94
136
|
export interface DiscordWelcomeChannel {
|
|
137
|
+
/** Id of the featured channel. */
|
|
95
138
|
channel_id: string;
|
|
139
|
+
/** The blurb shown beside the channel. */
|
|
96
140
|
description: string;
|
|
141
|
+
/** Id of a custom emoji shown beside it, or `null`. */
|
|
97
142
|
emoji_id?: string | null;
|
|
143
|
+
/** Name of a Unicode emoji shown beside it, or `null`. */
|
|
98
144
|
emoji_name?: string | null;
|
|
99
145
|
}
|
|
100
146
|
/** Whether the screen is on is the `WELCOME_SCREEN_ENABLED` entry in the guild's `features`; the object has no flag. */
|
|
101
147
|
export interface DiscordWelcomeScreen {
|
|
148
|
+
/** The server description shown on the screen, or `null`. */
|
|
102
149
|
description: string | null;
|
|
150
|
+
/** The channels featured on the screen. */
|
|
103
151
|
welcome_channels: DiscordWelcomeChannel[];
|
|
104
152
|
}
|
|
153
|
+
/** What `PATCH /guilds/{id}/welcome-screen` takes. */
|
|
105
154
|
export interface ModifyWelcomeScreenInput {
|
|
155
|
+
/** Whether to turn the welcome screen on or off. */
|
|
106
156
|
enabled?: boolean;
|
|
157
|
+
/** New welcome-screen description, or `null` to clear it. */
|
|
107
158
|
description?: string | null;
|
|
159
|
+
/** The channels to feature on the welcome screen. */
|
|
108
160
|
welcome_channels?: DiscordWelcomeChannel[];
|
|
109
161
|
}
|
|
162
|
+
/** A server emoji; `id` is `null` for a standard Unicode emoji. */
|
|
110
163
|
export interface DiscordEmoji {
|
|
164
|
+
/** The emoji id, or `null` for a Unicode emoji. */
|
|
111
165
|
id: string | null;
|
|
166
|
+
/** The emoji name (the Unicode character for a standard emoji), or `null`. */
|
|
112
167
|
name: string | null;
|
|
168
|
+
/** Whether the emoji is animated. */
|
|
113
169
|
animated?: boolean;
|
|
114
170
|
}
|
|
171
|
+
/** One answer a member can pick in an onboarding prompt. */
|
|
115
172
|
export interface DiscordOnboardingOption {
|
|
173
|
+
/** The option id; absent when creating a new option. */
|
|
116
174
|
id?: string;
|
|
175
|
+
/** The text of the option. */
|
|
117
176
|
title: string;
|
|
177
|
+
/** A short explanation shown under the title. */
|
|
118
178
|
description?: string | null;
|
|
179
|
+
/** Ids of the channels a member who picks this option is shown. */
|
|
119
180
|
channel_ids?: string[];
|
|
181
|
+
/** Ids of the roles a member who picks this option is given. */
|
|
120
182
|
role_ids?: string[];
|
|
121
183
|
/** Discord returns the emoji as an object... */
|
|
122
184
|
emoji?: DiscordEmoji;
|
|
123
185
|
/** ...and takes it as these three fields (a custom emoji has `emoji_id`, a Unicode one only `emoji_name`). */
|
|
124
186
|
emoji_id?: string | null;
|
|
187
|
+
/** Name of a Unicode emoji, or of a custom emoji together with `emoji_id`. */
|
|
125
188
|
emoji_name?: string | null;
|
|
189
|
+
/** Whether the custom emoji is animated. */
|
|
126
190
|
emoji_animated?: boolean;
|
|
127
191
|
}
|
|
192
|
+
/** A question in the server's onboarding flow, with the options a member picks from. */
|
|
128
193
|
export interface DiscordOnboardingPrompt {
|
|
194
|
+
/** The prompt id; absent when creating a new prompt. */
|
|
129
195
|
id?: string;
|
|
130
196
|
/** 0 multiple choice, 1 dropdown. */
|
|
131
197
|
type: number;
|
|
198
|
+
/** The question text. */
|
|
132
199
|
title: string;
|
|
200
|
+
/** Whether a member may pick only one option. */
|
|
133
201
|
single_select: boolean;
|
|
202
|
+
/** Whether a member must answer. */
|
|
134
203
|
required: boolean;
|
|
204
|
+
/** Whether the prompt appears during onboarding (otherwise only in Channels & Roles). */
|
|
135
205
|
in_onboarding: boolean;
|
|
206
|
+
/** The answers a member can choose from. */
|
|
136
207
|
options: DiscordOnboardingOption[];
|
|
137
208
|
}
|
|
209
|
+
/** A server's onboarding configuration, as `GET /guilds/{id}/onboarding` returns and `PUT` takes it. */
|
|
138
210
|
export interface DiscordOnboarding {
|
|
211
|
+
/** The server id. */
|
|
139
212
|
guild_id?: string;
|
|
213
|
+
/** The questions asked during onboarding. */
|
|
140
214
|
prompts: DiscordOnboardingPrompt[];
|
|
215
|
+
/** Ids of the channels every new member is shown by default. */
|
|
141
216
|
default_channel_ids: string[];
|
|
217
|
+
/** Whether onboarding is turned on. */
|
|
142
218
|
enabled: boolean;
|
|
143
219
|
/** 0 default, 1 advanced. */
|
|
144
220
|
mode?: number;
|
|
145
221
|
}
|
|
222
|
+
/** A per-role or per-member override of a channel's permissions. */
|
|
146
223
|
export interface DiscordPermissionOverwrite {
|
|
147
224
|
/** Role or user id. */
|
|
148
225
|
id: string;
|
|
@@ -153,92 +230,146 @@ export interface DiscordPermissionOverwrite {
|
|
|
153
230
|
/** Bitfield of permissions to deny, as a string. */
|
|
154
231
|
deny: string;
|
|
155
232
|
}
|
|
233
|
+
/** A channel or category in a server, as Discord returns it. */
|
|
156
234
|
export interface DiscordChannel {
|
|
235
|
+
/** The channel id. */
|
|
157
236
|
id: string;
|
|
237
|
+
/** The channel name. */
|
|
158
238
|
name: string;
|
|
239
|
+
/** The channel type; see `ChannelType`. */
|
|
159
240
|
type: number;
|
|
241
|
+
/** Id of the category the channel sits in, or `null` for none. */
|
|
160
242
|
parent_id?: string | null;
|
|
243
|
+
/** The channel topic, or `null` when unset. */
|
|
161
244
|
topic?: string | null;
|
|
245
|
+
/** The channel's sort position within its category or the server. */
|
|
162
246
|
position?: number;
|
|
247
|
+
/** Permission overrides set on this channel. */
|
|
163
248
|
permission_overwrites?: DiscordPermissionOverwrite[];
|
|
164
249
|
}
|
|
250
|
+
/** What `POST /guilds/{id}/channels` takes. */
|
|
165
251
|
export interface CreateChannelInput {
|
|
252
|
+
/** The channel name. */
|
|
166
253
|
name: string;
|
|
254
|
+
/** The channel type; see `ChannelType`. Discord creates a text channel when omitted. */
|
|
167
255
|
type?: number;
|
|
256
|
+
/** The channel topic. */
|
|
168
257
|
topic?: string;
|
|
258
|
+
/** Id of the category to create the channel in. */
|
|
169
259
|
parent_id?: string;
|
|
260
|
+
/** Permission overrides to set on the new channel. */
|
|
170
261
|
permission_overwrites?: DiscordPermissionOverwrite[];
|
|
171
262
|
}
|
|
172
263
|
/** `null` clears `topic` or detaches the channel from its category. */
|
|
173
264
|
export interface ModifyChannelInput {
|
|
265
|
+
/** A new channel name. */
|
|
174
266
|
name?: string;
|
|
267
|
+
/** A new topic. */
|
|
175
268
|
topic?: string | null;
|
|
269
|
+
/** Id of the category to move the channel into. */
|
|
176
270
|
parent_id?: string | null;
|
|
271
|
+
/** The full list of permission overrides, replacing the existing ones. */
|
|
177
272
|
permission_overwrites?: DiscordPermissionOverwrite[];
|
|
178
273
|
}
|
|
179
274
|
/** A member of a server. Only what provisioning needs: who they are and which roles they hold. */
|
|
180
275
|
export interface DiscordGuildMember {
|
|
276
|
+
/** The member's account; Discord leaves it out in some message contexts. */
|
|
181
277
|
user?: {
|
|
278
|
+
/** The user id. */
|
|
182
279
|
id: string;
|
|
280
|
+
/** The account's username. */
|
|
183
281
|
username?: string;
|
|
184
282
|
};
|
|
185
283
|
/** Ids of the roles the member holds. */
|
|
186
284
|
roles: string[];
|
|
285
|
+
/** The member's nickname in the server, or `null` when none is set. */
|
|
187
286
|
nick?: string | null;
|
|
188
287
|
}
|
|
288
|
+
/** A role in a server, as Discord returns it. */
|
|
189
289
|
export interface DiscordRole {
|
|
290
|
+
/** The role id. */
|
|
190
291
|
id: string;
|
|
292
|
+
/** The role name. */
|
|
191
293
|
name: string;
|
|
294
|
+
/** The role colour as an integer RGB value; `0` means no colour. */
|
|
192
295
|
color: number;
|
|
296
|
+
/** Whether anyone can @mention the role. */
|
|
193
297
|
mentionable: boolean;
|
|
298
|
+
/** Whether members with the role are listed separately in the member list. */
|
|
194
299
|
hoist?: boolean;
|
|
195
300
|
/** Bitfield of permissions, as a string. */
|
|
196
301
|
permissions?: string;
|
|
302
|
+
/** Whether an integration (such as a bot) manages the role. */
|
|
197
303
|
managed?: boolean;
|
|
304
|
+
/** The role's position in the role hierarchy. */
|
|
198
305
|
position?: number;
|
|
199
306
|
}
|
|
307
|
+
/** Role fields `PATCH /guilds/{id}/roles/{id}` can change; a field left out is left alone. */
|
|
200
308
|
export interface ModifyRoleInput {
|
|
309
|
+
/** A new role name. */
|
|
201
310
|
name?: string;
|
|
311
|
+
/** A new colour as an integer RGB value. */
|
|
202
312
|
color?: number;
|
|
313
|
+
/** Whether to list the role's members separately. */
|
|
203
314
|
hoist?: boolean;
|
|
315
|
+
/** Whether anyone can @mention the role. */
|
|
204
316
|
mentionable?: boolean;
|
|
205
317
|
/** Bitfield of permissions, as a string. */
|
|
206
318
|
permissions?: string;
|
|
207
319
|
}
|
|
320
|
+
/** What `POST /guilds/{id}/roles` takes. */
|
|
208
321
|
export interface CreateRoleInput {
|
|
322
|
+
/** The role name. */
|
|
209
323
|
name: string;
|
|
324
|
+
/** The colour as an integer RGB value. */
|
|
210
325
|
color?: number;
|
|
326
|
+
/** Whether anyone can @mention the role. */
|
|
211
327
|
mentionable?: boolean;
|
|
328
|
+
/** Whether to list the role's members separately. */
|
|
212
329
|
hoist?: boolean;
|
|
213
330
|
/** Bitfield of permissions, as a string. */
|
|
214
331
|
permissions?: string;
|
|
215
332
|
}
|
|
333
|
+
/** A webhook attached to a channel, as the bot API returns it. */
|
|
216
334
|
export interface DiscordChannelWebhook {
|
|
335
|
+
/** The webhook id. */
|
|
217
336
|
id: string;
|
|
337
|
+
/** The webhook name, or `null` when unset. */
|
|
218
338
|
name: string | null;
|
|
219
339
|
/** The avatar hash, or `null` for the default one. */
|
|
220
340
|
avatar?: string | null;
|
|
341
|
+
/** Id of the channel the webhook posts to. */
|
|
221
342
|
channel_id: string;
|
|
222
343
|
/** Present only on webhooks this application created; Discord omits it otherwise. */
|
|
223
344
|
token?: string;
|
|
224
345
|
/** Present only on webhooks this application created. */
|
|
225
346
|
url?: string;
|
|
226
347
|
}
|
|
348
|
+
/** What `POST /channels/{id}/messages` takes. */
|
|
227
349
|
export interface CreateMessageInput {
|
|
350
|
+
/** The message text. */
|
|
228
351
|
content: string;
|
|
229
352
|
/** With `enforce_nonce`, Discord drops a repeat of the same nonce, so a retry after a lost response cannot post twice. */
|
|
230
353
|
nonce?: string | number;
|
|
354
|
+
/** Turns on the nonce de-duplication for `nonce`. */
|
|
231
355
|
enforce_nonce?: boolean;
|
|
232
356
|
/** Defaults to no mentions, so a pasted `@everyone` cannot ping anyone. */
|
|
233
357
|
allowed_mentions?: {
|
|
358
|
+
/** Which mention types Discord may resolve into pings. */
|
|
234
359
|
parse?: Array<"roles" | "users" | "everyone">;
|
|
360
|
+
/** Ids of the roles that may be pinged. */
|
|
235
361
|
roles?: string[];
|
|
362
|
+
/** Ids of the users that may be pinged. */
|
|
236
363
|
users?: string[];
|
|
237
364
|
};
|
|
238
365
|
}
|
|
366
|
+
/** A message that was posted, as Discord returns it. */
|
|
239
367
|
export interface DiscordMessage {
|
|
368
|
+
/** The message id. */
|
|
240
369
|
id: string;
|
|
370
|
+
/** Id of the channel the message is in. */
|
|
241
371
|
channel_id: string;
|
|
372
|
+
/** The message text. */
|
|
242
373
|
content: string;
|
|
243
374
|
}
|
|
244
375
|
/** How the bot is added to a server or an account. */
|
|
@@ -253,17 +384,26 @@ export interface DiscordInstallParams {
|
|
|
253
384
|
* that Discord has not verified; once verified, the plain ones take over and the toggle is Discord's to change.
|
|
254
385
|
*/
|
|
255
386
|
export declare const ApplicationFlag: {
|
|
387
|
+
/** Application may receive presence updates (verified apps). */
|
|
256
388
|
readonly GatewayPresence: number;
|
|
389
|
+
/** The privileged presence intent toggle for an unverified app. */
|
|
257
390
|
readonly GatewayPresenceLimited: number;
|
|
391
|
+
/** Application may receive server-member events and the member list (verified apps). */
|
|
258
392
|
readonly GatewayGuildMembers: number;
|
|
393
|
+
/** The privileged server-members intent toggle for an unverified app. */
|
|
259
394
|
readonly GatewayGuildMembersLimited: number;
|
|
395
|
+
/** Application may read message content (verified apps). */
|
|
260
396
|
readonly GatewayMessageContent: number;
|
|
397
|
+
/** The privileged message-content intent toggle for an unverified app. */
|
|
261
398
|
readonly GatewayMessageContentLimited: number;
|
|
262
399
|
};
|
|
263
400
|
/** The bot's own application, as `GET /applications/@me` returns it. Fields Discord leaves out are absent or null. */
|
|
264
401
|
export interface DiscordApplication {
|
|
402
|
+
/** The application id. */
|
|
265
403
|
id: string;
|
|
404
|
+
/** The application name. */
|
|
266
405
|
name: string;
|
|
406
|
+
/** The description shown on the application's page. */
|
|
267
407
|
description?: string | null;
|
|
268
408
|
/** Up to five short labels shown on the application's page. */
|
|
269
409
|
tags?: string[];
|
|
@@ -271,13 +411,19 @@ export interface DiscordApplication {
|
|
|
271
411
|
install_params?: DiscordInstallParams;
|
|
272
412
|
/** Used instead of the default install link when set. */
|
|
273
413
|
custom_install_url?: string | null;
|
|
414
|
+
/** URL Discord uses for linked-role verification. */
|
|
274
415
|
role_connections_verification_url?: string | null;
|
|
416
|
+
/** URL of the application's terms of service. */
|
|
275
417
|
terms_of_service_url?: string | null;
|
|
418
|
+
/** URL of the application's privacy policy. */
|
|
276
419
|
privacy_policy_url?: string | null;
|
|
420
|
+
/** URL Discord sends interaction events to. */
|
|
277
421
|
interactions_endpoint_url?: string | null;
|
|
278
422
|
/** Whether anyone can add the bot (`true`) or only its owner. */
|
|
279
423
|
bot_public?: boolean;
|
|
424
|
+
/** Whether the bot is only added after the full OAuth2 code grant. */
|
|
280
425
|
bot_require_code_grant?: boolean;
|
|
426
|
+
/** The application flags bitfield; see `ApplicationFlag`. */
|
|
281
427
|
flags?: number;
|
|
282
428
|
/**
|
|
283
429
|
* The OAuth2 redirect URIs registered on the application. Read-only here: Discord accepts a write to this
|
|
@@ -287,13 +433,21 @@ export interface DiscordApplication {
|
|
|
287
433
|
}
|
|
288
434
|
/** What `PATCH /applications/@me` takes; a field left out is left alone, and `null` clears the ones that can be cleared. */
|
|
289
435
|
export interface ModifyApplicationInput {
|
|
436
|
+
/** A new description. */
|
|
290
437
|
description?: string;
|
|
438
|
+
/** The new tags (at most five). */
|
|
291
439
|
tags?: string[];
|
|
440
|
+
/** The new default install link scopes and permissions. */
|
|
292
441
|
install_params?: DiscordInstallParams;
|
|
442
|
+
/** A custom install URL, or `null` to use the default link. */
|
|
293
443
|
custom_install_url?: string | null;
|
|
444
|
+
/** The linked-role verification URL, or `null` to clear it. */
|
|
294
445
|
role_connections_verification_url?: string | null;
|
|
446
|
+
/** The terms of service URL, or `null` to clear it. */
|
|
295
447
|
terms_of_service_url?: string | null;
|
|
448
|
+
/** The privacy policy URL, or `null` to clear it. */
|
|
296
449
|
privacy_policy_url?: string | null;
|
|
450
|
+
/** The interactions endpoint URL, or `null` to clear it. */
|
|
297
451
|
interactions_endpoint_url?: string | null;
|
|
298
452
|
/**
|
|
299
453
|
* The whole flags value. Discord keeps only the bits an app may change (the `*Limited` privileged-intent
|
|
@@ -301,22 +455,29 @@ export interface ModifyApplicationInput {
|
|
|
301
455
|
*/
|
|
302
456
|
flags?: number;
|
|
303
457
|
}
|
|
458
|
+
/** What `PATCH /webhooks/{id}` takes; a field left out is left alone. */
|
|
304
459
|
export interface ModifyWebhookInput {
|
|
460
|
+
/** A new webhook name. */
|
|
305
461
|
name?: string;
|
|
306
462
|
/** A data URI (`data:image/png;base64,...`); `null` clears it. */
|
|
307
463
|
avatar?: string | null;
|
|
308
464
|
}
|
|
309
465
|
/** What `POST /guilds` takes. Only a bot in fewer than ten servers may create one, and it becomes the owner. */
|
|
310
466
|
export interface CreateGuildInput {
|
|
467
|
+
/** The server name. */
|
|
311
468
|
name: string;
|
|
312
469
|
/** A data URI (`data:image/png;base64,...`). */
|
|
313
470
|
icon?: string;
|
|
471
|
+
/** Verification level, using the same values as `DiscordGuild.verification_level`. */
|
|
314
472
|
verification_level?: number;
|
|
473
|
+
/** Default notification setting, using the same values as `DiscordGuild.default_message_notifications`. */
|
|
315
474
|
default_message_notifications?: number;
|
|
475
|
+
/** Content filter level, using the same values as `DiscordGuild.explicit_content_filter`. */
|
|
316
476
|
explicit_content_filter?: number;
|
|
317
477
|
}
|
|
318
478
|
/** Page options for `guilds.members`; Discord caps `limit` at 1000. */
|
|
319
479
|
export interface ListMembersInput {
|
|
480
|
+
/** How many members to return; Discord caps it at 1000. */
|
|
320
481
|
limit?: number;
|
|
321
482
|
/** Return members after this user id. */
|
|
322
483
|
after?: string;
|
|
@@ -325,29 +486,43 @@ export interface DiscordEmoji {
|
|
|
325
486
|
id: string | null;
|
|
326
487
|
name: string | null;
|
|
327
488
|
animated?: boolean;
|
|
489
|
+
/** Whether the emoji can be used (it may be unavailable when the server lost a boost level). */
|
|
328
490
|
available?: boolean;
|
|
329
491
|
}
|
|
492
|
+
/** What `POST /channels/{id}/invites` takes. */
|
|
330
493
|
export interface CreateInviteInput {
|
|
331
494
|
/** Seconds until it expires; `0` never. Discord's default is 86400. */
|
|
332
495
|
max_age?: number;
|
|
333
496
|
/** Uses before it is revoked; `0` unlimited. */
|
|
334
497
|
max_uses?: number;
|
|
498
|
+
/** Whether the invite grants temporary membership. */
|
|
335
499
|
temporary?: boolean;
|
|
500
|
+
/** Whether to always create a new invite instead of reusing a similar one. */
|
|
336
501
|
unique?: boolean;
|
|
337
502
|
}
|
|
503
|
+
/** A server invite, as Discord returns it. */
|
|
338
504
|
export interface DiscordInvite {
|
|
505
|
+
/** The invite code, the part after `discord.gg/`. */
|
|
339
506
|
code: string;
|
|
507
|
+
/** Id of the channel the invite leads to. */
|
|
340
508
|
channel_id?: string;
|
|
509
|
+
/** How many times the invite has been used. */
|
|
341
510
|
uses?: number;
|
|
342
511
|
}
|
|
343
512
|
/** A message listed back from a channel, with who wrote it. */
|
|
344
513
|
export interface DiscordChannelMessage extends DiscordMessage {
|
|
514
|
+
/** Who wrote the message; absent when Discord omits it. */
|
|
345
515
|
author?: {
|
|
516
|
+
/** The author's user id. */
|
|
346
517
|
id: string;
|
|
518
|
+
/** The author's username. */
|
|
347
519
|
username?: string;
|
|
520
|
+
/** Whether the author is a bot. */
|
|
348
521
|
bot?: boolean;
|
|
349
522
|
};
|
|
523
|
+
/** Id of the webhook that posted the message, when one did. */
|
|
350
524
|
webhook_id?: string;
|
|
525
|
+
/** Whether the message is pinned in its channel. */
|
|
351
526
|
pinned?: boolean;
|
|
352
527
|
}
|
|
353
528
|
/**
|
|
@@ -441,6 +616,7 @@ export declare function createDiscordBotClient(opts: DiscordBotClientOptions): {
|
|
|
441
616
|
delete: (webhookId: string) => Promise<void>;
|
|
442
617
|
};
|
|
443
618
|
};
|
|
619
|
+
/** The bot-token client returned by `createDiscordBotClient`, with its resource groups (guilds, channels, roles, webhooks, messages and so on). */
|
|
444
620
|
export type DiscordBotClient = ReturnType<typeof createDiscordBotClient>;
|
|
445
621
|
/**
|
|
446
622
|
* Discord permission bits, by the names the Discord docs use. Permissions travel as
|
|
@@ -449,62 +625,114 @@ export type DiscordBotClient = ReturnType<typeof createDiscordBotClient>;
|
|
|
449
625
|
* `permissions` cannot set them by name.
|
|
450
626
|
*/
|
|
451
627
|
export declare const Permission: {
|
|
628
|
+
/** Create invites to the server. */
|
|
452
629
|
readonly CreateInstantInvite: bigint;
|
|
630
|
+
/** Kick members. */
|
|
453
631
|
readonly KickMembers: bigint;
|
|
632
|
+
/** Ban members. */
|
|
454
633
|
readonly BanMembers: bigint;
|
|
634
|
+
/** Administrator: all permissions, and bypasses channel overrides. */
|
|
455
635
|
readonly Administrator: bigint;
|
|
636
|
+
/** Create, edit and delete channels. */
|
|
456
637
|
readonly ManageChannels: bigint;
|
|
638
|
+
/** Change server settings. */
|
|
457
639
|
readonly ManageGuild: bigint;
|
|
640
|
+
/** Add new reactions to messages. */
|
|
458
641
|
readonly AddReactions: bigint;
|
|
642
|
+
/** View the audit log. */
|
|
459
643
|
readonly ViewAuditLog: bigint;
|
|
644
|
+
/** Use priority speaker in voice channels. */
|
|
460
645
|
readonly PrioritySpeaker: bigint;
|
|
646
|
+
/** Go live (stream) in voice channels. */
|
|
461
647
|
readonly Stream: bigint;
|
|
648
|
+
/** View channels (and read their messages). */
|
|
462
649
|
readonly ViewChannel: bigint;
|
|
650
|
+
/** Send messages in text channels. */
|
|
463
651
|
readonly SendMessages: bigint;
|
|
652
|
+
/** Send text-to-speech messages. */
|
|
464
653
|
readonly SendTtsMessages: bigint;
|
|
654
|
+
/** Delete other members' messages and pin messages. */
|
|
465
655
|
readonly ManageMessages: bigint;
|
|
656
|
+
/** Have links in messages embed. */
|
|
466
657
|
readonly EmbedLinks: bigint;
|
|
658
|
+
/** Upload files and media. */
|
|
467
659
|
readonly AttachFiles: bigint;
|
|
660
|
+
/** Read message history. */
|
|
468
661
|
readonly ReadMessageHistory: bigint;
|
|
662
|
+
/** Mention @everyone, @here and all roles. */
|
|
469
663
|
readonly MentionEveryone: bigint;
|
|
664
|
+
/** Use emojis from other servers. */
|
|
470
665
|
readonly UseExternalEmojis: bigint;
|
|
666
|
+
/** View server insights. */
|
|
471
667
|
readonly ViewGuildInsights: bigint;
|
|
668
|
+
/** Join voice channels. */
|
|
472
669
|
readonly Connect: bigint;
|
|
670
|
+
/** Speak in voice channels. */
|
|
473
671
|
readonly Speak: bigint;
|
|
672
|
+
/** Mute other members in voice channels. */
|
|
474
673
|
readonly MuteMembers: bigint;
|
|
674
|
+
/** Deafen other members in voice channels. */
|
|
475
675
|
readonly DeafenMembers: bigint;
|
|
676
|
+
/** Move members between voice channels. */
|
|
476
677
|
readonly MoveMembers: bigint;
|
|
678
|
+
/** Use voice activity detection instead of push-to-talk. */
|
|
477
679
|
readonly UseVoiceActivity: bigint;
|
|
680
|
+
/** Change one's own nickname. */
|
|
478
681
|
readonly ChangeNickname: bigint;
|
|
682
|
+
/** Change other members' nicknames. */
|
|
479
683
|
readonly ManageNicknames: bigint;
|
|
684
|
+
/** Create, edit and delete roles lower than the member's own. */
|
|
480
685
|
readonly ManageRoles: bigint;
|
|
686
|
+
/** Create, edit and delete webhooks. */
|
|
481
687
|
readonly ManageWebhooks: bigint;
|
|
688
|
+
/** Edit and delete emojis, stickers and soundboard sounds. */
|
|
482
689
|
readonly ManageGuildExpressions: bigint;
|
|
690
|
+
/** Use application commands (slash commands). */
|
|
483
691
|
readonly UseApplicationCommands: bigint;
|
|
692
|
+
/** Request to speak in stage channels. */
|
|
484
693
|
readonly RequestToSpeak: bigint;
|
|
694
|
+
/** Edit and delete scheduled events. */
|
|
485
695
|
readonly ManageEvents: bigint;
|
|
696
|
+
/** Manage and delete threads. */
|
|
486
697
|
readonly ManageThreads: bigint;
|
|
698
|
+
/** Create public threads. */
|
|
487
699
|
readonly CreatePublicThreads: bigint;
|
|
700
|
+
/** Create private threads. */
|
|
488
701
|
readonly CreatePrivateThreads: bigint;
|
|
702
|
+
/** Use stickers from other servers. */
|
|
489
703
|
readonly UseExternalStickers: bigint;
|
|
704
|
+
/** Send messages in threads. */
|
|
490
705
|
readonly SendMessagesInThreads: bigint;
|
|
706
|
+
/** Start activities in voice channels. */
|
|
491
707
|
readonly UseEmbeddedActivities: bigint;
|
|
708
|
+
/** Time out members. */
|
|
492
709
|
readonly ModerateMembers: bigint;
|
|
710
|
+
/** View creator monetization analytics. */
|
|
493
711
|
readonly ViewCreatorMonetizationAnalytics: bigint;
|
|
712
|
+
/** Use soundboard sounds. */
|
|
494
713
|
readonly UseSoundboard: bigint;
|
|
714
|
+
/** Create emojis, stickers and soundboard sounds. */
|
|
495
715
|
readonly CreateGuildExpressions: bigint;
|
|
716
|
+
/** Create scheduled events. */
|
|
496
717
|
readonly CreateEvents: bigint;
|
|
718
|
+
/** Use soundboard sounds from other servers. */
|
|
497
719
|
readonly UseExternalSounds: bigint;
|
|
720
|
+
/** Send voice messages. */
|
|
498
721
|
readonly SendVoiceMessages: bigint;
|
|
722
|
+
/** Send polls. */
|
|
499
723
|
readonly SendPolls: bigint;
|
|
724
|
+
/** Use apps that are not installed in the server. */
|
|
500
725
|
readonly UseExternalApps: bigint;
|
|
726
|
+
/** Pin and unpin messages. */
|
|
501
727
|
readonly PinMessages: bigint;
|
|
502
728
|
};
|
|
729
|
+
/** The name of one entry in `Permission`. */
|
|
503
730
|
export type PermissionName = keyof typeof Permission;
|
|
504
731
|
/** The decimal-string bitfield Discord wants for the named permissions (`"0"` for none). */
|
|
505
732
|
export declare function permissions(names: readonly PermissionName[]): string;
|
|
506
733
|
/** The permission names set in a bitfield, in declaration order (unknown bits are ignored). */
|
|
507
734
|
export declare function permissionNames(bitfield: string): PermissionName[];
|
|
735
|
+
/** Options for `createDiscordOAuthClient`. */
|
|
508
736
|
export interface DiscordOAuthClientOptions {
|
|
509
737
|
/** The application's client id (the same as its application id). Not a secret. */
|
|
510
738
|
clientId: string;
|
|
@@ -523,11 +751,15 @@ export interface DiscordOAuthClientOptions {
|
|
|
523
751
|
}
|
|
524
752
|
/** What a member's token may do: `identify` reads who they are, `connections` reads their linked accounts. */
|
|
525
753
|
export type DiscordOAuthScope = "identify" | "connections";
|
|
754
|
+
/** The token Discord returns from the OAuth2 token endpoint. */
|
|
526
755
|
export interface DiscordOAuthToken {
|
|
756
|
+
/** The access token to send as a bearer. */
|
|
527
757
|
access_token: string;
|
|
758
|
+
/** The token type, `Bearer`. */
|
|
528
759
|
token_type: string;
|
|
529
760
|
/** Seconds until `access_token` stops working. */
|
|
530
761
|
expires_in: number;
|
|
762
|
+
/** The token that can be exchanged for a new access token. */
|
|
531
763
|
refresh_token?: string;
|
|
532
764
|
/** The scopes granted, space separated. */
|
|
533
765
|
scope: string;
|
|
@@ -542,12 +774,16 @@ export interface DiscordConnection {
|
|
|
542
774
|
type: string;
|
|
543
775
|
/** Whether Discord confirmed the member owns the account. */
|
|
544
776
|
verified: boolean;
|
|
777
|
+
/** Discord's visibility code: 0 only the member, 1 everyone. */
|
|
545
778
|
visibility?: number;
|
|
546
779
|
}
|
|
547
780
|
/** The member who signed in, as `GET /users/@me` returns it with their token. */
|
|
548
781
|
export interface DiscordOAuthUser {
|
|
782
|
+
/** The Discord user id. */
|
|
549
783
|
id: string;
|
|
784
|
+
/** The account's username. */
|
|
550
785
|
username: string;
|
|
786
|
+
/** The display name, or `null` when the member has none. */
|
|
551
787
|
global_name?: string | null;
|
|
552
788
|
}
|
|
553
789
|
/**
|
|
@@ -580,6 +816,7 @@ export declare function createDiscordOAuthClient(opts: DiscordOAuthClientOptions
|
|
|
580
816
|
/** `GET /users/@me/connections` as the member (needs `connections`). */
|
|
581
817
|
connections: (accessToken: string) => Promise<DiscordConnection[]>;
|
|
582
818
|
};
|
|
819
|
+
/** The member-OAuth client returned by `createDiscordOAuthClient`. */
|
|
583
820
|
export type DiscordOAuthClient = ReturnType<typeof createDiscordOAuthClient>;
|
|
584
821
|
/**
|
|
585
822
|
* The verified connection of one service, or `undefined`. Unverified ones are ignored: anyone can type a
|
|
@@ -603,6 +840,7 @@ export declare function signOAuthState(secret: string, opts?: {
|
|
|
603
840
|
export declare function verifyOAuthState(secret: string, state: string, opts?: {
|
|
604
841
|
now?: number;
|
|
605
842
|
}): boolean;
|
|
843
|
+
/** Builds the webhook client: a `webhooks` group that reads, posts to and deletes messages from a webhook by its id and token. */
|
|
606
844
|
export declare function createDiscordClient(opts?: DiscordClientOptions): {
|
|
607
845
|
webhooks: {
|
|
608
846
|
get: (id: string, token: string) => Promise<DiscordWebhookInfo>;
|
|
@@ -613,5 +851,6 @@ export declare function createDiscordClient(opts?: DiscordClientOptions): {
|
|
|
613
851
|
deleteMessage: (id: string, token: string, messageId: string) => Promise<void>;
|
|
614
852
|
};
|
|
615
853
|
};
|
|
854
|
+
/** The client `createDiscordClient` returns. */
|
|
616
855
|
export type DiscordClient = ReturnType<typeof createDiscordClient>;
|
|
617
856
|
export type { DiscordClientOptions, DiscordWebhookInfo };
|
package/dist/index.mjs
CHANGED
|
@@ -344,9 +344,13 @@ function createDiscordBotClient(opts) {
|
|
|
344
344
|
// src/bot/bot.type.ts
|
|
345
345
|
/** Discord channel `type` values this client creates or reads. */
|
|
346
346
|
const ChannelType = {
|
|
347
|
+
/** A text channel. */
|
|
347
348
|
Text: 0,
|
|
349
|
+
/** A category that groups channels. */
|
|
348
350
|
Category: 4,
|
|
351
|
+
/** An announcement channel. */
|
|
349
352
|
Announcement: 5,
|
|
353
|
+
/** A forum channel. */
|
|
350
354
|
Forum: 15
|
|
351
355
|
};
|
|
352
356
|
/**
|
|
@@ -354,11 +358,17 @@ const ChannelType = {
|
|
|
354
358
|
* that Discord has not verified; once verified, the plain ones take over and the toggle is Discord's to change.
|
|
355
359
|
*/
|
|
356
360
|
const ApplicationFlag = {
|
|
361
|
+
/** Application may receive presence updates (verified apps). */
|
|
357
362
|
GatewayPresence: 4096,
|
|
363
|
+
/** The privileged presence intent toggle for an unverified app. */
|
|
358
364
|
GatewayPresenceLimited: 8192,
|
|
365
|
+
/** Application may receive server-member events and the member list (verified apps). */
|
|
359
366
|
GatewayGuildMembers: 16384,
|
|
367
|
+
/** The privileged server-members intent toggle for an unverified app. */
|
|
360
368
|
GatewayGuildMembersLimited: 32768,
|
|
369
|
+
/** Application may read message content (verified apps). */
|
|
361
370
|
GatewayMessageContent: 1 << 18,
|
|
371
|
+
/** The privileged message-content intent toggle for an unverified app. */
|
|
362
372
|
GatewayMessageContentLimited: 1 << 19
|
|
363
373
|
};
|
|
364
374
|
// src/bot/permissions.ts
|
|
@@ -369,55 +379,105 @@ const ApplicationFlag = {
|
|
|
369
379
|
* `permissions` cannot set them by name.
|
|
370
380
|
*/
|
|
371
381
|
const Permission = {
|
|
382
|
+
/** Create invites to the server. */
|
|
372
383
|
CreateInstantInvite: 1n << 0n,
|
|
384
|
+
/** Kick members. */
|
|
373
385
|
KickMembers: 1n << 1n,
|
|
386
|
+
/** Ban members. */
|
|
374
387
|
BanMembers: 1n << 2n,
|
|
388
|
+
/** Administrator: all permissions, and bypasses channel overrides. */
|
|
375
389
|
Administrator: 1n << 3n,
|
|
390
|
+
/** Create, edit and delete channels. */
|
|
376
391
|
ManageChannels: 1n << 4n,
|
|
392
|
+
/** Change server settings. */
|
|
377
393
|
ManageGuild: 1n << 5n,
|
|
394
|
+
/** Add new reactions to messages. */
|
|
378
395
|
AddReactions: 1n << 6n,
|
|
396
|
+
/** View the audit log. */
|
|
379
397
|
ViewAuditLog: 1n << 7n,
|
|
398
|
+
/** Use priority speaker in voice channels. */
|
|
380
399
|
PrioritySpeaker: 1n << 8n,
|
|
400
|
+
/** Go live (stream) in voice channels. */
|
|
381
401
|
Stream: 1n << 9n,
|
|
402
|
+
/** View channels (and read their messages). */
|
|
382
403
|
ViewChannel: 1n << 10n,
|
|
404
|
+
/** Send messages in text channels. */
|
|
383
405
|
SendMessages: 1n << 11n,
|
|
406
|
+
/** Send text-to-speech messages. */
|
|
384
407
|
SendTtsMessages: 1n << 12n,
|
|
408
|
+
/** Delete other members' messages and pin messages. */
|
|
385
409
|
ManageMessages: 1n << 13n,
|
|
410
|
+
/** Have links in messages embed. */
|
|
386
411
|
EmbedLinks: 1n << 14n,
|
|
412
|
+
/** Upload files and media. */
|
|
387
413
|
AttachFiles: 1n << 15n,
|
|
414
|
+
/** Read message history. */
|
|
388
415
|
ReadMessageHistory: 1n << 16n,
|
|
416
|
+
/** Mention @everyone, @here and all roles. */
|
|
389
417
|
MentionEveryone: 1n << 17n,
|
|
418
|
+
/** Use emojis from other servers. */
|
|
390
419
|
UseExternalEmojis: 1n << 18n,
|
|
420
|
+
/** View server insights. */
|
|
391
421
|
ViewGuildInsights: 1n << 19n,
|
|
422
|
+
/** Join voice channels. */
|
|
392
423
|
Connect: 1n << 20n,
|
|
424
|
+
/** Speak in voice channels. */
|
|
393
425
|
Speak: 1n << 21n,
|
|
426
|
+
/** Mute other members in voice channels. */
|
|
394
427
|
MuteMembers: 1n << 22n,
|
|
428
|
+
/** Deafen other members in voice channels. */
|
|
395
429
|
DeafenMembers: 1n << 23n,
|
|
430
|
+
/** Move members between voice channels. */
|
|
396
431
|
MoveMembers: 1n << 24n,
|
|
432
|
+
/** Use voice activity detection instead of push-to-talk. */
|
|
397
433
|
UseVoiceActivity: 1n << 25n,
|
|
434
|
+
/** Change one's own nickname. */
|
|
398
435
|
ChangeNickname: 1n << 26n,
|
|
436
|
+
/** Change other members' nicknames. */
|
|
399
437
|
ManageNicknames: 1n << 27n,
|
|
438
|
+
/** Create, edit and delete roles lower than the member's own. */
|
|
400
439
|
ManageRoles: 1n << 28n,
|
|
440
|
+
/** Create, edit and delete webhooks. */
|
|
401
441
|
ManageWebhooks: 1n << 29n,
|
|
442
|
+
/** Edit and delete emojis, stickers and soundboard sounds. */
|
|
402
443
|
ManageGuildExpressions: 1n << 30n,
|
|
444
|
+
/** Use application commands (slash commands). */
|
|
403
445
|
UseApplicationCommands: 1n << 31n,
|
|
446
|
+
/** Request to speak in stage channels. */
|
|
404
447
|
RequestToSpeak: 1n << 32n,
|
|
448
|
+
/** Edit and delete scheduled events. */
|
|
405
449
|
ManageEvents: 1n << 33n,
|
|
450
|
+
/** Manage and delete threads. */
|
|
406
451
|
ManageThreads: 1n << 34n,
|
|
452
|
+
/** Create public threads. */
|
|
407
453
|
CreatePublicThreads: 1n << 35n,
|
|
454
|
+
/** Create private threads. */
|
|
408
455
|
CreatePrivateThreads: 1n << 36n,
|
|
456
|
+
/** Use stickers from other servers. */
|
|
409
457
|
UseExternalStickers: 1n << 37n,
|
|
458
|
+
/** Send messages in threads. */
|
|
410
459
|
SendMessagesInThreads: 1n << 38n,
|
|
460
|
+
/** Start activities in voice channels. */
|
|
411
461
|
UseEmbeddedActivities: 1n << 39n,
|
|
462
|
+
/** Time out members. */
|
|
412
463
|
ModerateMembers: 1n << 40n,
|
|
464
|
+
/** View creator monetization analytics. */
|
|
413
465
|
ViewCreatorMonetizationAnalytics: 1n << 41n,
|
|
466
|
+
/** Use soundboard sounds. */
|
|
414
467
|
UseSoundboard: 1n << 42n,
|
|
468
|
+
/** Create emojis, stickers and soundboard sounds. */
|
|
415
469
|
CreateGuildExpressions: 1n << 43n,
|
|
470
|
+
/** Create scheduled events. */
|
|
416
471
|
CreateEvents: 1n << 44n,
|
|
472
|
+
/** Use soundboard sounds from other servers. */
|
|
417
473
|
UseExternalSounds: 1n << 45n,
|
|
474
|
+
/** Send voice messages. */
|
|
418
475
|
SendVoiceMessages: 1n << 46n,
|
|
476
|
+
/** Send polls. */
|
|
419
477
|
SendPolls: 1n << 49n,
|
|
478
|
+
/** Use apps that are not installed in the server. */
|
|
420
479
|
UseExternalApps: 1n << 50n,
|
|
480
|
+
/** Pin and unpin messages. */
|
|
421
481
|
PinMessages: 1n << 51n
|
|
422
482
|
};
|
|
423
483
|
/** The decimal-string bitfield Discord wants for the named permissions (`"0"` for none). */
|
|
@@ -561,6 +621,7 @@ function verifyOAuthState(secret, state, opts = {}) {
|
|
|
561
621
|
return Number(expires) >= Math.floor((opts.now ?? Date.now()) / 1e3);
|
|
562
622
|
}
|
|
563
623
|
// src/index.ts
|
|
624
|
+
/** Builds the webhook client: a `webhooks` group that reads, posts to and deletes messages from a webhook by its id and token. */
|
|
564
625
|
function createDiscordClient(opts = {}) {
|
|
565
626
|
return { webhooks: webhooks(opts.baseUrl ?? "https://discord.com/api/v10", opts.fetch ?? globalThis.fetch) };
|
|
566
627
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/discord-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.4",
|
|
4
4
|
"description": "A TypeScript client for the Discord webhooks API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"discord",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.4"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^26",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"tsdown": "^0.23.3",
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"vitest": "^5.0.5",
|
|
47
|
-
"@theholocron/
|
|
48
|
-
"@theholocron/
|
|
49
|
-
"@theholocron/eslint-config": "^8.9.0-alpha.
|
|
50
|
-
"@theholocron/
|
|
47
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.5",
|
|
48
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.5",
|
|
49
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.5",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.5"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=22.0.0"
|