@satorijs/adapter-discord 4.4.0 → 4.5.1

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/lib/index.cjs ADDED
@@ -0,0 +1,2289 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Discord: () => utils_exports,
24
+ DiscordBot: () => DiscordBot,
25
+ DiscordMessageEncoder: () => DiscordMessageEncoder,
26
+ WsClient: () => WsClient,
27
+ default: () => src_default
28
+ });
29
+ module.exports = __toCommonJS(src_exports);
30
+
31
+ // src/bot.ts
32
+ var import_core5 = require("@satorijs/core");
33
+
34
+ // src/utils.ts
35
+ var utils_exports = {};
36
+ __export(utils_exports, {
37
+ ActivityFlag: () => ActivityFlag,
38
+ ActivityType: () => ActivityType,
39
+ AllowedMentionType: () => AllowedMentionType,
40
+ ApplicationCommand: () => ApplicationCommand2,
41
+ ApplicationFlag: () => ApplicationFlag,
42
+ ApplicationRoleConnection: () => ApplicationRoleConnection,
43
+ AuditLog: () => AuditLog,
44
+ AutoModerationAction: () => AutoModerationAction,
45
+ AutoModerationRule: () => AutoModerationRule2,
46
+ ButtonStyles: () => ButtonStyles,
47
+ Channel: () => Channel2,
48
+ ComponentType: () => ComponentType,
49
+ DeviceType: () => DeviceType,
50
+ Gateway: () => Gateway,
51
+ Guild: () => Guild3,
52
+ GuildFeature: () => GuildFeature,
53
+ GuildScheduledEvent: () => GuildScheduledEvent3,
54
+ IntegrationExpireBehavior: () => IntegrationExpireBehavior,
55
+ Interaction: () => Interaction,
56
+ Internal: () => Internal,
57
+ Invite: () => Invite,
58
+ Locale: () => Locale3,
59
+ MembershipState: () => MembershipState,
60
+ Message: () => Message2,
61
+ OverwriteType: () => OverwriteType,
62
+ Permission: () => Permission,
63
+ PremiumType: () => PremiumType,
64
+ StatusType: () => StatusType2,
65
+ Sticker: () => Sticker3,
66
+ SystemChannelFlag: () => SystemChannelFlag,
67
+ TextInputStyles: () => TextInputStyles,
68
+ UserFlag: () => UserFlag,
69
+ VisibilityType: () => VisibilityType,
70
+ Webhook: () => Webhook2,
71
+ adaptSession: () => adaptSession,
72
+ decodeChannel: () => decodeChannel,
73
+ decodeGuild: () => decodeGuild,
74
+ decodeGuildMember: () => decodeGuildMember,
75
+ decodeMessage: () => decodeMessage,
76
+ decodeRole: () => decodeRole,
77
+ decodeUser: () => decodeUser,
78
+ encodeCommand: () => encodeCommand,
79
+ encodeCommandOptions: () => encodeCommandOptions,
80
+ encodeRole: () => encodeRole,
81
+ sanitize: () => sanitize,
82
+ setupMessageGuildId: () => setupMessageGuildId
83
+ });
84
+ var import_core2 = require("@satorijs/core");
85
+
86
+ // src/types/internal.ts
87
+ var import_core = require("@satorijs/core");
88
+ var Internal = class _Internal {
89
+ constructor(bot) {
90
+ this.bot = bot;
91
+ }
92
+ static {
93
+ __name(this, "Internal");
94
+ }
95
+ static define(routes) {
96
+ for (const path in routes) {
97
+ for (const key in routes[path]) {
98
+ const method = key;
99
+ for (const name of (0, import_core.makeArray)(routes[path][method])) {
100
+ _Internal.prototype[name] = async function(...args) {
101
+ const raw = args.join(", ");
102
+ const url = path.replace(/\{([^}]+)\}/g, () => {
103
+ if (!args.length)
104
+ throw new Error(`too few arguments for ${path}, received ${raw}`);
105
+ return args.shift();
106
+ });
107
+ const config = {};
108
+ if (args.length === 1) {
109
+ if (method === "GET" || method === "DELETE") {
110
+ config.params = args[0];
111
+ } else {
112
+ config.data = args[0];
113
+ }
114
+ } else if (args.length === 2 && method !== "GET" && method !== "DELETE") {
115
+ config.data = args[0];
116
+ config.params = args[1];
117
+ } else if (args.length > 1) {
118
+ throw new Error(`too many arguments for ${path}, received ${raw}`);
119
+ }
120
+ try {
121
+ this.bot.logger.debug(`${method} ${url}`, config);
122
+ return (await this.bot.http(method, url, config)).data;
123
+ } catch (error) {
124
+ if (!this.bot.http.isError(error) || !error.response)
125
+ throw error;
126
+ throw new Error(`[${error.response.status}] ${JSON.stringify(error.response.data)}`);
127
+ }
128
+ };
129
+ }
130
+ }
131
+ }
132
+ }
133
+ };
134
+
135
+ // src/types/application.ts
136
+ var ApplicationFlag = /* @__PURE__ */ ((ApplicationFlag2) => {
137
+ ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE"] = 4096] = "GATEWAY_PRESENCE";
138
+ ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE_LIMITED"] = 8192] = "GATEWAY_PRESENCE_LIMITED";
139
+ ApplicationFlag2[ApplicationFlag2["GATEWAY_GUILD_MEMBERS"] = 16384] = "GATEWAY_GUILD_MEMBERS";
140
+ ApplicationFlag2[ApplicationFlag2["GATEWAY_GUILD_MEMBERS_LIMITED"] = 32768] = "GATEWAY_GUILD_MEMBERS_LIMITED";
141
+ ApplicationFlag2[ApplicationFlag2["VERIFICATION_PENDING_GUILD_LIMIT"] = 65536] = "VERIFICATION_PENDING_GUILD_LIMIT";
142
+ ApplicationFlag2[ApplicationFlag2["EMBEDDED"] = 131072] = "EMBEDDED";
143
+ ApplicationFlag2[ApplicationFlag2["GATEWAY_MESSAGE_CONTENT"] = 262144] = "GATEWAY_MESSAGE_CONTENT";
144
+ ApplicationFlag2[ApplicationFlag2["GATEWAY_MESSAGE_CONTENT_LIMITED"] = 524288] = "GATEWAY_MESSAGE_CONTENT_LIMITED";
145
+ ApplicationFlag2[ApplicationFlag2["APPLICATION_COMMAND_BADGE"] = 8388608] = "APPLICATION_COMMAND_BADGE";
146
+ return ApplicationFlag2;
147
+ })(ApplicationFlag || {});
148
+ Internal.define({
149
+ "/oauth2/applications/@me": {
150
+ GET: "getCurrentBotApplicationInformation"
151
+ },
152
+ "/oauth2/@me": {
153
+ GET: "getCurrentAuthorizationInformation"
154
+ }
155
+ });
156
+
157
+ // src/types/application-role-connection.ts
158
+ var ApplicationRoleConnection;
159
+ ((ApplicationRoleConnection2) => {
160
+ let MetadataType;
161
+ ((MetadataType2) => {
162
+ MetadataType2[MetadataType2["INTEGER_LESS_THAN_OR_EQUAL"] = 1] = "INTEGER_LESS_THAN_OR_EQUAL";
163
+ MetadataType2[MetadataType2["INTEGER_GREATER_THAN_OR_EQUAL"] = 2] = "INTEGER_GREATER_THAN_OR_EQUAL";
164
+ MetadataType2[MetadataType2["INTEGER_EQUAL"] = 3] = "INTEGER_EQUAL";
165
+ MetadataType2[MetadataType2["INTEGER_NOT_EQUAL"] = 4] = "INTEGER_NOT_EQUAL";
166
+ MetadataType2[MetadataType2["DATETIME_LESS_THAN_OR_EQUAL"] = 5] = "DATETIME_LESS_THAN_OR_EQUAL";
167
+ MetadataType2[MetadataType2["DATETIME_GREATER_THAN_OR_EQUAL"] = 6] = "DATETIME_GREATER_THAN_OR_EQUAL";
168
+ MetadataType2[MetadataType2["BOOLEAN_EQUAL"] = 7] = "BOOLEAN_EQUAL";
169
+ MetadataType2[MetadataType2["BOOLEAN_NOT_EQUAL"] = 8] = "BOOLEAN_NOT_EQUAL";
170
+ })(MetadataType = ApplicationRoleConnection2.MetadataType || (ApplicationRoleConnection2.MetadataType = {}));
171
+ })(ApplicationRoleConnection || (ApplicationRoleConnection = {}));
172
+ Internal.define({
173
+ "/applications/{application.id}/role-connections/metadata": {
174
+ GET: "getApplicationRoleConnectionMetadataRecords",
175
+ PUT: "updateApplicationRoleConnectionMetadataRecords"
176
+ }
177
+ });
178
+
179
+ // src/types/audit-log.ts
180
+ var AuditLog;
181
+ ((AuditLog2) => {
182
+ let Type;
183
+ ((Type2) => {
184
+ Type2[Type2["GUILD_UPDATE"] = 1] = "GUILD_UPDATE";
185
+ Type2[Type2["CHANNEL_CREATE"] = 10] = "CHANNEL_CREATE";
186
+ Type2[Type2["CHANNEL_UPDATE"] = 11] = "CHANNEL_UPDATE";
187
+ Type2[Type2["CHANNEL_DELETE"] = 12] = "CHANNEL_DELETE";
188
+ Type2[Type2["CHANNEL_OVERWRITE_CREATE"] = 13] = "CHANNEL_OVERWRITE_CREATE";
189
+ Type2[Type2["CHANNEL_OVERWRITE_UPDATE"] = 14] = "CHANNEL_OVERWRITE_UPDATE";
190
+ Type2[Type2["CHANNEL_OVERWRITE_DELETE"] = 15] = "CHANNEL_OVERWRITE_DELETE";
191
+ Type2[Type2["MEMBER_KICK"] = 20] = "MEMBER_KICK";
192
+ Type2[Type2["MEMBER_PRUNE"] = 21] = "MEMBER_PRUNE";
193
+ Type2[Type2["MEMBER_BAN_ADD"] = 22] = "MEMBER_BAN_ADD";
194
+ Type2[Type2["MEMBER_BAN_REMOVE"] = 23] = "MEMBER_BAN_REMOVE";
195
+ Type2[Type2["MEMBER_UPDATE"] = 24] = "MEMBER_UPDATE";
196
+ Type2[Type2["MEMBER_ROLE_UPDATE"] = 25] = "MEMBER_ROLE_UPDATE";
197
+ Type2[Type2["MEMBER_MOVE"] = 26] = "MEMBER_MOVE";
198
+ Type2[Type2["MEMBER_DISCONNECT"] = 27] = "MEMBER_DISCONNECT";
199
+ Type2[Type2["BOT_ADD"] = 28] = "BOT_ADD";
200
+ Type2[Type2["ROLE_CREATE"] = 30] = "ROLE_CREATE";
201
+ Type2[Type2["ROLE_UPDATE"] = 31] = "ROLE_UPDATE";
202
+ Type2[Type2["ROLE_DELETE"] = 32] = "ROLE_DELETE";
203
+ Type2[Type2["INVITE_CREATE"] = 40] = "INVITE_CREATE";
204
+ Type2[Type2["INVITE_UPDATE"] = 41] = "INVITE_UPDATE";
205
+ Type2[Type2["INVITE_DELETE"] = 42] = "INVITE_DELETE";
206
+ Type2[Type2["WEBHOOK_CREATE"] = 50] = "WEBHOOK_CREATE";
207
+ Type2[Type2["WEBHOOK_UPDATE"] = 51] = "WEBHOOK_UPDATE";
208
+ Type2[Type2["WEBHOOK_DELETE"] = 52] = "WEBHOOK_DELETE";
209
+ Type2[Type2["EMOJI_CREATE"] = 60] = "EMOJI_CREATE";
210
+ Type2[Type2["EMOJI_UPDATE"] = 61] = "EMOJI_UPDATE";
211
+ Type2[Type2["EMOJI_DELETE"] = 62] = "EMOJI_DELETE";
212
+ Type2[Type2["MESSAGE_DELETE"] = 72] = "MESSAGE_DELETE";
213
+ Type2[Type2["MESSAGE_BULK_DELETE"] = 73] = "MESSAGE_BULK_DELETE";
214
+ Type2[Type2["MESSAGE_PIN"] = 74] = "MESSAGE_PIN";
215
+ Type2[Type2["MESSAGE_UNPIN"] = 75] = "MESSAGE_UNPIN";
216
+ Type2[Type2["INTEGRATION_CREATE"] = 80] = "INTEGRATION_CREATE";
217
+ Type2[Type2["INTEGRATION_UPDATE"] = 81] = "INTEGRATION_UPDATE";
218
+ Type2[Type2["INTEGRATION_DELETE"] = 82] = "INTEGRATION_DELETE";
219
+ Type2[Type2["STAGE_INSTANCE_CREATE"] = 83] = "STAGE_INSTANCE_CREATE";
220
+ Type2[Type2["STAGE_INSTANCE_UPDATE"] = 84] = "STAGE_INSTANCE_UPDATE";
221
+ Type2[Type2["STAGE_INSTANCE_DELETE"] = 85] = "STAGE_INSTANCE_DELETE";
222
+ Type2[Type2["STICKER_CREATE"] = 90] = "STICKER_CREATE";
223
+ Type2[Type2["STICKER_UPDATE"] = 91] = "STICKER_UPDATE";
224
+ Type2[Type2["STICKER_DELETE"] = 92] = "STICKER_DELETE";
225
+ Type2[Type2["GUILD_SCHEDULED_EVENT_CREATE"] = 100] = "GUILD_SCHEDULED_EVENT_CREATE";
226
+ Type2[Type2["GUILD_SCHEDULED_EVENT_UPDATE"] = 101] = "GUILD_SCHEDULED_EVENT_UPDATE";
227
+ Type2[Type2["GUILD_SCHEDULED_EVENT_DELETE"] = 102] = "GUILD_SCHEDULED_EVENT_DELETE";
228
+ Type2[Type2["THREAD_CREATE"] = 110] = "THREAD_CREATE";
229
+ Type2[Type2["THREAD_UPDATE"] = 111] = "THREAD_UPDATE";
230
+ Type2[Type2["THREAD_DELETE"] = 112] = "THREAD_DELETE";
231
+ Type2[Type2["APPLICATION_COMMAND_PERMISSION_UPDATE"] = 121] = "APPLICATION_COMMAND_PERMISSION_UPDATE";
232
+ Type2[Type2["AUTO_MODERATION_RULE_CREATE"] = 140] = "AUTO_MODERATION_RULE_CREATE";
233
+ Type2[Type2["AUTO_MODERATION_RULE_UPDATE"] = 141] = "AUTO_MODERATION_RULE_UPDATE";
234
+ Type2[Type2["AUTO_MODERATION_RULE_DELETE"] = 142] = "AUTO_MODERATION_RULE_DELETE";
235
+ Type2[Type2["AUTO_MODERATION_BLOCK_MESSAGE"] = 143] = "AUTO_MODERATION_BLOCK_MESSAGE";
236
+ Type2[Type2["AUTO_MODERATION_FLAG_TO_CHANNEL"] = 144] = "AUTO_MODERATION_FLAG_TO_CHANNEL";
237
+ Type2[Type2["AUTO_MODERATION_USER_COMMUNICATION_DISABLED"] = 145] = "AUTO_MODERATION_USER_COMMUNICATION_DISABLED";
238
+ })(Type = AuditLog2.Type || (AuditLog2.Type = {}));
239
+ })(AuditLog || (AuditLog = {}));
240
+ Internal.define({
241
+ "/guilds/{guild.id}/audit-logs": {
242
+ GET: "getGuildAuditLog"
243
+ }
244
+ });
245
+
246
+ // src/types/auto-moderation.ts
247
+ var AutoModerationRule2;
248
+ ((AutoModerationRule3) => {
249
+ let EventType;
250
+ ((EventType2) => {
251
+ EventType2[EventType2["MESSAGE_SEND"] = 1] = "MESSAGE_SEND";
252
+ })(EventType = AutoModerationRule3.EventType || (AutoModerationRule3.EventType = {}));
253
+ let TriggerType;
254
+ ((TriggerType2) => {
255
+ TriggerType2[TriggerType2["KEYWORD"] = 1] = "KEYWORD";
256
+ TriggerType2[TriggerType2["SPAM"] = 3] = "SPAM";
257
+ TriggerType2[TriggerType2["KEYWORD_PRESET"] = 4] = "KEYWORD_PRESET";
258
+ TriggerType2[TriggerType2["MENTION_SPAM"] = 5] = "MENTION_SPAM";
259
+ })(TriggerType = AutoModerationRule3.TriggerType || (AutoModerationRule3.TriggerType = {}));
260
+ let KeywordPresetType;
261
+ ((KeywordPresetType2) => {
262
+ KeywordPresetType2[KeywordPresetType2["PROFANITY"] = 1] = "PROFANITY";
263
+ KeywordPresetType2[KeywordPresetType2["SEXUAL_CONTEN"] = 2] = "SEXUAL_CONTEN";
264
+ KeywordPresetType2[KeywordPresetType2["SLURS"] = 3] = "SLURS";
265
+ })(KeywordPresetType = AutoModerationRule3.KeywordPresetType || (AutoModerationRule3.KeywordPresetType = {}));
266
+ })(AutoModerationRule2 || (AutoModerationRule2 = {}));
267
+ var AutoModerationAction;
268
+ ((AutoModerationAction2) => {
269
+ let Type;
270
+ ((Type2) => {
271
+ Type2[Type2["BLOCK_MESSAGE"] = 1] = "BLOCK_MESSAGE";
272
+ Type2[Type2["SEND_ALERT_MESSAGE"] = 2] = "SEND_ALERT_MESSAGE";
273
+ Type2[Type2["TIMEOUT"] = 3] = "TIMEOUT";
274
+ })(Type = AutoModerationAction2.Type || (AutoModerationAction2.Type = {}));
275
+ })(AutoModerationAction || (AutoModerationAction = {}));
276
+ Internal.define({
277
+ "/guilds/{guild.id}/auto-moderation/rules": {
278
+ GET: "listAutoModerationRules",
279
+ POST: "createAutoModerationRule"
280
+ },
281
+ "/guilds/{guild.id}/auto-moderation/rules/{rule.id}": {
282
+ GET: "getAutoModerationRule",
283
+ PATCH: "modifyAutoModerationRule",
284
+ DELETE: "deleteAutoModerationRule"
285
+ }
286
+ });
287
+
288
+ // src/types/ban.ts
289
+ Internal.define({
290
+ "/guilds/{guild.id}/bans": {
291
+ GET: "getGuildBans"
292
+ },
293
+ "/guilds/{guild.id}/bans/{user.id}": {
294
+ GET: "getGuildBan",
295
+ PUT: "createGuildBan",
296
+ DELETE: "removeGuildBan"
297
+ }
298
+ });
299
+
300
+ // src/types/channel.ts
301
+ var Channel2;
302
+ ((Channel11) => {
303
+ let Type;
304
+ ((Type2) => {
305
+ Type2[Type2["GUILD_TEXT"] = 0] = "GUILD_TEXT";
306
+ Type2[Type2["DM"] = 1] = "DM";
307
+ Type2[Type2["GUILD_VOICE"] = 2] = "GUILD_VOICE";
308
+ Type2[Type2["GROUP_DM"] = 3] = "GROUP_DM";
309
+ Type2[Type2["GUILD_CATEGORY"] = 4] = "GUILD_CATEGORY";
310
+ Type2[Type2["GUILD_NEWS"] = 5] = "GUILD_NEWS";
311
+ Type2[Type2["GUILD_STORE"] = 6] = "GUILD_STORE";
312
+ Type2[Type2["GUILD_NEWS_THREAD"] = 10] = "GUILD_NEWS_THREAD";
313
+ Type2[Type2["GUILD_PUBLIC_THREAD"] = 11] = "GUILD_PUBLIC_THREAD";
314
+ Type2[Type2["GUILD_PRIVATE_THREAD"] = 12] = "GUILD_PRIVATE_THREAD";
315
+ Type2[Type2["GUILD_STAGE_VOICE"] = 13] = "GUILD_STAGE_VOICE";
316
+ Type2[Type2["GUILD_DIRECTORY"] = 14] = "GUILD_DIRECTORY";
317
+ Type2[Type2["GUILD_FORUM"] = 15] = "GUILD_FORUM";
318
+ })(Type = Channel11.Type || (Channel11.Type = {}));
319
+ })(Channel2 || (Channel2 = {}));
320
+ var OverwriteType = /* @__PURE__ */ ((OverwriteType2) => {
321
+ OverwriteType2[OverwriteType2["ROLE"] = 0] = "ROLE";
322
+ OverwriteType2[OverwriteType2["MEMBER"] = 1] = "MEMBER";
323
+ return OverwriteType2;
324
+ })(OverwriteType || {});
325
+ var AllowedMentionType = /* @__PURE__ */ ((AllowedMentionType2) => {
326
+ AllowedMentionType2["ROLE_MENTIONS"] = "roles";
327
+ AllowedMentionType2["USER_MENTIONS"] = "users";
328
+ AllowedMentionType2["EVERYONE_MENTIONS"] = "everyone";
329
+ return AllowedMentionType2;
330
+ })(AllowedMentionType || {});
331
+ Internal.define({
332
+ "/users/@me/channels": {
333
+ POST: ["createDM", "createGroupDM"]
334
+ }
335
+ });
336
+ Internal.define({
337
+ "/guilds/{guild.id}/channels": {
338
+ GET: "getGuildChannels",
339
+ POST: "createGuildChannel",
340
+ PATCH: "modifyGuildChannelPositions"
341
+ }
342
+ });
343
+ Internal.define({
344
+ "/channels/{channel.id}": {
345
+ GET: "getChannel",
346
+ PATCH: "modifyChannel",
347
+ DELETE: "deleteChannel"
348
+ },
349
+ "/channels/{channel.id}/permissions/{overwrite.id}": {
350
+ PUT: "editChannelPermissions",
351
+ DELETE: "deleteChannelPermission"
352
+ },
353
+ "/channels/{channel.id}/followers": {
354
+ POST: "followNewsChannel"
355
+ },
356
+ "/channels/{channel.id}/typing": {
357
+ POST: "triggerTypingIndicator"
358
+ },
359
+ "/channels/{channel.id}/recipients/{user.id}": {
360
+ PUT: "groupDMAddRecipient",
361
+ DELETE: "groupDMRemoveRecipient"
362
+ }
363
+ });
364
+
365
+ // src/types/command.ts
366
+ var ApplicationCommand2;
367
+ ((ApplicationCommand4) => {
368
+ let Type;
369
+ ((Type2) => {
370
+ Type2[Type2["CHAT_INPUT"] = 1] = "CHAT_INPUT";
371
+ Type2[Type2["USER"] = 2] = "USER";
372
+ Type2[Type2["MESSAGE"] = 3] = "MESSAGE";
373
+ })(Type = ApplicationCommand4.Type || (ApplicationCommand4.Type = {}));
374
+ let OptionType;
375
+ ((OptionType2) => {
376
+ OptionType2[OptionType2["SUB_COMMAND"] = 1] = "SUB_COMMAND";
377
+ OptionType2[OptionType2["SUB_COMMAND_GROUP"] = 2] = "SUB_COMMAND_GROUP";
378
+ OptionType2[OptionType2["STRING"] = 3] = "STRING";
379
+ OptionType2[OptionType2["INTEGER"] = 4] = "INTEGER";
380
+ OptionType2[OptionType2["BOOLEAN"] = 5] = "BOOLEAN";
381
+ OptionType2[OptionType2["USER"] = 6] = "USER";
382
+ OptionType2[OptionType2["CHANNEL"] = 7] = "CHANNEL";
383
+ OptionType2[OptionType2["ROLE"] = 8] = "ROLE";
384
+ OptionType2[OptionType2["MENTIONABLE"] = 9] = "MENTIONABLE";
385
+ OptionType2[OptionType2["NUMBER"] = 10] = "NUMBER";
386
+ OptionType2[OptionType2["ATTACHMENT"] = 11] = "ATTACHMENT";
387
+ })(OptionType = ApplicationCommand4.OptionType || (ApplicationCommand4.OptionType = {}));
388
+ let PermissionType;
389
+ ((PermissionType2) => {
390
+ PermissionType2[PermissionType2["ROLE"] = 1] = "ROLE";
391
+ PermissionType2[PermissionType2["USER"] = 2] = "USER";
392
+ PermissionType2[PermissionType2["CHANNEL"] = 3] = "CHANNEL";
393
+ })(PermissionType = ApplicationCommand4.PermissionType || (ApplicationCommand4.PermissionType = {}));
394
+ })(ApplicationCommand2 || (ApplicationCommand2 = {}));
395
+ Internal.define({
396
+ "/applications/{application.id}/commands": {
397
+ GET: "getGlobalApplicationCommands",
398
+ POST: "createGlobalApplicationCommand",
399
+ PUT: "bulkOverwriteGlobalApplicationCommands"
400
+ },
401
+ "/applications/{application.id}/commands/{command.id}": {
402
+ GET: "getGlobalApplicationCommand",
403
+ PATCH: "editGlobalApplicationCommand",
404
+ DELETE: "deleteGlobalApplicationCommand"
405
+ },
406
+ "/applications/{application.id}/guilds/{guild.id}/commands": {
407
+ GET: "getGuildApplicationCommands",
408
+ POST: "createGuildApplicationCommand",
409
+ PUT: "bulkOverwriteGuildApplicationCommands"
410
+ },
411
+ "/applications/{application.id}/guilds/{guild.id}/commands/{command.id}": {
412
+ GET: "getGuildApplicationCommand",
413
+ PATCH: "editGuildApplicationCommand",
414
+ DELETE: "deleteGuildApplicationCommand"
415
+ },
416
+ "/applications/{application.id}/guilds/{guild.id}/commands/permissions": {
417
+ GET: "getGuildApplicationCommandPermissions"
418
+ },
419
+ "/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions": {
420
+ GET: "getApplicationCommandPermissions",
421
+ PUT: "editApplicationCommandPermissions"
422
+ }
423
+ });
424
+
425
+ // src/types/component.ts
426
+ var ComponentType = /* @__PURE__ */ ((ComponentType3) => {
427
+ ComponentType3[ComponentType3["ACTION_ROW"] = 1] = "ACTION_ROW";
428
+ ComponentType3[ComponentType3["BUTTON"] = 2] = "BUTTON";
429
+ ComponentType3[ComponentType3["SELECT_MENU"] = 3] = "SELECT_MENU";
430
+ ComponentType3[ComponentType3["TEXT_INPUT"] = 4] = "TEXT_INPUT";
431
+ ComponentType3[ComponentType3["USER_SELECT"] = 5] = "USER_SELECT";
432
+ ComponentType3[ComponentType3["ROLE_SELECT"] = 6] = "ROLE_SELECT";
433
+ ComponentType3[ComponentType3["MENTIONABLE_SELECT"] = 7] = "MENTIONABLE_SELECT";
434
+ ComponentType3[ComponentType3["CHANNEL_SELECT"] = 8] = "CHANNEL_SELECT";
435
+ return ComponentType3;
436
+ })(ComponentType || {});
437
+ var ButtonStyles = /* @__PURE__ */ ((ButtonStyles2) => {
438
+ ButtonStyles2[ButtonStyles2["PRIMARY"] = 1] = "PRIMARY";
439
+ ButtonStyles2[ButtonStyles2["SECONDARY"] = 2] = "SECONDARY";
440
+ ButtonStyles2[ButtonStyles2["SUCCESS"] = 3] = "SUCCESS";
441
+ ButtonStyles2[ButtonStyles2["DANGER"] = 4] = "DANGER";
442
+ ButtonStyles2[ButtonStyles2["LINK"] = 5] = "LINK";
443
+ return ButtonStyles2;
444
+ })(ButtonStyles || {});
445
+ var TextInputStyles = /* @__PURE__ */ ((TextInputStyles2) => {
446
+ TextInputStyles2[TextInputStyles2["SHORT"] = 1] = "SHORT";
447
+ TextInputStyles2[TextInputStyles2["PARAGRAPH"] = 2] = "PARAGRAPH";
448
+ return TextInputStyles2;
449
+ })(TextInputStyles || {});
450
+
451
+ // src/types/device.ts
452
+ var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
453
+ DeviceType2["AUDIO_INPUT"] = "audioinput";
454
+ DeviceType2["AUDIO_OUTPUT"] = "audiooutput";
455
+ DeviceType2["VIDEO_INPUT"] = "videoinput";
456
+ return DeviceType2;
457
+ })(DeviceType || {});
458
+
459
+ // src/types/emoji.ts
460
+ Internal.define({
461
+ "/guilds/{guild.id}/emojis": {
462
+ GET: "listGuildEmojis",
463
+ POST: "createGuildEmoji"
464
+ },
465
+ "/guilds/{guild.id}/emojis/{emoji.id}": {
466
+ GET: "getGuildEmoji",
467
+ PATCH: "modifyGuildEmoji",
468
+ DELETE: "deleteGuildEmoji"
469
+ }
470
+ });
471
+
472
+ // src/types/gateway.ts
473
+ var Gateway;
474
+ ((Gateway3) => {
475
+ let Opcode;
476
+ ((Opcode2) => {
477
+ Opcode2[Opcode2["DISPATCH"] = 0] = "DISPATCH";
478
+ Opcode2[Opcode2["HEARTBEAT"] = 1] = "HEARTBEAT";
479
+ Opcode2[Opcode2["IDENTIFY"] = 2] = "IDENTIFY";
480
+ Opcode2[Opcode2["PRESENCE_UPDATE"] = 3] = "PRESENCE_UPDATE";
481
+ Opcode2[Opcode2["VOICE_STATE_UPDATE"] = 4] = "VOICE_STATE_UPDATE";
482
+ Opcode2[Opcode2["RESUME"] = 6] = "RESUME";
483
+ Opcode2[Opcode2["RECONNECT"] = 7] = "RECONNECT";
484
+ Opcode2[Opcode2["REQUEST_GUILD_MEMBERS"] = 8] = "REQUEST_GUILD_MEMBERS";
485
+ Opcode2[Opcode2["INVALID_SESSION"] = 9] = "INVALID_SESSION";
486
+ Opcode2[Opcode2["HELLO"] = 10] = "HELLO";
487
+ Opcode2[Opcode2["HEARTBEAT_ACK"] = 11] = "HEARTBEAT_ACK";
488
+ })(Opcode = Gateway3.Opcode || (Gateway3.Opcode = {}));
489
+ let Intent;
490
+ ((Intent2) => {
491
+ Intent2[Intent2["GUILDS"] = 1] = "GUILDS";
492
+ Intent2[Intent2["GUILD_MEMBERS"] = 2] = "GUILD_MEMBERS";
493
+ Intent2[Intent2["GUILD_BANS"] = 4] = "GUILD_BANS";
494
+ Intent2[Intent2["GUILD_EMOJIS_AND_STICKERS"] = 8] = "GUILD_EMOJIS_AND_STICKERS";
495
+ Intent2[Intent2["GUILD_INTEGRATIONS"] = 16] = "GUILD_INTEGRATIONS";
496
+ Intent2[Intent2["GUILD_WEBHOOKS"] = 32] = "GUILD_WEBHOOKS";
497
+ Intent2[Intent2["GUILD_INVITES"] = 64] = "GUILD_INVITES";
498
+ Intent2[Intent2["GUILD_VOICE_STATES"] = 128] = "GUILD_VOICE_STATES";
499
+ Intent2[Intent2["GUILD_PRESENCES"] = 256] = "GUILD_PRESENCES";
500
+ Intent2[Intent2["GUILD_MESSAGES"] = 512] = "GUILD_MESSAGES";
501
+ Intent2[Intent2["GUILD_MESSAGE_REACTIONS"] = 1024] = "GUILD_MESSAGE_REACTIONS";
502
+ Intent2[Intent2["GUILD_MESSAGE_TYPING"] = 2048] = "GUILD_MESSAGE_TYPING";
503
+ Intent2[Intent2["DIRECT_MESSAGES"] = 4096] = "DIRECT_MESSAGES";
504
+ Intent2[Intent2["DIRECT_MESSAGE_REACTIONS"] = 8192] = "DIRECT_MESSAGE_REACTIONS";
505
+ Intent2[Intent2["DIRECT_MESSAGE_TYPING"] = 16384] = "DIRECT_MESSAGE_TYPING";
506
+ Intent2[Intent2["MESSAGE_CONTENT"] = 32768] = "MESSAGE_CONTENT";
507
+ Intent2[Intent2["GUILD_SCHEDULED_EVENTS"] = 65536] = "GUILD_SCHEDULED_EVENTS";
508
+ Intent2[Intent2["AUTO_MODERATION_CONFIGURATION"] = 1048576] = "AUTO_MODERATION_CONFIGURATION";
509
+ Intent2[Intent2["AUTO_MODERATION_EXECUTION"] = 2097152] = "AUTO_MODERATION_EXECUTION";
510
+ })(Intent = Gateway3.Intent || (Gateway3.Intent = {}));
511
+ })(Gateway || (Gateway = {}));
512
+ Internal.define({
513
+ "/gateway": {
514
+ GET: "getGateway"
515
+ },
516
+ "/gateway/bot": {
517
+ GET: "getGatewayBot"
518
+ }
519
+ });
520
+
521
+ // src/types/guild-member.ts
522
+ Internal.define({
523
+ "/guilds/{guild.id}/members/{user.id}": {
524
+ GET: "getGuildMember",
525
+ PUT: "addGuildMember",
526
+ PATCH: "modifyGuildMember",
527
+ DELETE: "removeGuildMember"
528
+ },
529
+ "/guilds/{guild.id}/members": {
530
+ GET: "listGuildMembers"
531
+ },
532
+ "/guilds/{guild.id}/members/search": {
533
+ GET: "searchGuildMembers"
534
+ },
535
+ "/guilds/{guild.id}/members/@me": {
536
+ PATCH: "modifyCurrentMember"
537
+ },
538
+ "/guilds/{guild.id}/members/{user.id}/roles/{role.id}": {
539
+ PUT: "addGuildMemberRole",
540
+ DELETE: "removeGuildMemberRole"
541
+ },
542
+ "/guilds/{guild.id}/prune": {
543
+ GET: "getGuildPruneCount",
544
+ POST: "beginGuildPrune"
545
+ }
546
+ });
547
+
548
+ // src/types/guild-template.ts
549
+ Internal.define({
550
+ "/guilds/templates/{template.code}": {
551
+ GET: "getGuildTemplate",
552
+ POST: "createGuildfromGuildTemplate"
553
+ },
554
+ "/guilds/{guild.id}/templates": {
555
+ GET: "getGuildTemplates",
556
+ POST: "createGuildTemplate"
557
+ },
558
+ "/guilds/{guild.id}/templates/{template.code}": {
559
+ PUT: "syncGuildTemplate",
560
+ PATCH: "modifyGuildTemplate",
561
+ DELETE: "deleteGuildTemplate"
562
+ }
563
+ });
564
+
565
+ // src/types/guild.ts
566
+ var Guild3;
567
+ ((Guild6) => {
568
+ let Params;
569
+ ((Params2) => {
570
+ let WidgetStyleOptions;
571
+ ((WidgetStyleOptions2) => {
572
+ WidgetStyleOptions2["shield"] = "shield";
573
+ WidgetStyleOptions2["banner1"] = "banner1";
574
+ WidgetStyleOptions2["banner2"] = "banner2";
575
+ WidgetStyleOptions2["banner3"] = "banner3";
576
+ WidgetStyleOptions2["banner4"] = "banner4";
577
+ })(WidgetStyleOptions = Params2.WidgetStyleOptions || (Params2.WidgetStyleOptions = {}));
578
+ })(Params = Guild6.Params || (Guild6.Params = {}));
579
+ })(Guild3 || (Guild3 = {}));
580
+ var SystemChannelFlag = /* @__PURE__ */ ((SystemChannelFlag2) => {
581
+ SystemChannelFlag2[SystemChannelFlag2["SUPPRESS_JOIN_NOTIFICATIONS"] = 1] = "SUPPRESS_JOIN_NOTIFICATIONS";
582
+ SystemChannelFlag2[SystemChannelFlag2["SUPPRESS_PREMIUM_SUBSCRIPTIONS"] = 2] = "SUPPRESS_PREMIUM_SUBSCRIPTIONS";
583
+ SystemChannelFlag2[SystemChannelFlag2["SUPPRESS_GUILD_REMINDER_NOTIFICATIONS"] = 4] = "SUPPRESS_GUILD_REMINDER_NOTIFICATIONS";
584
+ SystemChannelFlag2[SystemChannelFlag2["SUPPRESS_JOIN_NOTIFICATION_REPLIES"] = 8] = "SUPPRESS_JOIN_NOTIFICATION_REPLIES";
585
+ SystemChannelFlag2[SystemChannelFlag2["SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATIONS"] = 16] = "SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATIONS";
586
+ SystemChannelFlag2[SystemChannelFlag2["SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATION_REPLIES"] = 32] = "SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATION_REPLIES";
587
+ return SystemChannelFlag2;
588
+ })(SystemChannelFlag || {});
589
+ var GuildFeature = /* @__PURE__ */ ((GuildFeature2) => {
590
+ GuildFeature2["ANIMATED_ICON"] = "ANIMATED_ICON";
591
+ GuildFeature2["BANNER"] = "BANNER";
592
+ GuildFeature2["COMMERCE"] = "COMMERCE";
593
+ GuildFeature2["COMMUNITY"] = "COMMUNITY";
594
+ GuildFeature2["DISCOVERABLE"] = "DISCOVERABLE";
595
+ GuildFeature2["FEATURABLE"] = "FEATURABLE";
596
+ GuildFeature2["INVITE_SPLASH"] = "INVITE_SPLASH";
597
+ GuildFeature2["MEMBER_VERIFICATION_GATE_ENABLED"] = "MEMBER_VERIFICATION_GATE_ENABLED";
598
+ GuildFeature2["MONETIZATION_ENABLED"] = "MONETIZATION_ENABLED";
599
+ GuildFeature2["MORE_STICKERS"] = "MORE_STICKERS";
600
+ GuildFeature2["NEWS"] = "NEWS";
601
+ GuildFeature2["PARTNERED"] = "PARTNERED";
602
+ GuildFeature2["PREVIEW_ENABLED"] = "PREVIEW_ENABLED";
603
+ GuildFeature2["PRIVATE_THREADS"] = "PRIVATE_THREADS";
604
+ GuildFeature2["ROLE_ICONS"] = "ROLE_ICONS";
605
+ GuildFeature2["SEVEN_DAY_THREAD_ARCHIVE"] = "SEVEN_DAY_THREAD_ARCHIVE";
606
+ GuildFeature2["THREE_DAY_THREAD_ARCHIVE"] = "THREE_DAY_THREAD_ARCHIVE";
607
+ GuildFeature2["TICKETED_EVENTS_ENABLED"] = "TICKETED_EVENTS_ENABLED";
608
+ GuildFeature2["VANITY_URL"] = "VANITY_URL";
609
+ GuildFeature2["VERIFIED"] = "VERIFIED";
610
+ GuildFeature2["VIP_REGIONS"] = "VIP_REGIONS";
611
+ GuildFeature2["WELCOME_SCREEN_ENABLED"] = "WELCOME_SCREEN_ENABLED";
612
+ return GuildFeature2;
613
+ })(GuildFeature || {});
614
+ Internal.define({
615
+ "/users/@me/guilds": {
616
+ GET: "getCurrentUserGuilds"
617
+ },
618
+ "/users/@me/guilds/{guild.id}/member": {
619
+ GET: "getCurrentUserGuildMember"
620
+ },
621
+ "/users/@me/guilds/{guild.id}": {
622
+ DELETE: "leaveGuild"
623
+ }
624
+ });
625
+ Internal.define({
626
+ "/guilds": {
627
+ POST: "createGuild"
628
+ },
629
+ "/guilds/{guild.id}": {
630
+ GET: "getGuild",
631
+ PATCH: "modifyGuild",
632
+ DELETE: "deleteGuild"
633
+ },
634
+ "/guilds/{guild.id}/preview": {
635
+ GET: "getGuildPreview"
636
+ },
637
+ "/guilds/{guild.id}/widget": {
638
+ GET: "getGuildWidgetSettings",
639
+ PATCH: "modifyGuildWidget"
640
+ },
641
+ "/guilds/{guild.id}/widget.json": {
642
+ GET: "getGuildWidget"
643
+ },
644
+ "/guilds/{guild.id}/widget.png": {
645
+ GET: "getGuildWidgetImage"
646
+ },
647
+ "/guilds/{guild.id}/welcome-screen": {
648
+ GET: "getGuildWelcomeScreen",
649
+ PATCH: "modifyGuildWelcomeScreen"
650
+ }
651
+ });
652
+
653
+ // src/types/integration.ts
654
+ var IntegrationExpireBehavior = /* @__PURE__ */ ((IntegrationExpireBehavior2) => {
655
+ IntegrationExpireBehavior2[IntegrationExpireBehavior2["REMOVE_ROLE"] = 0] = "REMOVE_ROLE";
656
+ IntegrationExpireBehavior2[IntegrationExpireBehavior2["KICK"] = 1] = "KICK";
657
+ return IntegrationExpireBehavior2;
658
+ })(IntegrationExpireBehavior || {});
659
+ Internal.define({
660
+ "/guilds/{guild.id}/integrations": {
661
+ GET: "getGuildIntegrations"
662
+ },
663
+ "/guilds/{guild.id}/integrations/{integration.id}": {
664
+ DELETE: "deleteGuildIntegration"
665
+ }
666
+ });
667
+
668
+ // src/types/interaction.ts
669
+ var Interaction;
670
+ ((Interaction2) => {
671
+ let Type;
672
+ ((Type2) => {
673
+ Type2[Type2["PING"] = 1] = "PING";
674
+ Type2[Type2["APPLICATION_COMMAND"] = 2] = "APPLICATION_COMMAND";
675
+ Type2[Type2["MESSAGE_COMPONENT"] = 3] = "MESSAGE_COMPONENT";
676
+ Type2[Type2["APPLICATION_COMMAND_AUTOCOMPLETE"] = 4] = "APPLICATION_COMMAND_AUTOCOMPLETE";
677
+ Type2[Type2["MODAL_SUBMIT"] = 5] = "MODAL_SUBMIT";
678
+ })(Type = Interaction2.Type || (Interaction2.Type = {}));
679
+ })(Interaction || (Interaction = {}));
680
+ ((Interaction2) => {
681
+ let CallbackType;
682
+ ((CallbackType2) => {
683
+ CallbackType2[CallbackType2["PONG"] = 1] = "PONG";
684
+ CallbackType2[CallbackType2["CHANNEL_MESSAGE_WITH_SOURCE"] = 4] = "CHANNEL_MESSAGE_WITH_SOURCE";
685
+ CallbackType2[CallbackType2["DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE"] = 5] = "DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE";
686
+ CallbackType2[CallbackType2["DEFERRED_UPDATE_MESSAGE"] = 6] = "DEFERRED_UPDATE_MESSAGE";
687
+ CallbackType2[CallbackType2["UPDATE_MESSAGE"] = 7] = "UPDATE_MESSAGE";
688
+ CallbackType2[CallbackType2["APPLICATION_COMMAND_AUTOCOMPLETE_RESULT"] = 8] = "APPLICATION_COMMAND_AUTOCOMPLETE_RESULT";
689
+ CallbackType2[CallbackType2["MODAL"] = 9] = "MODAL";
690
+ })(CallbackType = Interaction2.CallbackType || (Interaction2.CallbackType = {}));
691
+ })(Interaction || (Interaction = {}));
692
+ Internal.define({
693
+ "/interactions/{interaction.id}/{interaction.token}/callback": {
694
+ POST: "createInteractionResponse"
695
+ },
696
+ "/webhooks/{application.id}/{interaction.token}/messages/@original": {
697
+ GET: "getOriginalInteractionResponse",
698
+ PATCH: "editOriginalInteractionResponse",
699
+ DELETE: "deleteOriginalInteractionResponse"
700
+ },
701
+ "/webhooks/{application.id}/{interaction.token}": {
702
+ POST: "createFollowupMessage"
703
+ },
704
+ "/webhooks/{application.id}/{interaction.token}/messages/{message.id}": {
705
+ GET: "getFollowupMessage",
706
+ PATCH: "editFollowupMessage",
707
+ DELETE: "deleteFollowupMessage"
708
+ }
709
+ });
710
+
711
+ // src/types/invite.ts
712
+ var Invite;
713
+ ((Invite2) => {
714
+ let TargetType;
715
+ ((TargetType2) => {
716
+ TargetType2[TargetType2["STREAM"] = 1] = "STREAM";
717
+ TargetType2[TargetType2["EMBEDDED_APPLICATION"] = 2] = "EMBEDDED_APPLICATION";
718
+ })(TargetType = Invite2.TargetType || (Invite2.TargetType = {}));
719
+ })(Invite || (Invite = {}));
720
+ Internal.define({
721
+ "/invites/{invite.code}": {
722
+ GET: "getInvite",
723
+ DELETE: "deleteInvite"
724
+ },
725
+ "/guilds/{guild.id}/invites": {
726
+ GET: "getGuildInvites"
727
+ },
728
+ "/guilds/{guild.id}/vanity-url": {
729
+ GET: "getGuildVanityURL"
730
+ },
731
+ "/channels/{channel.id}/invites": {
732
+ GET: "getChannelInvites",
733
+ POST: "createChannelInvite"
734
+ }
735
+ });
736
+
737
+ // src/types/message.ts
738
+ var Message2;
739
+ ((Message4) => {
740
+ let Type;
741
+ ((Type2) => {
742
+ Type2[Type2["DEFAULT"] = 0] = "DEFAULT";
743
+ Type2[Type2["RECIPIENT_ADD"] = 1] = "RECIPIENT_ADD";
744
+ Type2[Type2["RECIPIENT_REMOVE"] = 2] = "RECIPIENT_REMOVE";
745
+ Type2[Type2["CALL"] = 3] = "CALL";
746
+ Type2[Type2["CHANNEL_NAME_CHANGE"] = 4] = "CHANNEL_NAME_CHANGE";
747
+ Type2[Type2["CHANNEL_ICON_CHANGE"] = 5] = "CHANNEL_ICON_CHANGE";
748
+ Type2[Type2["CHANNEL_PINNED_MESSAGE"] = 6] = "CHANNEL_PINNED_MESSAGE";
749
+ Type2[Type2["GUILD_MEMBER_JOIN"] = 7] = "GUILD_MEMBER_JOIN";
750
+ Type2[Type2["USER_PREMIUM_GUILD_SUBSCRIPTION"] = 8] = "USER_PREMIUM_GUILD_SUBSCRIPTION";
751
+ Type2[Type2["USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1"] = 9] = "USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1";
752
+ Type2[Type2["USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2"] = 10] = "USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2";
753
+ Type2[Type2["USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3"] = 11] = "USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3";
754
+ Type2[Type2["CHANNEL_FOLLOW_ADD"] = 12] = "CHANNEL_FOLLOW_ADD";
755
+ Type2[Type2["GUILD_DISCOVERY_DISQUALIFIED"] = 14] = "GUILD_DISCOVERY_DISQUALIFIED";
756
+ Type2[Type2["GUILD_DISCOVERY_REQUALIFIED"] = 15] = "GUILD_DISCOVERY_REQUALIFIED";
757
+ Type2[Type2["GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING"] = 16] = "GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING";
758
+ Type2[Type2["GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING"] = 17] = "GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING";
759
+ Type2[Type2["THREAD_CREATED"] = 18] = "THREAD_CREATED";
760
+ Type2[Type2["REPLY"] = 19] = "REPLY";
761
+ Type2[Type2["CHAT_INPUT_COMMAND"] = 20] = "CHAT_INPUT_COMMAND";
762
+ Type2[Type2["THREAD_STARTER_MESSAGE"] = 21] = "THREAD_STARTER_MESSAGE";
763
+ Type2[Type2["GUILD_INVITE_REMINDER"] = 22] = "GUILD_INVITE_REMINDER";
764
+ Type2[Type2["CONTEXT_MENU_COMMAND"] = 23] = "CONTEXT_MENU_COMMAND";
765
+ Type2[Type2["AUTO_MODERATION_ACTION"] = 24] = "AUTO_MODERATION_ACTION";
766
+ Type2[Type2["ROLE_SUBSCRIPTION_PURCHASE"] = 25] = "ROLE_SUBSCRIPTION_PURCHASE";
767
+ Type2[Type2["INTERACTION_PREMIUM_UPSELL"] = 26] = "INTERACTION_PREMIUM_UPSELL";
768
+ Type2[Type2["GUILD_APPLICATION_PREMIUM_SUBSCRIPTION"] = 32] = "GUILD_APPLICATION_PREMIUM_SUBSCRIPTION";
769
+ })(Type = Message4.Type || (Message4.Type = {}));
770
+ let ActivityType2;
771
+ ((ActivityType3) => {
772
+ ActivityType3[ActivityType3["JOIN"] = 1] = "JOIN";
773
+ ActivityType3[ActivityType3["SPECTATE"] = 2] = "SPECTATE";
774
+ ActivityType3[ActivityType3["LISTEN"] = 3] = "LISTEN";
775
+ ActivityType3[ActivityType3["JOIN_REQUEST"] = 5] = "JOIN_REQUEST";
776
+ })(ActivityType2 = Message4.ActivityType || (Message4.ActivityType = {}));
777
+ let Flag;
778
+ ((Flag2) => {
779
+ Flag2[Flag2["CROSSPOSTED"] = 1] = "CROSSPOSTED";
780
+ Flag2[Flag2["IS_CROSSPOST"] = 2] = "IS_CROSSPOST";
781
+ Flag2[Flag2["SUPPRESS_EMBEDS"] = 4] = "SUPPRESS_EMBEDS";
782
+ Flag2[Flag2["SOURCE_MESSAGE_DELETED"] = 8] = "SOURCE_MESSAGE_DELETED";
783
+ Flag2[Flag2["URGENT"] = 16] = "URGENT";
784
+ Flag2[Flag2["HAS_THREAD"] = 32] = "HAS_THREAD";
785
+ Flag2[Flag2["EPHEMERAL"] = 64] = "EPHEMERAL";
786
+ Flag2[Flag2["LOADING"] = 128] = "LOADING";
787
+ Flag2[Flag2["FAILED_TO_MENTION_SOME_ROLES_IN_THREAD"] = 256] = "FAILED_TO_MENTION_SOME_ROLES_IN_THREAD";
788
+ Flag2[Flag2["SUPPRESS_NOTIFICATIONS"] = 4096] = "SUPPRESS_NOTIFICATIONS";
789
+ Flag2[Flag2["IS_VOICE_MESSAGE"] = 8192] = "IS_VOICE_MESSAGE";
790
+ })(Flag = Message4.Flag || (Message4.Flag = {}));
791
+ })(Message2 || (Message2 = {}));
792
+ Internal.define({
793
+ "/channels/{channel.id}/messages": {
794
+ GET: "getChannelMessages",
795
+ POST: "createMessage"
796
+ },
797
+ "/channels/{channel.id}/messages/{message.id}": {
798
+ GET: "getChannelMessage",
799
+ PATCH: "editMessage",
800
+ DELETE: "deleteMessage"
801
+ },
802
+ "/channels/{channel.id}/messages/{message.id}/crosspost": {
803
+ POST: "crosspostMessage"
804
+ },
805
+ "/channels/{channel.id}/messages/bulk-delete": {
806
+ POST: "bulkDeleteMessages"
807
+ },
808
+ "/channels/{channel.id}/pins": {
809
+ GET: "getPinnedMessages"
810
+ },
811
+ "/channels/{channel.id}/pins/{message.id}": {
812
+ PUT: "pinMessage",
813
+ DELETE: "unpinMessage"
814
+ }
815
+ });
816
+
817
+ // src/types/presence.ts
818
+ var StatusType2 = /* @__PURE__ */ ((StatusType3) => {
819
+ StatusType3["ONLINE"] = "ONLINE";
820
+ StatusType3["DND"] = "DND";
821
+ StatusType3["IDLE"] = "IDLE";
822
+ StatusType3["OFFLINE"] = "OFFLINE";
823
+ return StatusType3;
824
+ })(StatusType2 || {});
825
+ var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
826
+ ActivityType2[ActivityType2["GAME"] = 0] = "GAME";
827
+ ActivityType2[ActivityType2["STREAMING"] = 1] = "STREAMING";
828
+ ActivityType2[ActivityType2["LISTENING"] = 2] = "LISTENING";
829
+ ActivityType2[ActivityType2["WATCHING"] = 3] = "WATCHING";
830
+ ActivityType2[ActivityType2["CUSTOM"] = 4] = "CUSTOM";
831
+ ActivityType2[ActivityType2["COMPETING"] = 5] = "COMPETING";
832
+ return ActivityType2;
833
+ })(ActivityType || {});
834
+ var ActivityFlag = /* @__PURE__ */ ((ActivityFlag2) => {
835
+ ActivityFlag2[ActivityFlag2["INSTANCE"] = 1] = "INSTANCE";
836
+ ActivityFlag2[ActivityFlag2["JOIN"] = 2] = "JOIN";
837
+ ActivityFlag2[ActivityFlag2["SPECTATE"] = 4] = "SPECTATE";
838
+ ActivityFlag2[ActivityFlag2["JOIN_REQUEST"] = 8] = "JOIN_REQUEST";
839
+ ActivityFlag2[ActivityFlag2["SYNC"] = 16] = "SYNC";
840
+ ActivityFlag2[ActivityFlag2["PLAY"] = 32] = "PLAY";
841
+ ActivityFlag2[ActivityFlag2["PARTY_PRIVACY_FRIENDS"] = 64] = "PARTY_PRIVACY_FRIENDS";
842
+ ActivityFlag2[ActivityFlag2["PARTY_PRIVACY_VOICE_CHANNEL"] = 128] = "PARTY_PRIVACY_VOICE_CHANNEL";
843
+ ActivityFlag2[ActivityFlag2["EMBEDDED"] = 256] = "EMBEDDED";
844
+ return ActivityFlag2;
845
+ })(ActivityFlag || {});
846
+
847
+ // src/types/reaction.ts
848
+ Internal.define({
849
+ "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me": {
850
+ PUT: "createReaction",
851
+ DELETE: "deleteOwnReaction"
852
+ },
853
+ "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/{user.id}": {
854
+ DELETE: "deleteUserReaction"
855
+ },
856
+ "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}": {
857
+ GET: "getReactions",
858
+ DELETE: "deleteAllReactionsforEmoji"
859
+ },
860
+ "/channels/{channel.id}/messages/{message.id}/reactions": {
861
+ DELETE: "deleteAllReactions"
862
+ }
863
+ });
864
+
865
+ // src/types/role.ts
866
+ var Permission = /* @__PURE__ */ ((Permission2) => {
867
+ Permission2[Permission2["CREATE_INSTANT_INVITE"] = 1] = "CREATE_INSTANT_INVITE";
868
+ Permission2[Permission2["KICK_MEMBERS"] = 2] = "KICK_MEMBERS";
869
+ Permission2[Permission2["BAN_MEMBERS"] = 4] = "BAN_MEMBERS";
870
+ Permission2[Permission2["ADMINISTRATOR"] = 8] = "ADMINISTRATOR";
871
+ Permission2[Permission2["MANAGE_CHANNELS"] = 16] = "MANAGE_CHANNELS";
872
+ Permission2[Permission2["MANAGE_GUILD"] = 32] = "MANAGE_GUILD";
873
+ Permission2[Permission2["ADD_REACTIONS"] = 64] = "ADD_REACTIONS";
874
+ Permission2[Permission2["VIEW_AUDIT_LOG"] = 128] = "VIEW_AUDIT_LOG";
875
+ Permission2[Permission2["PRIORITY_SPEAKER"] = 256] = "PRIORITY_SPEAKER";
876
+ Permission2[Permission2["STREAM"] = 512] = "STREAM";
877
+ Permission2[Permission2["VIEW_CHANNEL"] = 1024] = "VIEW_CHANNEL";
878
+ Permission2[Permission2["SEND_MESSAGES"] = 2048] = "SEND_MESSAGES";
879
+ Permission2[Permission2["SEND_TTS_MESSAGES"] = 4096] = "SEND_TTS_MESSAGES";
880
+ Permission2[Permission2["MANAGE_MESSAGES"] = 8192] = "MANAGE_MESSAGES";
881
+ Permission2[Permission2["EMBED_LINKS"] = 16384] = "EMBED_LINKS";
882
+ Permission2[Permission2["ATTACH_FILES"] = 32768] = "ATTACH_FILES";
883
+ Permission2[Permission2["READ_MESSAGE_HISTORY"] = 65536] = "READ_MESSAGE_HISTORY";
884
+ Permission2[Permission2["MENTION_EVERYONE"] = 131072] = "MENTION_EVERYONE";
885
+ Permission2[Permission2["USE_EXTERNAL_EMOJIS"] = 262144] = "USE_EXTERNAL_EMOJIS";
886
+ Permission2[Permission2["VIEW_GUILD_INSIGHTS"] = 524288] = "VIEW_GUILD_INSIGHTS";
887
+ Permission2[Permission2["CONNECT"] = 1048576] = "CONNECT";
888
+ Permission2[Permission2["SPEAK"] = 2097152] = "SPEAK";
889
+ Permission2[Permission2["MUTE_MEMBERS"] = 4194304] = "MUTE_MEMBERS";
890
+ Permission2[Permission2["DEAFEN_MEMBERS"] = 8388608] = "DEAFEN_MEMBERS";
891
+ Permission2[Permission2["MOVE_MEMBERS"] = 16777216] = "MOVE_MEMBERS";
892
+ Permission2[Permission2["USE_VAD"] = 33554432] = "USE_VAD";
893
+ Permission2[Permission2["CHANGE_NICKNAME"] = 67108864] = "CHANGE_NICKNAME";
894
+ Permission2[Permission2["MANAGE_NICKNAMES"] = 134217728] = "MANAGE_NICKNAMES";
895
+ Permission2[Permission2["MANAGE_ROLES"] = 268435456] = "MANAGE_ROLES";
896
+ Permission2[Permission2["MANAGE_WEBHOOKS"] = 536870912] = "MANAGE_WEBHOOKS";
897
+ Permission2[Permission2["MANAGE_EMOJIS_AND_STICKERS"] = 1073741824] = "MANAGE_EMOJIS_AND_STICKERS";
898
+ Permission2[Permission2["USE_APPLICATION_COMMANDS"] = -2147483648] = "USE_APPLICATION_COMMANDS";
899
+ Permission2[Permission2["REQUEST_TO_SPEAK"] = 1] = "REQUEST_TO_SPEAK";
900
+ Permission2[Permission2["MANAGE_THREADS"] = 4] = "MANAGE_THREADS";
901
+ Permission2[Permission2["CREATE_PUBLIC_THREADS"] = 8] = "CREATE_PUBLIC_THREADS";
902
+ Permission2[Permission2["CREATE_PRIVATE_THREADS"] = 16] = "CREATE_PRIVATE_THREADS";
903
+ Permission2[Permission2["USE_EXTERNAL_STICKERS"] = 32] = "USE_EXTERNAL_STICKERS";
904
+ Permission2[Permission2["SEND_MESSAGES_IN_THREADS"] = 64] = "SEND_MESSAGES_IN_THREADS";
905
+ Permission2[Permission2["START_EMBEDDED_ACTIVITIES"] = 128] = "START_EMBEDDED_ACTIVITIES";
906
+ Permission2[Permission2["MODERATE_MEMBERS"] = 256] = "MODERATE_MEMBERS";
907
+ return Permission2;
908
+ })(Permission || {});
909
+ Internal.define({
910
+ "/guilds/{guild.id}/roles": {
911
+ GET: "getGuildRoles",
912
+ POST: "createGuildRole",
913
+ PATCH: "modifyGuildRolePositions"
914
+ },
915
+ "/guilds/{guild.id}/roles/{role.id}": {
916
+ PATCH: "modifyGuildRole",
917
+ DELETE: "deleteGuildRole"
918
+ }
919
+ });
920
+
921
+ // src/types/scheduled-event.ts
922
+ var GuildScheduledEvent3;
923
+ ((GuildScheduledEvent4) => {
924
+ let PrivacyLevel;
925
+ ((PrivacyLevel2) => {
926
+ PrivacyLevel2[PrivacyLevel2["GUILD_ONLY"] = 2] = "GUILD_ONLY";
927
+ })(PrivacyLevel = GuildScheduledEvent4.PrivacyLevel || (GuildScheduledEvent4.PrivacyLevel = {}));
928
+ let EntityType;
929
+ ((EntityType2) => {
930
+ EntityType2[EntityType2["STAGE_INSTANCE"] = 1] = "STAGE_INSTANCE";
931
+ EntityType2[EntityType2["VOICE"] = 2] = "VOICE";
932
+ EntityType2[EntityType2["EXTERNAL"] = 3] = "EXTERNAL";
933
+ })(EntityType = GuildScheduledEvent4.EntityType || (GuildScheduledEvent4.EntityType = {}));
934
+ let Status;
935
+ ((Status2) => {
936
+ Status2[Status2["SCHEDULED"] = 1] = "SCHEDULED";
937
+ Status2[Status2["ACTIVE"] = 2] = "ACTIVE";
938
+ Status2[Status2["COMPLETED"] = 3] = "COMPLETED";
939
+ Status2[Status2["CANCELLED"] = 4] = "CANCELLED";
940
+ })(Status = GuildScheduledEvent4.Status || (GuildScheduledEvent4.Status = {}));
941
+ })(GuildScheduledEvent3 || (GuildScheduledEvent3 = {}));
942
+ Internal.define({
943
+ "/guilds/{guild.id}/scheduled-events": {
944
+ GET: "listScheduledEventsforGuild",
945
+ POST: "createGuildScheduledEvent"
946
+ },
947
+ "/guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id}": {
948
+ GET: "getGuildScheduledEvent",
949
+ PATCH: "modifyGuildScheduledEvent",
950
+ DELETE: "deleteGuildScheduledEvent"
951
+ },
952
+ "/guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id}/users": {
953
+ GET: "getGuildScheduledEventUsers"
954
+ }
955
+ });
956
+
957
+ // src/types/stage-instance.ts
958
+ Internal.define({
959
+ "/stage-instances": {
960
+ POST: "createStageInstance"
961
+ },
962
+ "/stage-instances/{channel.id}": {
963
+ GET: "getStageInstance",
964
+ PATCH: "modifyStageInstance",
965
+ DELETE: "deleteStageInstance"
966
+ }
967
+ });
968
+
969
+ // src/types/sticker.ts
970
+ var Sticker3;
971
+ ((Sticker4) => {
972
+ let Type;
973
+ ((Type2) => {
974
+ Type2[Type2["STANDARD"] = 1] = "STANDARD";
975
+ Type2[Type2["GUILD"] = 2] = "GUILD";
976
+ })(Type = Sticker4.Type || (Sticker4.Type = {}));
977
+ let FormatType;
978
+ ((FormatType2) => {
979
+ FormatType2[FormatType2["PNG"] = 1] = "PNG";
980
+ FormatType2[FormatType2["APNG"] = 2] = "APNG";
981
+ FormatType2[FormatType2["LOTTIE"] = 3] = "LOTTIE";
982
+ FormatType2[FormatType2["GIF"] = 4] = "GIF";
983
+ })(FormatType = Sticker4.FormatType || (Sticker4.FormatType = {}));
984
+ })(Sticker3 || (Sticker3 = {}));
985
+ Internal.define({
986
+ "/stickers/{sticker.id}": {
987
+ GET: "getSticker"
988
+ },
989
+ "/sticker-packs": {
990
+ GET: "listNitroStickerPacks"
991
+ },
992
+ "/guilds/{guild.id}/stickers": {
993
+ GET: "listGuildStickers",
994
+ POST: "createGuildSticker"
995
+ },
996
+ "/guilds/{guild.id}/stickers/{sticker.id}": {
997
+ GET: "getGuildSticker",
998
+ PATCH: "modifyGuildSticker",
999
+ DELETE: "deleteGuildSticker"
1000
+ }
1001
+ });
1002
+
1003
+ // src/types/team.ts
1004
+ var MembershipState = /* @__PURE__ */ ((MembershipState2) => {
1005
+ MembershipState2[MembershipState2["INVITED"] = 1] = "INVITED";
1006
+ MembershipState2[MembershipState2["ACCEPTED"] = 2] = "ACCEPTED";
1007
+ return MembershipState2;
1008
+ })(MembershipState || {});
1009
+
1010
+ // src/types/thread.ts
1011
+ Internal.define({
1012
+ "/channels/{channel.id}/messages/{message.id}/threads": {
1013
+ POST: "startThreadFromMessage"
1014
+ },
1015
+ "/channels/{channel.id}/threads": {
1016
+ POST: ["startThreadWithoutMessage", "startThreadInForumChannel"]
1017
+ },
1018
+ "/channels/{channel.id}/thread-members/@me": {
1019
+ PUT: "joinThread",
1020
+ DELETE: "leaveThread"
1021
+ },
1022
+ "/channels/{channel.id}/thread-members/{user.id}": {
1023
+ PUT: "addThreadMember",
1024
+ DELETE: "removeThreadMember",
1025
+ GET: "getThreadMember"
1026
+ },
1027
+ "/channels/{channel.id}/thread-members": {
1028
+ GET: "listThreadMembers"
1029
+ },
1030
+ "/channels/{channel.id}/threads/archived/public": {
1031
+ GET: "listPublicArchivedThreads"
1032
+ },
1033
+ "/channels/{channel.id}/threads/archived/private": {
1034
+ GET: "listPrivateArchivedThreads"
1035
+ },
1036
+ "/channels/{channel.id}/users/@me/threads/archived/private": {
1037
+ GET: "listJoinedPrivateArchivedThreads"
1038
+ }
1039
+ });
1040
+
1041
+ // src/types/user.ts
1042
+ var UserFlag = /* @__PURE__ */ ((UserFlag2) => {
1043
+ UserFlag2[UserFlag2["NONE"] = 0] = "NONE";
1044
+ UserFlag2[UserFlag2["DISCORD_EMPLOYEE"] = 1] = "DISCORD_EMPLOYEE";
1045
+ UserFlag2[UserFlag2["PARTNERED_SERVER_OWNER"] = 2] = "PARTNERED_SERVER_OWNER";
1046
+ UserFlag2[UserFlag2["HYPESQUAD_EVENTS"] = 4] = "HYPESQUAD_EVENTS";
1047
+ UserFlag2[UserFlag2["BUG_HUNTER_LEVEL_1"] = 8] = "BUG_HUNTER_LEVEL_1";
1048
+ UserFlag2[UserFlag2["HOUSE_BRAVERY"] = 64] = "HOUSE_BRAVERY";
1049
+ UserFlag2[UserFlag2["HOUSE_BRILLIANCE"] = 128] = "HOUSE_BRILLIANCE";
1050
+ UserFlag2[UserFlag2["HOUSE_BALANCE"] = 256] = "HOUSE_BALANCE";
1051
+ UserFlag2[UserFlag2["EARLY_SUPPORTER"] = 512] = "EARLY_SUPPORTER";
1052
+ UserFlag2[UserFlag2["TEAM_USER"] = 1024] = "TEAM_USER";
1053
+ UserFlag2[UserFlag2["BUG_HUNTER_LEVEL_2"] = 16384] = "BUG_HUNTER_LEVEL_2";
1054
+ UserFlag2[UserFlag2["VERIFIED_BOT"] = 65536] = "VERIFIED_BOT";
1055
+ UserFlag2[UserFlag2["EARLY_VERIFIED_BOT_DEVELOPER"] = 131072] = "EARLY_VERIFIED_BOT_DEVELOPER";
1056
+ UserFlag2[UserFlag2["DISCORD_CERTIFIED_MODERATOR"] = 262144] = "DISCORD_CERTIFIED_MODERATOR";
1057
+ UserFlag2[UserFlag2["BOT_HTTP_INTERACTIONS"] = 524288] = "BOT_HTTP_INTERACTIONS";
1058
+ UserFlag2[UserFlag2["ACTIVE_DEVELOPER"] = 4194304] = "ACTIVE_DEVELOPER";
1059
+ return UserFlag2;
1060
+ })(UserFlag || {});
1061
+ var PremiumType = /* @__PURE__ */ ((PremiumType2) => {
1062
+ PremiumType2[PremiumType2["NONE"] = 0] = "NONE";
1063
+ PremiumType2[PremiumType2["NITRO_CLASSIC"] = 1] = "NITRO_CLASSIC";
1064
+ PremiumType2[PremiumType2["NITRO"] = 2] = "NITRO";
1065
+ PremiumType2[PremiumType2["NITRO_BASIC"] = 3] = "NITRO_BASIC";
1066
+ return PremiumType2;
1067
+ })(PremiumType || {});
1068
+ var VisibilityType = /* @__PURE__ */ ((VisibilityType2) => {
1069
+ VisibilityType2[VisibilityType2["NONE"] = 0] = "NONE";
1070
+ VisibilityType2[VisibilityType2["EVERYONE"] = 1] = "EVERYONE";
1071
+ return VisibilityType2;
1072
+ })(VisibilityType || {});
1073
+ Internal.define({
1074
+ "/users/@me": {
1075
+ GET: "getCurrentUser",
1076
+ PATCH: "modifyCurrentUser"
1077
+ },
1078
+ "/users/{user.id}": {
1079
+ GET: "getUser"
1080
+ },
1081
+ "/users/@me/connections": {
1082
+ GET: "getUserConnections"
1083
+ }
1084
+ });
1085
+
1086
+ // src/types/voice.ts
1087
+ Internal.define({
1088
+ "/voice/regions": {
1089
+ GET: "listVoiceRegions"
1090
+ },
1091
+ "/guilds/{guild.id}/regions": {
1092
+ GET: "getGuildVoiceRegions"
1093
+ },
1094
+ "/guilds/{guild.id}/voice-states/@me": {
1095
+ PATCH: "modifyCurrentUserVoiceState"
1096
+ },
1097
+ "/guilds/{guild.id}/voice-states/{user.id}": {
1098
+ PATCH: "modifyUserVoiceState"
1099
+ }
1100
+ });
1101
+
1102
+ // src/types/webhook.ts
1103
+ var Webhook2;
1104
+ ((Webhook4) => {
1105
+ let Type;
1106
+ ((Type2) => {
1107
+ Type2[Type2["INCOMING"] = 1] = "INCOMING";
1108
+ Type2[Type2["CHANNEL_FOLLOWER"] = 2] = "CHANNEL_FOLLOWER";
1109
+ Type2[Type2["APPLICATION"] = 3] = "APPLICATION";
1110
+ })(Type = Webhook4.Type || (Webhook4.Type = {}));
1111
+ })(Webhook2 || (Webhook2 = {}));
1112
+ Internal.define({
1113
+ "/channels/{channel.id}/webhooks": {
1114
+ POST: "createWebhook",
1115
+ GET: "getChannelWebhooks"
1116
+ },
1117
+ "/guilds/{guild.id}/webhooks": {
1118
+ GET: "getGuildWebhooks"
1119
+ },
1120
+ "/webhooks/{webhook.id}": {
1121
+ GET: "getWebhook",
1122
+ PATCH: "modifyWebhook",
1123
+ DELETE: "deleteWebhook"
1124
+ },
1125
+ "/webhooks/{webhook.id}/{webhook.token}": {
1126
+ GET: "getWebhookwithToken",
1127
+ PATCH: "modifyWebhookwithToken",
1128
+ DELETE: "deleteWebhookwithToken",
1129
+ POST: "executeWebhook"
1130
+ },
1131
+ "/webhooks/{webhook.id}/{webhook.token}/slack": {
1132
+ POST: "executeSlackCompatibleWebhook"
1133
+ },
1134
+ "/webhooks/{webhook.id}/{webhook.token}/github": {
1135
+ POST: "executeGitHubCompatibleWebhook"
1136
+ },
1137
+ "/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}": {
1138
+ GET: "getWebhookMessage",
1139
+ PATCH: "editWebhookMessage",
1140
+ DELETE: "deleteWebhookMessage"
1141
+ }
1142
+ });
1143
+
1144
+ // src/types/index.ts
1145
+ var Locale3 = [
1146
+ "da",
1147
+ "de",
1148
+ "en-GB",
1149
+ "en-US",
1150
+ "es-ES",
1151
+ "fr",
1152
+ "hr",
1153
+ "it",
1154
+ "lt",
1155
+ "hu",
1156
+ "nl",
1157
+ "no",
1158
+ "pl",
1159
+ "pt-BR",
1160
+ "ro",
1161
+ "fi",
1162
+ "sv-SE",
1163
+ "vi",
1164
+ "tr",
1165
+ "cs",
1166
+ "el",
1167
+ "bg",
1168
+ "ru",
1169
+ "uk",
1170
+ "hi",
1171
+ "th",
1172
+ "zh-CN",
1173
+ "ja",
1174
+ "zh-TW",
1175
+ "ko"
1176
+ ];
1177
+
1178
+ // src/utils.ts
1179
+ var sanitize = /* @__PURE__ */ __name((val) => val.replace(/[\\*_`~|()\[\]]/g, "\\$&").replace(/@everyone/g, () => "\\@everyone").replace(/@here/g, () => "\\@here"), "sanitize");
1180
+ var decodeUser = /* @__PURE__ */ __name((user) => ({
1181
+ id: user.id,
1182
+ name: user.username,
1183
+ userId: user.id,
1184
+ avatar: user.avatar && `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`,
1185
+ username: user.username,
1186
+ discriminator: user.discriminator,
1187
+ isBot: user.bot || false
1188
+ }), "decodeUser");
1189
+ var decodeGuildMember = /* @__PURE__ */ __name((member) => ({
1190
+ user: member.user && decodeUser(member.user),
1191
+ nick: member.nick,
1192
+ roles: member.roles,
1193
+ joinedAt: member.joined_at && new Date(member.joined_at).valueOf()
1194
+ }), "decodeGuildMember");
1195
+ var decodeGuild = /* @__PURE__ */ __name((data) => ({
1196
+ id: data.id,
1197
+ name: data.name,
1198
+ avatar: data.icon && `https://cdn.discordapp.com/icons/${data.id}/${data.icon}.webp?size=240`
1199
+ }), "decodeGuild");
1200
+ var decodeChannel = /* @__PURE__ */ __name((data) => ({
1201
+ id: data.id,
1202
+ name: data.name,
1203
+ type: data.type === Channel2.Type.DM ? import_core2.Universal.Channel.Type.DIRECT : data.type === Channel2.Type.GUILD_VOICE ? import_core2.Universal.Channel.Type.VOICE : data.type === Channel2.Type.GUILD_CATEGORY ? import_core2.Universal.Channel.Type.CATEGORY : import_core2.Universal.Channel.Type.TEXT
1204
+ }), "decodeChannel");
1205
+ var decodeRole = /* @__PURE__ */ __name((role) => ({
1206
+ ...role,
1207
+ permissions: BigInt(role.permissions)
1208
+ }), "decodeRole");
1209
+ var encodeRole = /* @__PURE__ */ __name((role) => ({
1210
+ ...role,
1211
+ permissions: role.permissions && "" + role.permissions
1212
+ }), "encodeRole");
1213
+ async function decodeMessage(bot, data, message, payload = message, details = true) {
1214
+ const { platform } = bot;
1215
+ message.id = message.messageId = data.id;
1216
+ message.content = "";
1217
+ if (data.content) {
1218
+ message.content = data.content.replace(/<@[!&]?(.+?)>/g, (_, id) => {
1219
+ if (data.mention_roles.includes(id)) {
1220
+ return (0, import_core2.h)("at", { role: id }).toString();
1221
+ } else {
1222
+ const user = data.mentions?.find((u) => u.id === id || `${u.username}#${u.discriminator}` === id);
1223
+ return import_core2.h.at(id, { name: user?.username }).toString();
1224
+ }
1225
+ }).replace(/<a?:(.*):(.+?)>/g, (_, name, id) => {
1226
+ const animated = _[1] === "a";
1227
+ return (0, import_core2.h)("face", { id, name, animated, platform }, [
1228
+ import_core2.h.image(`https://cdn.discordapp.com/emojis/${id}.webp?quality=lossless`)
1229
+ ]).toString();
1230
+ }).replace(/@everyone/g, () => (0, import_core2.h)("at", { type: "all" }).toString()).replace(/@here/g, () => (0, import_core2.h)("at", { type: "here" }).toString()).replace(/<#(.+?)>/g, (_, id) => {
1231
+ const channel = data.mention_channels?.find((c) => c.id === id);
1232
+ return import_core2.h.sharp(id, { name: channel?.name }).toString();
1233
+ });
1234
+ }
1235
+ if (data.attachments?.length) {
1236
+ if (!/\s$/.test(message.content))
1237
+ message.content += " ";
1238
+ message.content += data.attachments.map((v) => {
1239
+ if (v.height && v.width && v.content_type?.startsWith("image/")) {
1240
+ return (0, import_core2.h)("img", {
1241
+ src: v.url,
1242
+ proxy_url: v.proxy_url,
1243
+ file: v.filename,
1244
+ type: v.content_type,
1245
+ width: v.width,
1246
+ height: v.height
1247
+ });
1248
+ } else if (v.height && v.width && v.content_type?.startsWith("video/")) {
1249
+ return (0, import_core2.h)("video", {
1250
+ src: v.url,
1251
+ proxy_url: v.proxy_url,
1252
+ file: v.filename,
1253
+ type: v.content_type,
1254
+ width: v.width,
1255
+ height: v.height,
1256
+ size: v.size
1257
+ });
1258
+ } else if (v.content_type?.startsWith("audio/")) {
1259
+ return (0, import_core2.h)("record", {
1260
+ src: v.url,
1261
+ proxy_url: v.proxy_url,
1262
+ file: v.filename,
1263
+ type: v.content_type,
1264
+ size: v.size
1265
+ });
1266
+ } else {
1267
+ return (0, import_core2.h)("file", {
1268
+ src: v.url,
1269
+ proxy_url: v.proxy_url,
1270
+ file: v.filename,
1271
+ type: v.content_type,
1272
+ size: v.size
1273
+ });
1274
+ }
1275
+ }).join("");
1276
+ }
1277
+ for (const embed of data.embeds) {
1278
+ if (embed.image) {
1279
+ message.content += (0, import_core2.h)("img", { src: embed.image.url, proxy_url: embed.image.proxy_url });
1280
+ }
1281
+ if (embed.thumbnail) {
1282
+ message.content += (0, import_core2.h)("img", { src: embed.thumbnail.url, proxy_url: embed.thumbnail.proxy_url });
1283
+ }
1284
+ if (embed.video) {
1285
+ message.content += (0, import_core2.h)("video", { src: embed.video.url, proxy_url: embed.video.proxy_url });
1286
+ }
1287
+ }
1288
+ message.elements = import_core2.h.parse(message.content);
1289
+ if (details && data.message_reference) {
1290
+ const { message_id, channel_id } = data.message_reference;
1291
+ message.quote = await bot.getMessage(channel_id, message_id, false);
1292
+ }
1293
+ message.createdAt = new Date(data.timestamp).valueOf();
1294
+ message.updatedAt = data.edited_timestamp && new Date(data.edited_timestamp).valueOf();
1295
+ if (!payload)
1296
+ return message;
1297
+ payload.channel = {
1298
+ id: data.channel_id,
1299
+ type: data.member ? import_core2.Universal.Channel.Type.TEXT : import_core2.Universal.Channel.Type.DIRECT
1300
+ };
1301
+ payload.user = decodeUser(data.author);
1302
+ payload.member = data.member && decodeGuildMember(data.member);
1303
+ payload.timestamp = new Date(data.timestamp).valueOf();
1304
+ return message;
1305
+ }
1306
+ __name(decodeMessage, "decodeMessage");
1307
+ function setupMessageGuildId(session, guildId) {
1308
+ session.guildId = guildId;
1309
+ session.isDirect = !guildId;
1310
+ session.subtype = guildId ? "group" : "private";
1311
+ }
1312
+ __name(setupMessageGuildId, "setupMessageGuildId");
1313
+ function setupReaction(session, data) {
1314
+ session.userId = data.user_id;
1315
+ session.messageId = data.message_id;
1316
+ session.guildId = data.guild_id;
1317
+ session.channelId = data.channel_id;
1318
+ session.isDirect = !data.guild_id;
1319
+ session.subtype = data.guild_id ? "group" : "private";
1320
+ if (!data.emoji)
1321
+ return;
1322
+ const { id, name } = data.emoji;
1323
+ session.content = id ? `${name}:${id}` : name;
1324
+ }
1325
+ __name(setupReaction, "setupReaction");
1326
+ async function adaptSession(bot, input) {
1327
+ const session = bot.session();
1328
+ session.setInternal("discord", input);
1329
+ if (input.t === "MESSAGE_CREATE") {
1330
+ setupMessageGuildId(session, input.d.guild_id);
1331
+ if (input.d.webhook_id && !session.isDirect) {
1332
+ try {
1333
+ const webhook = await bot.ensureWebhook(input.d.channel_id);
1334
+ if (webhook.id === input.d.webhook_id)
1335
+ return;
1336
+ } catch (e) {
1337
+ }
1338
+ }
1339
+ session.type = "message";
1340
+ await decodeMessage(bot, input.d, session.event.message = {}, session.event);
1341
+ } else if (input.t === "MESSAGE_UPDATE") {
1342
+ session.type = "message-updated";
1343
+ const message = await bot._getMessage(input.d.channel_id, input.d.id);
1344
+ await decodeMessage(bot, message, session.event.message = {}, session.event);
1345
+ const channel = await bot.internal.getChannel(input.d.channel_id);
1346
+ setupMessageGuildId(session, channel.guild_id);
1347
+ } else if (input.t === "MESSAGE_DELETE") {
1348
+ session.type = "message-deleted";
1349
+ session.messageId = input.d.id;
1350
+ session.channelId = input.d.channel_id;
1351
+ setupMessageGuildId(session, input.d.guild_id);
1352
+ } else if (input.t === "MESSAGE_REACTION_ADD") {
1353
+ session.type = "reaction-added";
1354
+ setupReaction(session, input.d);
1355
+ } else if (input.t === "MESSAGE_REACTION_REMOVE") {
1356
+ session.type = "reaction-deleted";
1357
+ session.subtype = "one";
1358
+ setupReaction(session, input.d);
1359
+ } else if (input.t === "MESSAGE_REACTION_REMOVE_ALL") {
1360
+ session.type = "reaction-deleted";
1361
+ session.subtype = "all";
1362
+ setupReaction(session, input.d);
1363
+ } else if (input.t === "MESSAGE_REACTION_REMOVE_EMOJI") {
1364
+ session.type = "reaction-deleted";
1365
+ session.subtype = "emoji";
1366
+ setupReaction(session, input.d);
1367
+ } else if (input.t === "GUILD_ROLE_CREATE") {
1368
+ session.type = "guild-role-added";
1369
+ session.guildId = input.d.guild_id;
1370
+ session.roleId = input.d.role.id;
1371
+ session.event.role = decodeRole(input.d.role);
1372
+ } else if (input.t === "GUILD_ROLE_UPDATE") {
1373
+ session.type = "guild-role-updated";
1374
+ session.guildId = input.d.guild_id;
1375
+ session.roleId = input.d.role.id;
1376
+ session.event.role = decodeRole(input.d.role);
1377
+ } else if (input.t === "GUILD_ROLE_DELETE") {
1378
+ session.type = "guild-role-added";
1379
+ session.guildId = input.d.guild_id;
1380
+ session.roleId = input.d.role_id;
1381
+ } else if (input.t === "INTERACTION_CREATE" && input.d.type === Interaction.Type.APPLICATION_COMMAND) {
1382
+ const data = input.d.data;
1383
+ const command = bot.commands.find((cmd) => cmd.name === data.name);
1384
+ if (!command)
1385
+ return;
1386
+ await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1387
+ type: Interaction.CallbackType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE
1388
+ });
1389
+ session.type = "interaction/command";
1390
+ session.isDirect = !input.d.guild_id;
1391
+ session.subtype = input.d.guild_id ? "group" : "private";
1392
+ session.channelId = input.d.channel_id;
1393
+ session.guildId = input.d.guild_id;
1394
+ session.userId = session.isDirect ? input.d.user.id : input.d.member.user.id;
1395
+ session.messageId = input.d.id;
1396
+ session.content = "";
1397
+ session.event.argv = decodeArgv(data, command);
1398
+ } else if (input.t === "INTERACTION_CREATE" && input.d.type === Interaction.Type.MODAL_SUBMIT) {
1399
+ const data = input.d.data;
1400
+ if (!data.custom_id.startsWith("input") && !data.custom_id.includes(":"))
1401
+ return;
1402
+ const user_input = data.components[0].components[0].value;
1403
+ await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1404
+ type: Interaction.CallbackType.DEFERRED_UPDATE_MESSAGE
1405
+ });
1406
+ session.type = "interaction/command";
1407
+ session.isDirect = !input.d.guild_id;
1408
+ session.subtype = input.d.guild_id ? "group" : "private";
1409
+ session.channelId = input.d.channel_id;
1410
+ session.guildId = input.d.guild_id;
1411
+ session.userId = session.isDirect ? input.d.user.id : input.d.member.user.id;
1412
+ session.messageId = input.d.id;
1413
+ session.content = user_input;
1414
+ } else if (input.t === "INTERACTION_CREATE" && input.d.type === Interaction.Type.MESSAGE_COMPONENT) {
1415
+ const id = input.d.data.custom_id;
1416
+ if (id.startsWith("input") && id.includes(":")) {
1417
+ await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1418
+ type: Interaction.CallbackType.MODAL,
1419
+ data: {
1420
+ custom_id: id,
1421
+ title: "Input",
1422
+ components: [{
1423
+ type: 1 /* ACTION_ROW */,
1424
+ components: [{
1425
+ custom_id: id,
1426
+ type: 4 /* TEXT_INPUT */,
1427
+ label: "Command",
1428
+ value: id.slice(id.indexOf(":") + 1),
1429
+ style: 1
1430
+ }]
1431
+ }]
1432
+ }
1433
+ });
1434
+ } else {
1435
+ await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1436
+ type: Interaction.CallbackType.DEFERRED_UPDATE_MESSAGE
1437
+ });
1438
+ }
1439
+ session.type = "interaction/button";
1440
+ session.isDirect = !input.d.guild_id;
1441
+ session.channelId = input.d.channel_id;
1442
+ session.guildId = input.d.guild_id;
1443
+ session.userId = session.isDirect ? input.d.user.id : input.d.member.user.id;
1444
+ session.messageId = input.d.id;
1445
+ session.content = "";
1446
+ session.event.button = {
1447
+ id
1448
+ };
1449
+ } else if (input.t === "CHANNEL_UPDATE") {
1450
+ session.type = "channel-updated";
1451
+ session.guildId = input.d.guild_id;
1452
+ session.subtype = input.d.guild_id ? "group" : "private";
1453
+ session.channelId = input.d.id;
1454
+ } else {
1455
+ return;
1456
+ }
1457
+ return session;
1458
+ }
1459
+ __name(adaptSession, "adaptSession");
1460
+ var types = {
1461
+ text: ApplicationCommand2.OptionType.STRING,
1462
+ string: ApplicationCommand2.OptionType.STRING,
1463
+ boolean: ApplicationCommand2.OptionType.BOOLEAN,
1464
+ number: ApplicationCommand2.OptionType.NUMBER,
1465
+ integer: ApplicationCommand2.OptionType.INTEGER,
1466
+ posint: ApplicationCommand2.OptionType.INTEGER,
1467
+ user: ApplicationCommand2.OptionType.STRING,
1468
+ channel: ApplicationCommand2.OptionType.STRING,
1469
+ guild: ApplicationCommand2.OptionType.STRING
1470
+ };
1471
+ var trimDescription = /* @__PURE__ */ __name((source) => {
1472
+ if (!source || source.length < 96)
1473
+ return source;
1474
+ return source.slice(0, 93) + "...";
1475
+ }, "trimDescription");
1476
+ var encodeDescription = /* @__PURE__ */ __name((object) => ({
1477
+ description: trimDescription(object.description[""] || object.name),
1478
+ description_localizations: (0, import_core2.valueMap)((0, import_core2.pick)(object.description, Locale3), trimDescription)
1479
+ }), "encodeDescription");
1480
+ var encodeCommand = /* @__PURE__ */ __name((cmd) => ({
1481
+ ...encodeDescription(cmd),
1482
+ name: cmd.name,
1483
+ type: ApplicationCommand2.Type.CHAT_INPUT,
1484
+ options: encodeCommandOptions(cmd)
1485
+ }), "encodeCommand");
1486
+ var decodeArgv = /* @__PURE__ */ __name((data, command) => {
1487
+ const result = { name: data.name, arguments: [], options: {} };
1488
+ for (const argument of command.arguments) {
1489
+ const value = data.options?.find((opt) => opt.name === argument.name)?.value;
1490
+ if (value !== void 0)
1491
+ result.arguments.push(value);
1492
+ }
1493
+ for (const option of command.options) {
1494
+ const value = data.options?.find((opt) => opt.name === option.name)?.value;
1495
+ if (value !== void 0)
1496
+ result.options[option.name] = value;
1497
+ }
1498
+ return result;
1499
+ }, "decodeArgv");
1500
+ function encodeCommandOptions(cmd) {
1501
+ const result = [];
1502
+ if (cmd.children.length) {
1503
+ result.push(...cmd.children.map((child) => ({
1504
+ name: child.name.slice(cmd.name.length + 1),
1505
+ type: child.children.length ? ApplicationCommand2.OptionType.SUB_COMMAND_GROUP : ApplicationCommand2.OptionType.SUB_COMMAND,
1506
+ options: encodeCommandOptions(child),
1507
+ description: cmd.description[""] || child.name,
1508
+ description_localizations: (0, import_core2.pick)(cmd.description, Locale3)
1509
+ })));
1510
+ } else {
1511
+ for (const arg of cmd.arguments) {
1512
+ result.push({
1513
+ ...encodeDescription(arg),
1514
+ name: arg.name.toLowerCase().replace(/[^a-z0-9]/g, ""),
1515
+ type: types[arg.type] ?? types.text,
1516
+ required: arg.required ?? false
1517
+ });
1518
+ }
1519
+ for (const option of cmd.options) {
1520
+ result.push({
1521
+ ...encodeDescription(option),
1522
+ name: option.name.toLowerCase(),
1523
+ type: types[option.type] ?? types.text,
1524
+ required: false,
1525
+ min_value: option.type === "posint" ? 1 : void 0
1526
+ });
1527
+ }
1528
+ }
1529
+ return result.sort((a, b) => +b.required - +a.required);
1530
+ }
1531
+ __name(encodeCommandOptions, "encodeCommandOptions");
1532
+
1533
+ // src/message.ts
1534
+ var import_core3 = require("@satorijs/core");
1535
+ var State = class {
1536
+ // forward: send the first message and create a thread
1537
+ constructor(type) {
1538
+ this.type = type;
1539
+ }
1540
+ static {
1541
+ __name(this, "State");
1542
+ }
1543
+ author = {};
1544
+ quote = {};
1545
+ channel = {};
1546
+ fakeMessageMap = {};
1547
+ // [userInput] = discord messages
1548
+ threadCreated = false;
1549
+ };
1550
+ var DiscordMessageEncoder = class extends import_core3.MessageEncoder {
1551
+ static {
1552
+ __name(this, "DiscordMessageEncoder");
1553
+ }
1554
+ stack = [new State("message")];
1555
+ buffer = "";
1556
+ addition = {};
1557
+ figure = null;
1558
+ mode = "default";
1559
+ listType = null;
1560
+ rows = [];
1561
+ async getUrl() {
1562
+ const input = this.options?.session?.discord;
1563
+ if (input?.t === "INTERACTION_CREATE") {
1564
+ return `/webhooks/${input.d.application_id}/${input.d.token}`;
1565
+ } else if (this.stack[0].type === "forward" && this.stack[0].channel?.id) {
1566
+ if (this.stack[1].author.name || this.stack[1].author.avatar) {
1567
+ const webhook = await this.ensureWebhook();
1568
+ return `/webhooks/${webhook.id}/${webhook.token}?wait=true&thread_id=${this.stack[0].channel?.id}`;
1569
+ } else {
1570
+ return `/channels/${this.stack[0].channel.id}/messages`;
1571
+ }
1572
+ } else {
1573
+ if (this.stack[0].author.name || this.stack[0].author.avatar || this.stack[0].type === "forward" && !this.stack[0].threadCreated) {
1574
+ const webhook = await this.ensureWebhook();
1575
+ return `/webhooks/${webhook.id}/${webhook.token}?wait=true`;
1576
+ } else {
1577
+ return `/channels/${this.channelId}/messages`;
1578
+ }
1579
+ }
1580
+ }
1581
+ async post(data, headers) {
1582
+ try {
1583
+ const url = await this.getUrl();
1584
+ const result = await this.bot.http.post(url, data, { headers });
1585
+ const session = this.bot.session();
1586
+ const message = await decodeMessage(this.bot, result, session.event.message = {}, session.event);
1587
+ session.app.emit(session, "send", session);
1588
+ this.results.push(session.event.message);
1589
+ Object.defineProperty(session.event.message, "channel", {
1590
+ configurable: true,
1591
+ get: () => session.event.channel
1592
+ });
1593
+ if (this.stack[0].type === "forward" && !this.stack[0].threadCreated) {
1594
+ this.stack[0].threadCreated = true;
1595
+ const thread = await this.bot.internal.startThreadFromMessage(this.channelId, result.id, {
1596
+ name: "Forward",
1597
+ auto_archive_duration: 60
1598
+ });
1599
+ this.stack[0].channel = thread;
1600
+ }
1601
+ return message;
1602
+ } catch (e) {
1603
+ if (this.bot.http.isError(e) && e.response) {
1604
+ if (e.response.data?.code === 10015) {
1605
+ this.bot.logger.debug("webhook has been deleted, recreating..., %o", e.response.data);
1606
+ if (!this.bot.webhookLock[this.channelId])
1607
+ this.bot.webhooks[this.channelId] = null;
1608
+ await this.ensureWebhook();
1609
+ return this.post(data, headers);
1610
+ } else {
1611
+ e = new Error(`[${e.response.status}] ${JSON.stringify(e.response.data)}`);
1612
+ }
1613
+ }
1614
+ this.errors.push(e);
1615
+ }
1616
+ }
1617
+ async sendEmbed(attrs, payload) {
1618
+ const { filename, data, mime } = await this.bot.ctx.http.file(attrs.src || attrs.url, attrs);
1619
+ const form = new FormData();
1620
+ const value = new Blob([data], { type: mime });
1621
+ form.append("files[0]", value, attrs.file || filename);
1622
+ form.append("payload_json", JSON.stringify(payload));
1623
+ return this.post(form);
1624
+ }
1625
+ async sendAsset(type, attrs, addition) {
1626
+ const { handleMixedContent, handleExternalAsset } = this.bot.config;
1627
+ if (handleMixedContent === "separate" && addition.content) {
1628
+ await this.post(addition);
1629
+ addition.content = "";
1630
+ }
1631
+ const sendDirect = /* @__PURE__ */ __name(async () => {
1632
+ if (addition.content) {
1633
+ await this.post(addition);
1634
+ }
1635
+ return this.post({ ...addition, content: attrs.src || attrs.url });
1636
+ }, "sendDirect");
1637
+ if (await this.bot.http.isLocal(attrs.src || attrs.url)) {
1638
+ return await this.sendEmbed(attrs, addition);
1639
+ }
1640
+ const mode = attrs.mode || handleExternalAsset;
1641
+ if (mode === "download" || handleMixedContent === "attach" && addition.content || type === "file") {
1642
+ return this.sendEmbed(attrs, addition);
1643
+ } else if (mode === "direct") {
1644
+ return sendDirect();
1645
+ }
1646
+ if (await this.checkMediaType(attrs.src || attrs.url, type)) {
1647
+ return sendDirect();
1648
+ } else {
1649
+ return this.sendEmbed(attrs, addition);
1650
+ }
1651
+ }
1652
+ checkMediaType(url, type) {
1653
+ if (url.startsWith("https://cdn.discordapp.com/"))
1654
+ return true;
1655
+ return this.bot.ctx.http.head(url, {
1656
+ headers: { accept: type + "/*" },
1657
+ timeout: 1e3
1658
+ }).then(
1659
+ (headers) => headers.get("content-type").startsWith(type),
1660
+ () => false
1661
+ );
1662
+ }
1663
+ async ensureWebhook() {
1664
+ return this.bot.ensureWebhook(this.channelId);
1665
+ }
1666
+ async flush() {
1667
+ const content = this.buffer.trim();
1668
+ this.trimButtons();
1669
+ if (!content && !this.rows.length)
1670
+ return;
1671
+ this.addition.components = this.rows;
1672
+ await this.post({ ...this.addition, content });
1673
+ this.buffer = "";
1674
+ this.addition = {};
1675
+ this.rows = [];
1676
+ }
1677
+ decodeButton(attrs, label) {
1678
+ let style = 1 /* PRIMARY */;
1679
+ if (attrs.class === "secondary")
1680
+ style = 2 /* SECONDARY */;
1681
+ if (attrs.class === "danger")
1682
+ style = 4 /* DANGER */;
1683
+ if (attrs.class === "success")
1684
+ style = 3 /* SUCCESS */;
1685
+ if (attrs.type === "link") {
1686
+ return {
1687
+ type: 2 /* BUTTON */,
1688
+ url: attrs.href,
1689
+ label: label || "Link",
1690
+ style: 5 /* LINK */
1691
+ };
1692
+ } else if (attrs.type === "input") {
1693
+ return {
1694
+ type: 2 /* BUTTON */,
1695
+ custom_id: `input${attrs.id}:${attrs.text ?? ""}`,
1696
+ label: label || "Input",
1697
+ style
1698
+ };
1699
+ } else {
1700
+ return {
1701
+ type: 2 /* BUTTON */,
1702
+ custom_id: attrs.id,
1703
+ label: label || "Button",
1704
+ style
1705
+ };
1706
+ }
1707
+ }
1708
+ lastRow() {
1709
+ if (!this.rows.length) {
1710
+ this.rows.push({
1711
+ type: 1 /* ACTION_ROW */,
1712
+ components: []
1713
+ });
1714
+ }
1715
+ let last = this.rows[this.rows.length - 1];
1716
+ if (last.components.length >= 5) {
1717
+ this.rows.push({
1718
+ type: 1 /* ACTION_ROW */,
1719
+ components: []
1720
+ });
1721
+ last = this.rows[this.rows.length - 1];
1722
+ }
1723
+ return last;
1724
+ }
1725
+ trimButtons() {
1726
+ if (this.rows.length && this.rows[this.rows.length - 1].components.length === 0)
1727
+ this.rows.pop();
1728
+ }
1729
+ async visit(element) {
1730
+ const { type, attrs, children } = element;
1731
+ if (type === "text") {
1732
+ this.buffer += sanitize(attrs.content);
1733
+ } else if (type === "b" || type === "strong") {
1734
+ this.buffer += "**";
1735
+ await this.render(children);
1736
+ this.buffer += "**";
1737
+ } else if (type === "i" || type === "em") {
1738
+ this.buffer += "*";
1739
+ await this.render(children);
1740
+ this.buffer += "*";
1741
+ } else if (type === "u" || type === "ins") {
1742
+ this.buffer += "__";
1743
+ await this.render(children);
1744
+ this.buffer += "__";
1745
+ } else if (type === "s" || type === "del") {
1746
+ this.buffer += "~~";
1747
+ await this.render(children);
1748
+ this.buffer += "~~";
1749
+ } else if (type === "spl") {
1750
+ this.buffer += "||";
1751
+ await this.render(children);
1752
+ this.buffer += "||";
1753
+ } else if (type === "code") {
1754
+ this.buffer += "`";
1755
+ await this.render(children);
1756
+ this.buffer += "`";
1757
+ } else if (type === "a") {
1758
+ this.buffer += "[";
1759
+ await this.render(children);
1760
+ this.buffer += "]";
1761
+ if (this.options.linkPreview) {
1762
+ this.buffer += `(${attrs.href})`;
1763
+ } else {
1764
+ this.buffer += `(<${attrs.href}>)`;
1765
+ }
1766
+ } else if (type === "br") {
1767
+ this.buffer += "\n";
1768
+ } else if (type === "p") {
1769
+ if (!this.buffer.endsWith("\n"))
1770
+ this.buffer += "\n";
1771
+ await this.render(children);
1772
+ if (!this.buffer.endsWith("\n"))
1773
+ this.buffer += "\n";
1774
+ } else if (type === "blockquote") {
1775
+ if (!this.buffer.endsWith("\n"))
1776
+ this.buffer += "\n";
1777
+ this.buffer += "> ";
1778
+ await this.render(children);
1779
+ this.buffer += "\n";
1780
+ } else if (type === "ul" || type === "ol") {
1781
+ this.listType = type;
1782
+ await this.render(children);
1783
+ this.listType = null;
1784
+ } else if (type === "li") {
1785
+ if (!this.buffer.endsWith("\n"))
1786
+ this.buffer += "\n";
1787
+ if (this.listType === "ol") {
1788
+ this.buffer += "0. ";
1789
+ } else if (this.listType === "ul") {
1790
+ this.buffer += "- ";
1791
+ }
1792
+ this.render(children);
1793
+ this.buffer += "\n";
1794
+ } else if (type === "at") {
1795
+ if (attrs.id) {
1796
+ this.buffer += `<@${attrs.id}>`;
1797
+ } else if (attrs.type === "all") {
1798
+ this.buffer += `@everyone`;
1799
+ } else if (attrs.type === "here") {
1800
+ this.buffer += `@here`;
1801
+ }
1802
+ } else if (type === "sharp" && attrs.id) {
1803
+ this.buffer += `<#${attrs.id}>`;
1804
+ } else if (type === "face") {
1805
+ if (attrs.platform && attrs.platform !== this.bot.platform) {
1806
+ return this.render(children);
1807
+ } else {
1808
+ this.buffer += `<${attrs.animated ? "a" : ""}:${attrs.name}:${attrs.id}>`;
1809
+ }
1810
+ } else if ((type === "img" || type === "image" || type === "video") && (attrs.src || attrs.url)) {
1811
+ if (this.mode === "figure") {
1812
+ this.figure = element;
1813
+ } else {
1814
+ await this.sendAsset(type, attrs, {
1815
+ ...this.addition,
1816
+ content: this.buffer.trim()
1817
+ });
1818
+ this.buffer = "";
1819
+ }
1820
+ } else if (type === "share") {
1821
+ await this.flush();
1822
+ await this.post({
1823
+ ...this.addition,
1824
+ embeds: [{ ...attrs }]
1825
+ });
1826
+ } else if (type === "audio") {
1827
+ await this.sendAsset("file", attrs, {
1828
+ ...this.addition,
1829
+ content: "",
1830
+ attachments: [
1831
+ {
1832
+ waveform: "",
1833
+ // base64 encoded bytearray representing a sampled waveform
1834
+ id: 0,
1835
+ duration_secs: attrs.duration ?? 0
1836
+ }
1837
+ ],
1838
+ flags: Message2.Flag.IS_VOICE_MESSAGE
1839
+ });
1840
+ this.buffer = "";
1841
+ } else if (type === "author") {
1842
+ const { avatar, name } = attrs;
1843
+ if (avatar)
1844
+ this.addition.avatar_url = avatar;
1845
+ if (name)
1846
+ this.addition.username = name;
1847
+ if (this.stack[0].type === "message") {
1848
+ this.stack[0].author = attrs;
1849
+ }
1850
+ if (this.stack[0].type === "forward") {
1851
+ this.stack[1].author = attrs;
1852
+ }
1853
+ } else if (type === "quote") {
1854
+ await this.flush();
1855
+ const parse = /* @__PURE__ */ __name((val) => val.replace(/\\([\\*_`~|()\[\]])/g, "$1"), "parse");
1856
+ const message = this.stack[this.stack[0].type === "forward" ? 1 : 0];
1857
+ if (!message.author.avatar && !message.author.name && this.stack[0].type !== "forward") {
1858
+ await this.flush();
1859
+ this.addition.message_reference = {
1860
+ message_id: attrs.id
1861
+ };
1862
+ } else {
1863
+ let replyId = attrs.id, guildId = this.session.guildId, channelId = this.channelId;
1864
+ if (this.stack[0].type === "forward" && this.stack[0].fakeMessageMap[attrs.id]?.length >= 1) {
1865
+ replyId = this.stack[0].fakeMessageMap[attrs.id][0].id;
1866
+ channelId = this.stack[0].fakeMessageMap[attrs.id][0].channel.id;
1867
+ }
1868
+ const quote = await this.bot.getMessage(channelId, replyId);
1869
+ if (!guildId) {
1870
+ const c = await this.bot.internal.getChannel(channelId);
1871
+ if (c.guild_id)
1872
+ guildId = c.guild_id;
1873
+ }
1874
+ if (!guildId) {
1875
+ this.bot.logger.warn("skip <quote> due to missing guild id");
1876
+ return;
1877
+ }
1878
+ this.addition.embeds = [{
1879
+ description: [
1880
+ sanitize(parse(quote.elements.filter((v) => v.type === "text").join("")).slice(0, 30)),
1881
+ `<t:${Math.ceil(quote.timestamp / 1e3)}:R> [[ ↑ ]](https://discord.com/channels/${guildId}/${channelId}/${replyId})`
1882
+ ].join("\n\n"),
1883
+ author: {
1884
+ name: quote.user.name,
1885
+ icon_url: quote.user.avatar
1886
+ }
1887
+ }];
1888
+ }
1889
+ } else if (type === "figure") {
1890
+ await this.flush();
1891
+ this.mode = "figure";
1892
+ await this.render(children);
1893
+ await this.sendAsset(this.figure.type, this.figure.attrs, {
1894
+ ...this.addition,
1895
+ content: this.buffer.trim()
1896
+ });
1897
+ this.buffer = "";
1898
+ this.mode = "default";
1899
+ } else if (type === "message" && !attrs.forward) {
1900
+ if (this.mode === "figure") {
1901
+ await this.render(children);
1902
+ this.buffer += "\n";
1903
+ } else {
1904
+ const resultLength = +this.results.length;
1905
+ await this.flush();
1906
+ await this.render(children);
1907
+ await this.flush();
1908
+ const newLength = +this.results.length;
1909
+ const sentMessages = this.results.slice(resultLength, newLength);
1910
+ if (this.stack[0].type === "forward" && attrs.id) {
1911
+ this.stack[0].fakeMessageMap[attrs.id] = sentMessages;
1912
+ }
1913
+ if (this.stack[0].type === "message") {
1914
+ this.stack[0].author = {};
1915
+ }
1916
+ if (this.stack[0].type === "forward") {
1917
+ this.stack[1].author = {};
1918
+ }
1919
+ }
1920
+ } else if (type === "button") {
1921
+ const last = this.lastRow();
1922
+ last.components.push(this.decodeButton(
1923
+ attrs,
1924
+ children.join("")
1925
+ ));
1926
+ } else if (type === "button-group") {
1927
+ if (this.rows.length && this.rows[this.rows.length - 1].components.length) {
1928
+ this.rows.push({
1929
+ type: 1 /* ACTION_ROW */,
1930
+ components: []
1931
+ });
1932
+ }
1933
+ await this.render(children);
1934
+ this.rows.push({
1935
+ type: 1 /* ACTION_ROW */,
1936
+ components: []
1937
+ });
1938
+ } else if (type === "message" && attrs.forward) {
1939
+ this.stack.unshift(new State("forward"));
1940
+ await this.render(children);
1941
+ await this.flush();
1942
+ await this.bot.internal.modifyChannel(this.stack[0].channel.id, {
1943
+ archived: true,
1944
+ locked: true
1945
+ });
1946
+ this.stack.shift();
1947
+ } else {
1948
+ await this.render(children);
1949
+ }
1950
+ }
1951
+ };
1952
+ ((DiscordMessageEncoder2) => {
1953
+ DiscordMessageEncoder2.Config = import_core3.Schema.object({
1954
+ handleExternalAsset: import_core3.Schema.union([
1955
+ import_core3.Schema.const("download").description("先下载后发送"),
1956
+ import_core3.Schema.const("direct").description("直接发送链接"),
1957
+ import_core3.Schema.const("auto").description("发送一个 HEAD 请求,根据返回的 Content-Type 决定发送方式")
1958
+ ]).role("radio").description("发送外链资源时采用的方式。").default("auto"),
1959
+ handleMixedContent: import_core3.Schema.union([
1960
+ import_core3.Schema.const("separate").description("将每个不同形式的内容分开发送"),
1961
+ import_core3.Schema.const("attach").description("图片前如果有文本内容,则将文本作为图片的附带信息进行发送"),
1962
+ import_core3.Schema.const("auto").description("如果图片本身采用直接发送则与前面的文本分开,否则将文本作为图片的附带信息发送")
1963
+ ]).role("radio").description("发送图文等混合内容时采用的方式。").default("auto")
1964
+ }).description("发送设置");
1965
+ })(DiscordMessageEncoder || (DiscordMessageEncoder = {}));
1966
+
1967
+ // src/ws.ts
1968
+ var import_core4 = require("@satorijs/core");
1969
+ var WsClient = class extends import_core4.Adapter.WsClient {
1970
+ static {
1971
+ __name(this, "WsClient");
1972
+ }
1973
+ _d = 0;
1974
+ _ping;
1975
+ _sessionId = "";
1976
+ _resumeUrl;
1977
+ async prepare() {
1978
+ if (this._resumeUrl) {
1979
+ return this.bot.http.ws(this._resumeUrl + "/?v=10&encoding=json");
1980
+ }
1981
+ const { url } = await this.bot.internal.getGatewayBot();
1982
+ return this.bot.http.ws(url + "/?v=10&encoding=json");
1983
+ }
1984
+ heartbeat() {
1985
+ this.bot.logger.debug(`heartbeat d ${this._d}`);
1986
+ this.socket.send(JSON.stringify({
1987
+ op: Gateway.Opcode.HEARTBEAT,
1988
+ d: this._d
1989
+ }));
1990
+ }
1991
+ accept() {
1992
+ this.socket.addEventListener("message", async ({ data }) => {
1993
+ let parsed;
1994
+ data = data.toString();
1995
+ try {
1996
+ parsed = JSON.parse(data);
1997
+ } catch (error) {
1998
+ return this.bot.logger.warn("cannot parse message", data);
1999
+ }
2000
+ this.bot.logger.debug(parsed);
2001
+ if (parsed.s) {
2002
+ this._d = parsed.s;
2003
+ }
2004
+ if (parsed.op === Gateway.Opcode.HELLO) {
2005
+ this._ping = setInterval(() => this.heartbeat(), parsed.d.heartbeat_interval);
2006
+ if (this._sessionId) {
2007
+ this.bot.logger.debug("resuming");
2008
+ this.socket.send(JSON.stringify({
2009
+ op: Gateway.Opcode.RESUME,
2010
+ d: {
2011
+ token: this.bot.config.token,
2012
+ session_id: this._sessionId,
2013
+ seq: this._d
2014
+ }
2015
+ }));
2016
+ } else {
2017
+ this.socket.send(JSON.stringify({
2018
+ op: Gateway.Opcode.IDENTIFY,
2019
+ d: {
2020
+ token: this.bot.config.token,
2021
+ properties: {},
2022
+ compress: false,
2023
+ intents: this.bot.config.intents
2024
+ }
2025
+ }));
2026
+ }
2027
+ }
2028
+ if (parsed.op === Gateway.Opcode.INVALID_SESSION) {
2029
+ if (parsed.d)
2030
+ return;
2031
+ this._sessionId = "";
2032
+ this.bot.logger.warn("offline: invalid session");
2033
+ this.socket?.close();
2034
+ }
2035
+ if (parsed.op === Gateway.Opcode.DISPATCH) {
2036
+ this.bot.dispatch(this.bot.session({
2037
+ type: "internal",
2038
+ _type: "discord/" + parsed.t.toLowerCase().replace(/_/g, "-"),
2039
+ _data: parsed.d
2040
+ }));
2041
+ if (parsed.t === "READY") {
2042
+ this._sessionId = parsed.d.session_id;
2043
+ this._resumeUrl = parsed.d.resume_gateway_url;
2044
+ this.bot.user = decodeUser(parsed.d.user);
2045
+ this.bot.logger.debug("session_id " + this._sessionId);
2046
+ return this.bot.online();
2047
+ }
2048
+ if (parsed.t === "RESUMED") {
2049
+ return this.bot.online();
2050
+ }
2051
+ const session = await adaptSession(this.bot, parsed);
2052
+ if (session)
2053
+ this.bot.dispatch(session);
2054
+ }
2055
+ if (parsed.op === Gateway.Opcode.RECONNECT) {
2056
+ this.bot.logger.warn("offline: discord request reconnect");
2057
+ this.socket?.close();
2058
+ }
2059
+ });
2060
+ this.socket.addEventListener("close", () => {
2061
+ clearInterval(this._ping);
2062
+ });
2063
+ }
2064
+ };
2065
+ ((WsClient2) => {
2066
+ WsClient2.Options = import_core4.Schema.intersect([
2067
+ import_core4.Schema.object({
2068
+ intents: import_core4.Schema.bitset(Gateway.Intent).description("需要订阅的机器人事件。").default(0 | Gateway.Intent.GUILD_MESSAGES | Gateway.Intent.GUILD_MESSAGE_REACTIONS | Gateway.Intent.DIRECT_MESSAGES | Gateway.Intent.DIRECT_MESSAGE_REACTIONS | Gateway.Intent.MESSAGE_CONTENT)
2069
+ }).description("推送设置"),
2070
+ import_core4.Adapter.WsClientConfig
2071
+ ]);
2072
+ })(WsClient || (WsClient = {}));
2073
+
2074
+ // src/bot.ts
2075
+ var import_package = require("../package.json");
2076
+ var DiscordBot = class extends import_core5.Bot {
2077
+ static {
2078
+ __name(this, "DiscordBot");
2079
+ }
2080
+ static MessageEncoder = DiscordMessageEncoder;
2081
+ static inject = ["http"];
2082
+ http;
2083
+ internal;
2084
+ webhooks = {};
2085
+ webhookLock = {};
2086
+ commands = [];
2087
+ constructor(ctx, config) {
2088
+ super(ctx, config, "discord");
2089
+ this.http = ctx.http.extend({
2090
+ ...config,
2091
+ headers: {
2092
+ Authorization: config.type === "user" ? config.token : `Bot ${config.token}`,
2093
+ "User-Agent": `Satori (https://koishi.chat/, ${import_package.version})`,
2094
+ ...config.headers
2095
+ }
2096
+ });
2097
+ this.internal = new Internal(this);
2098
+ ctx.plugin(WsClient, this);
2099
+ }
2100
+ async _ensureWebhook(channelId) {
2101
+ let webhook;
2102
+ const webhooks = await this.internal.getChannelWebhooks(channelId);
2103
+ const selfId = this.selfId;
2104
+ if (!webhooks.find((v) => v.name === "Koishi" && v.user.id === selfId)) {
2105
+ webhook = await this.internal.createWebhook(channelId, {
2106
+ name: "Koishi"
2107
+ });
2108
+ } else {
2109
+ webhook = webhooks.find((v) => v.name === "Koishi" && v.user.id === this.selfId);
2110
+ }
2111
+ return this.webhooks[channelId] = webhook;
2112
+ }
2113
+ async ensureWebhook(channelId) {
2114
+ if (this.webhooks[channelId] === null) {
2115
+ delete this.webhooks[channelId];
2116
+ delete this.webhookLock[channelId];
2117
+ }
2118
+ if (this.webhooks[channelId]) {
2119
+ delete this.webhookLock[channelId];
2120
+ return this.webhooks[channelId];
2121
+ }
2122
+ return this.webhookLock[channelId] ||= this._ensureWebhook(channelId);
2123
+ }
2124
+ async getLogin() {
2125
+ const data = await this.internal.getCurrentUser();
2126
+ this.user = decodeUser(data);
2127
+ return this.toJSON();
2128
+ }
2129
+ async deleteMessage(channelId, messageId) {
2130
+ await this.internal.deleteMessage(channelId, messageId);
2131
+ }
2132
+ async editMessage(channelId, messageId, content) {
2133
+ const elements = import_core5.h.normalize(content);
2134
+ content = elements.toString();
2135
+ const image = elements.find((v) => v.type === "img" || v.type === "image");
2136
+ if (image) {
2137
+ throw new Error("You can't include embed object(s) while editing message.");
2138
+ }
2139
+ await this.internal.editMessage(channelId, messageId, {
2140
+ content
2141
+ });
2142
+ }
2143
+ async _getMessage(channelId, messageId) {
2144
+ if (this.config.type === "user") {
2145
+ const data = await this.internal.getChannelMessages(channelId, { around: messageId, limit: 1 });
2146
+ return data[0];
2147
+ } else {
2148
+ return await this.internal.getChannelMessage(channelId, messageId);
2149
+ }
2150
+ }
2151
+ async getMessage(channelId, messageId, recursive = true) {
2152
+ const data = await this._getMessage(channelId, messageId);
2153
+ return await decodeMessage(this, data, {}, void 0, recursive);
2154
+ }
2155
+ async getMessageList(channelId, messageId, direction = "before", limit, order = "asc") {
2156
+ const messages = await this.internal.getChannelMessages(channelId, {
2157
+ [direction]: messageId,
2158
+ limit: limit && Math.min(limit, 100)
2159
+ });
2160
+ const data = await Promise.all(messages.reverse().map((data2) => decodeMessage(this, data2, {}, void 0, false)));
2161
+ const prev = data.at(direction === "after" ? -1 : 0)?.id;
2162
+ const next = data.at(direction === "before" ? 0 : -1)?.id;
2163
+ if (order === "desc")
2164
+ data.reverse();
2165
+ return { data, prev, next };
2166
+ }
2167
+ async getUser(userId) {
2168
+ const data = await this.internal.getUser(userId);
2169
+ return decodeUser(data);
2170
+ }
2171
+ async getGuildMemberList(guildId, after) {
2172
+ const users = await this.internal.listGuildMembers(guildId, { after, limit: 1e3 });
2173
+ const data = users.map((v) => decodeGuildMember(v));
2174
+ return { data, next: data[999]?.user.id };
2175
+ }
2176
+ async getChannel(channelId) {
2177
+ const data = await this.internal.getChannel(channelId);
2178
+ return decodeChannel(data);
2179
+ }
2180
+ async getGuildMember(guildId, userId) {
2181
+ const member = await this.internal.getGuildMember(guildId, userId);
2182
+ return decodeGuildMember(member);
2183
+ }
2184
+ async kickGuildMember(guildId, userId) {
2185
+ return this.internal.removeGuildMember(guildId, userId);
2186
+ }
2187
+ async getGuild(guildId) {
2188
+ const data = await this.internal.getGuild(guildId);
2189
+ return decodeGuild(data);
2190
+ }
2191
+ async getGuildList(after) {
2192
+ const guilds = await this.internal.getCurrentUserGuilds({ after, limit: 200 });
2193
+ const data = guilds.map(decodeGuild);
2194
+ return { data, next: data[199]?.id };
2195
+ }
2196
+ async getChannelList(guildId) {
2197
+ const channels = await this.internal.getGuildChannels(guildId);
2198
+ return { data: channels.map(decodeChannel) };
2199
+ }
2200
+ createReaction(channelId, messageId, emoji) {
2201
+ return this.internal.createReaction(channelId, messageId, emoji);
2202
+ }
2203
+ deleteReaction(channelId, messageId, emoji, userId) {
2204
+ if (!userId) {
2205
+ return this.internal.deleteOwnReaction(channelId, messageId, emoji);
2206
+ } else {
2207
+ return this.internal.deleteUserReaction(channelId, messageId, emoji, userId);
2208
+ }
2209
+ }
2210
+ clearReaction(channelId, messageId, emoji) {
2211
+ if (!emoji) {
2212
+ return this.internal.deleteAllReactions(channelId, messageId);
2213
+ } else {
2214
+ return this.internal.deleteAllReactionsForEmoji(channelId, messageId, emoji);
2215
+ }
2216
+ }
2217
+ async getReactionList(channelId, messageId, emoji, after) {
2218
+ const data = await this.internal.getReactions(channelId, messageId, emoji, { after, limit: 100 });
2219
+ return { data: data.map(decodeUser), next: data[99]?.id };
2220
+ }
2221
+ setGuildMemberRole(guildId, userId, roleId) {
2222
+ return this.internal.addGuildMemberRole(guildId, userId, roleId);
2223
+ }
2224
+ unsetGuildMemberRole(guildId, userId, roleId) {
2225
+ return this.internal.removeGuildMemberRole(guildId, userId, roleId);
2226
+ }
2227
+ async getGuildRoleList(guildId) {
2228
+ const data = await this.internal.getGuildRoles(guildId);
2229
+ return { data: data.map(decodeRole) };
2230
+ }
2231
+ async createGuildRole(guildId, data) {
2232
+ const role = await this.internal.createGuildRole(guildId, encodeRole(data));
2233
+ return decodeRole(role);
2234
+ }
2235
+ async updateGuildRole(guildId, roleId, data) {
2236
+ await this.internal.modifyGuildRole(guildId, roleId, encodeRole(data));
2237
+ }
2238
+ deleteGuildRole(guildId, roleId) {
2239
+ return this.internal.deleteGuildRole(guildId, roleId);
2240
+ }
2241
+ async createDirectChannel(userId) {
2242
+ const channel = await this.internal.createDM({ recipient_id: userId });
2243
+ return decodeChannel(channel);
2244
+ }
2245
+ async updateCommands(commands) {
2246
+ if (!this.config.slash)
2247
+ return;
2248
+ this.commands = commands;
2249
+ const updates = commands.map(encodeCommand);
2250
+ if (updates.length) {
2251
+ this.logger.debug("update %d command(s)", updates.length);
2252
+ await this.internal.bulkOverwriteGlobalApplicationCommands(this.selfId, updates);
2253
+ }
2254
+ }
2255
+ };
2256
+ ((DiscordBot2) => {
2257
+ DiscordBot2.Config = import_core5.Schema.intersect([
2258
+ import_core5.Schema.object({
2259
+ type: import_core5.Schema.union(["bot", "user"]).default("bot").description("登录方式")
2260
+ }),
2261
+ import_core5.Schema.union([
2262
+ import_core5.Schema.object({
2263
+ type: import_core5.Schema.const("bot"),
2264
+ token: import_core5.Schema.string().description("机器人的用户令牌。").role("secret").required()
2265
+ }),
2266
+ import_core5.Schema.object({
2267
+ type: import_core5.Schema.const("user"),
2268
+ token: import_core5.Schema.string().description("从网页端获取的用户令牌。").role("secret").required()
2269
+ })
2270
+ ]),
2271
+ import_core5.Schema.object({
2272
+ slash: import_core5.Schema.boolean().description("是否启用斜线指令。").default(true)
2273
+ }).description("功能设置"),
2274
+ WsClient.Options,
2275
+ DiscordMessageEncoder.Config,
2276
+ import_core5.HTTP.createConfig("https://discord.com/api/v10")
2277
+ ]);
2278
+ })(DiscordBot || (DiscordBot = {}));
2279
+
2280
+ // src/index.ts
2281
+ var src_default = DiscordBot;
2282
+ // Annotate the CommonJS export names for ESM import in node:
2283
+ 0 && (module.exports = {
2284
+ Discord,
2285
+ DiscordBot,
2286
+ DiscordMessageEncoder,
2287
+ WsClient
2288
+ });
2289
+ //# sourceMappingURL=index.cjs.map