@satorijs/adapter-discord 4.5.9 → 4.5.11

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.js DELETED
@@ -1,2250 +0,0 @@
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_satori5 = require("@satorijs/satori");
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_satori2 = require("@satorijs/satori");
85
-
86
- // src/types/internal.ts
87
- var import_satori = require("@satorijs/satori");
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_satori.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 (!import_satori.Quester.Error.is(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
- }), "decodeGuild");
1199
- var decodeChannel = /* @__PURE__ */ __name((data) => ({
1200
- id: data.id,
1201
- name: data.name,
1202
- type: data.type === Channel2.Type.DM ? import_satori2.Universal.Channel.Type.DIRECT : data.type === Channel2.Type.GUILD_VOICE ? import_satori2.Universal.Channel.Type.VOICE : data.type === Channel2.Type.GUILD_CATEGORY ? import_satori2.Universal.Channel.Type.CATEGORY : import_satori2.Universal.Channel.Type.TEXT
1203
- }), "decodeChannel");
1204
- var decodeRole = /* @__PURE__ */ __name((role) => ({
1205
- ...role,
1206
- permissions: BigInt(role.permissions)
1207
- }), "decodeRole");
1208
- var encodeRole = /* @__PURE__ */ __name((role) => ({
1209
- ...role,
1210
- permissions: role.permissions && "" + role.permissions
1211
- }), "encodeRole");
1212
- async function decodeMessage(bot, data, message, payload = message, details = true) {
1213
- const { platform } = bot;
1214
- message.id = message.messageId = data.id;
1215
- message.content = "";
1216
- if (data.content) {
1217
- message.content = data.content.replace(/<@[!&]?(.+?)>/g, (_, id) => {
1218
- if (data.mention_roles.includes(id)) {
1219
- return (0, import_satori2.h)("at", { role: id }).toString();
1220
- } else {
1221
- const user = data.mentions?.find((u) => u.id === id || `${u.username}#${u.discriminator}` === id);
1222
- return import_satori2.h.at(id, { name: user?.username }).toString();
1223
- }
1224
- }).replace(/<a?:(.*):(.+?)>/g, (_, name, id) => {
1225
- const animated = _[1] === "a";
1226
- return (0, import_satori2.h)("face", { id, name, animated, platform }, [
1227
- import_satori2.h.image(`https://cdn.discordapp.com/emojis/${id}.gif?quality=lossless`)
1228
- ]).toString();
1229
- }).replace(/@everyone/g, () => (0, import_satori2.h)("at", { type: "all" }).toString()).replace(/@here/g, () => (0, import_satori2.h)("at", { type: "here" }).toString()).replace(/<#(.+?)>/g, (_, id) => {
1230
- const channel = data.mention_channels?.find((c) => c.id === id);
1231
- return import_satori2.h.sharp(id, { name: channel?.name }).toString();
1232
- });
1233
- }
1234
- if (data.attachments?.length) {
1235
- if (!/\s$/.test(message.content))
1236
- message.content += " ";
1237
- message.content += data.attachments.map((v) => {
1238
- if (v.height && v.width && v.content_type?.startsWith("image/")) {
1239
- return (0, import_satori2.h)("img", {
1240
- src: v.url,
1241
- proxy_url: v.proxy_url,
1242
- file: v.filename
1243
- });
1244
- } else if (v.height && v.width && v.content_type?.startsWith("video/")) {
1245
- return (0, import_satori2.h)("video", {
1246
- src: v.url,
1247
- proxy_url: v.proxy_url,
1248
- file: v.filename
1249
- });
1250
- } else if (v.content_type?.startsWith("audio/")) {
1251
- return (0, import_satori2.h)("record", {
1252
- src: v.url,
1253
- proxy_url: v.proxy_url,
1254
- file: v.filename
1255
- });
1256
- } else {
1257
- return (0, import_satori2.h)("file", {
1258
- src: v.url,
1259
- proxy_url: v.proxy_url,
1260
- file: v.filename
1261
- });
1262
- }
1263
- }).join("");
1264
- }
1265
- for (const embed of data.embeds) {
1266
- if (embed.image) {
1267
- message.content += (0, import_satori2.h)("img", { src: embed.image.url, proxy_url: embed.image.proxy_url });
1268
- }
1269
- if (embed.thumbnail) {
1270
- message.content += (0, import_satori2.h)("img", { src: embed.thumbnail.url, proxy_url: embed.thumbnail.proxy_url });
1271
- }
1272
- if (embed.video) {
1273
- message.content += (0, import_satori2.h)("video", { src: embed.video.url, proxy_url: embed.video.proxy_url });
1274
- }
1275
- }
1276
- message.elements = import_satori2.h.parse(message.content);
1277
- if (details && data.message_reference) {
1278
- const { message_id, channel_id } = data.message_reference;
1279
- message.quote = await bot.getMessage(channel_id, message_id, false);
1280
- }
1281
- if (!payload)
1282
- return message;
1283
- payload.channel = {
1284
- id: data.channel_id,
1285
- type: data.member ? import_satori2.Universal.Channel.Type.TEXT : import_satori2.Universal.Channel.Type.DIRECT
1286
- };
1287
- payload.user = decodeUser(data.author);
1288
- payload.member = data.member && decodeGuildMember(data.member);
1289
- payload.timestamp = new Date(data.timestamp).valueOf() || Date.now();
1290
- return message;
1291
- }
1292
- __name(decodeMessage, "decodeMessage");
1293
- function setupMessageGuildId(session, guildId) {
1294
- session.guildId = guildId;
1295
- session.isDirect = !guildId;
1296
- session.subtype = guildId ? "group" : "private";
1297
- }
1298
- __name(setupMessageGuildId, "setupMessageGuildId");
1299
- function setupReaction(session, data) {
1300
- session.userId = data.user_id;
1301
- session.messageId = data.message_id;
1302
- session.guildId = data.guild_id;
1303
- session.channelId = data.channel_id;
1304
- session.isDirect = !data.guild_id;
1305
- session.subtype = data.guild_id ? "group" : "private";
1306
- if (!data.emoji)
1307
- return;
1308
- const { id, name } = data.emoji;
1309
- session.content = id ? `${name}:${id}` : name;
1310
- }
1311
- __name(setupReaction, "setupReaction");
1312
- async function adaptSession(bot, input) {
1313
- const session = bot.session();
1314
- session.setInternal("discord", input);
1315
- if (input.t === "MESSAGE_CREATE") {
1316
- setupMessageGuildId(session, input.d.guild_id);
1317
- if (input.d.webhook_id && !session.isDirect) {
1318
- try {
1319
- const webhook = await bot.ensureWebhook(input.d.channel_id);
1320
- if (webhook.id === input.d.webhook_id)
1321
- return;
1322
- } catch (e) {
1323
- }
1324
- }
1325
- session.type = "message";
1326
- await decodeMessage(bot, input.d, session.event.message = {}, session.event);
1327
- } else if (input.t === "MESSAGE_UPDATE") {
1328
- session.type = "message-updated";
1329
- const message = await bot.internal.getChannelMessage(input.d.channel_id, input.d.id);
1330
- await decodeMessage(bot, message, session.event.message = {}, session.event);
1331
- const channel = await bot.internal.getChannel(input.d.channel_id);
1332
- setupMessageGuildId(session, channel.guild_id);
1333
- } else if (input.t === "MESSAGE_DELETE") {
1334
- session.type = "message-deleted";
1335
- session.messageId = input.d.id;
1336
- session.channelId = input.d.channel_id;
1337
- setupMessageGuildId(session, input.d.guild_id);
1338
- } else if (input.t === "MESSAGE_REACTION_ADD") {
1339
- session.type = "reaction-added";
1340
- setupReaction(session, input.d);
1341
- } else if (input.t === "MESSAGE_REACTION_REMOVE") {
1342
- session.type = "reaction-deleted";
1343
- session.subtype = "one";
1344
- setupReaction(session, input.d);
1345
- } else if (input.t === "MESSAGE_REACTION_REMOVE_ALL") {
1346
- session.type = "reaction-deleted";
1347
- session.subtype = "all";
1348
- setupReaction(session, input.d);
1349
- } else if (input.t === "MESSAGE_REACTION_REMOVE_EMOJI") {
1350
- session.type = "reaction-deleted";
1351
- session.subtype = "emoji";
1352
- setupReaction(session, input.d);
1353
- } else if (input.t === "GUILD_ROLE_CREATE") {
1354
- session.type = "guild-role-added";
1355
- session.guildId = input.d.guild_id;
1356
- session.roleId = input.d.role.id;
1357
- session.event.role = decodeRole(input.d.role);
1358
- } else if (input.t === "GUILD_ROLE_UPDATE") {
1359
- session.type = "guild-role-updated";
1360
- session.guildId = input.d.guild_id;
1361
- session.roleId = input.d.role.id;
1362
- session.event.role = decodeRole(input.d.role);
1363
- } else if (input.t === "GUILD_ROLE_DELETE") {
1364
- session.type = "guild-role-added";
1365
- session.guildId = input.d.guild_id;
1366
- session.roleId = input.d.role_id;
1367
- } else if (input.t === "INTERACTION_CREATE" && input.d.type === Interaction.Type.APPLICATION_COMMAND) {
1368
- const data = input.d.data;
1369
- const command = bot.commands.find((cmd) => cmd.name === data.name);
1370
- if (!command)
1371
- return;
1372
- await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1373
- type: Interaction.CallbackType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE
1374
- });
1375
- session.type = "interaction/command";
1376
- session.isDirect = !input.d.guild_id;
1377
- session.subtype = input.d.guild_id ? "group" : "private";
1378
- session.channelId = input.d.channel_id;
1379
- session.guildId = input.d.guild_id;
1380
- session.userId = session.isDirect ? input.d.user.id : input.d.member.user.id;
1381
- session.messageId = input.d.id;
1382
- session.content = "";
1383
- session.event.argv = decodeArgv(data, command);
1384
- } else if (input.t === "INTERACTION_CREATE" && input.d.type === Interaction.Type.MODAL_SUBMIT) {
1385
- const data = input.d.data;
1386
- if (!data.custom_id.startsWith("input") && !data.custom_id.includes(":"))
1387
- return;
1388
- const user_input = data.components[0].components[0].value;
1389
- await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1390
- type: Interaction.CallbackType.DEFERRED_UPDATE_MESSAGE
1391
- });
1392
- session.type = "interaction/command";
1393
- session.isDirect = !input.d.guild_id;
1394
- session.subtype = input.d.guild_id ? "group" : "private";
1395
- session.channelId = input.d.channel_id;
1396
- session.guildId = input.d.guild_id;
1397
- session.userId = session.isDirect ? input.d.user.id : input.d.member.user.id;
1398
- session.messageId = input.d.id;
1399
- session.content = user_input;
1400
- } else if (input.t === "INTERACTION_CREATE" && input.d.type === Interaction.Type.MESSAGE_COMPONENT) {
1401
- const id = input.d.data.custom_id;
1402
- if (id.startsWith("input") && id.includes(":")) {
1403
- await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1404
- type: Interaction.CallbackType.MODAL,
1405
- data: {
1406
- custom_id: id,
1407
- title: "Input",
1408
- components: [{
1409
- type: 1 /* ACTION_ROW */,
1410
- components: [{
1411
- custom_id: id,
1412
- type: 4 /* TEXT_INPUT */,
1413
- label: "Command",
1414
- value: id.slice(id.indexOf(":") + 1),
1415
- style: 1
1416
- }]
1417
- }]
1418
- }
1419
- });
1420
- } else {
1421
- await bot.internal.createInteractionResponse(input.d.id, input.d.token, {
1422
- type: Interaction.CallbackType.DEFERRED_UPDATE_MESSAGE
1423
- });
1424
- }
1425
- session.type = "interaction/button";
1426
- session.isDirect = !input.d.guild_id;
1427
- session.channelId = input.d.channel_id;
1428
- session.guildId = input.d.guild_id;
1429
- session.userId = session.isDirect ? input.d.user.id : input.d.member.user.id;
1430
- session.messageId = input.d.id;
1431
- session.content = "";
1432
- session.event.button = {
1433
- id
1434
- };
1435
- } else if (input.t === "CHANNEL_UPDATE") {
1436
- session.type = "channel-updated";
1437
- session.guildId = input.d.guild_id;
1438
- session.subtype = input.d.guild_id ? "group" : "private";
1439
- session.channelId = input.d.id;
1440
- } else {
1441
- return;
1442
- }
1443
- return session;
1444
- }
1445
- __name(adaptSession, "adaptSession");
1446
- var types = {
1447
- text: ApplicationCommand2.OptionType.STRING,
1448
- string: ApplicationCommand2.OptionType.STRING,
1449
- boolean: ApplicationCommand2.OptionType.BOOLEAN,
1450
- number: ApplicationCommand2.OptionType.NUMBER,
1451
- integer: ApplicationCommand2.OptionType.INTEGER,
1452
- posint: ApplicationCommand2.OptionType.INTEGER,
1453
- user: ApplicationCommand2.OptionType.STRING,
1454
- channel: ApplicationCommand2.OptionType.STRING,
1455
- guild: ApplicationCommand2.OptionType.STRING
1456
- };
1457
- var trimDescription = /* @__PURE__ */ __name((source) => {
1458
- if (!source || source.length < 96)
1459
- return source;
1460
- return source.slice(0, 93) + "...";
1461
- }, "trimDescription");
1462
- var encodeDescription = /* @__PURE__ */ __name((object) => ({
1463
- description: trimDescription(object.description[""] || object.name),
1464
- description_localizations: (0, import_satori2.valueMap)((0, import_satori2.pick)(object.description, Locale3), trimDescription)
1465
- }), "encodeDescription");
1466
- var encodeCommand = /* @__PURE__ */ __name((cmd) => ({
1467
- ...encodeDescription(cmd),
1468
- name: cmd.name,
1469
- type: ApplicationCommand2.Type.CHAT_INPUT,
1470
- options: encodeCommandOptions(cmd)
1471
- }), "encodeCommand");
1472
- var decodeArgv = /* @__PURE__ */ __name((data, command) => {
1473
- const result = { name: data.name, arguments: [], options: {} };
1474
- for (const argument of command.arguments) {
1475
- const value = data.options?.find((opt) => opt.name === argument.name)?.value;
1476
- if (value !== void 0)
1477
- result.arguments.push(value);
1478
- }
1479
- for (const option of command.options) {
1480
- const value = data.options?.find((opt) => opt.name === option.name)?.value;
1481
- if (value !== void 0)
1482
- result.options[option.name] = value;
1483
- }
1484
- return result;
1485
- }, "decodeArgv");
1486
- function encodeCommandOptions(cmd) {
1487
- const result = [];
1488
- if (cmd.children.length) {
1489
- result.push(...cmd.children.map((child) => ({
1490
- name: child.name.slice(cmd.name.length + 1),
1491
- type: child.children.length ? ApplicationCommand2.OptionType.SUB_COMMAND_GROUP : ApplicationCommand2.OptionType.SUB_COMMAND,
1492
- options: encodeCommandOptions(child),
1493
- description: cmd.description[""] || child.name,
1494
- description_localizations: (0, import_satori2.pick)(cmd.description, Locale3)
1495
- })));
1496
- } else {
1497
- for (const arg of cmd.arguments) {
1498
- result.push({
1499
- ...encodeDescription(arg),
1500
- name: arg.name.toLowerCase().replace(/[^a-z0-9]/g, ""),
1501
- type: types[arg.type] ?? types.text,
1502
- required: arg.required ?? false
1503
- });
1504
- }
1505
- for (const option of cmd.options) {
1506
- result.push({
1507
- ...encodeDescription(option),
1508
- name: option.name.toLowerCase(),
1509
- type: types[option.type] ?? types.text,
1510
- required: option.required ?? false,
1511
- min_value: option.type === "posint" ? 1 : void 0
1512
- });
1513
- }
1514
- }
1515
- return result.sort((a, b) => +b.required - +a.required);
1516
- }
1517
- __name(encodeCommandOptions, "encodeCommandOptions");
1518
-
1519
- // src/message.ts
1520
- var import_satori3 = require("@satorijs/satori");
1521
- var State = class {
1522
- // forward: send the first message and create a thread
1523
- constructor(type) {
1524
- this.type = type;
1525
- }
1526
- static {
1527
- __name(this, "State");
1528
- }
1529
- author = {};
1530
- quote = {};
1531
- channel = {};
1532
- fakeMessageMap = {};
1533
- // [userInput] = discord messages
1534
- threadCreated = false;
1535
- };
1536
- var DiscordMessageEncoder = class extends import_satori3.MessageEncoder {
1537
- static {
1538
- __name(this, "DiscordMessageEncoder");
1539
- }
1540
- stack = [new State("message")];
1541
- buffer = "";
1542
- addition = {};
1543
- figure = null;
1544
- mode = "default";
1545
- listType = null;
1546
- rows = [];
1547
- async getUrl() {
1548
- const input = this.options?.session?.discord;
1549
- if (input?.t === "INTERACTION_CREATE") {
1550
- return `/webhooks/${input.d.application_id}/${input.d.token}`;
1551
- } else if (this.stack[0].type === "forward" && this.stack[0].channel?.id) {
1552
- if (this.stack[1].author.name || this.stack[1].author.avatar) {
1553
- const webhook = await this.ensureWebhook();
1554
- return `/webhooks/${webhook.id}/${webhook.token}?wait=true&thread_id=${this.stack[0].channel?.id}`;
1555
- } else {
1556
- return `/channels/${this.stack[0].channel.id}/messages`;
1557
- }
1558
- } else {
1559
- if (this.stack[0].author.name || this.stack[0].author.avatar || this.stack[0].type === "forward" && !this.stack[0].threadCreated) {
1560
- const webhook = await this.ensureWebhook();
1561
- return `/webhooks/${webhook.id}/${webhook.token}?wait=true`;
1562
- } else {
1563
- return `/channels/${this.channelId}/messages`;
1564
- }
1565
- }
1566
- }
1567
- async post(data, headers) {
1568
- try {
1569
- const url = await this.getUrl();
1570
- const result = await this.bot.http.post(url, data, { headers });
1571
- const session = this.bot.session();
1572
- const message = await decodeMessage(this.bot, result, session.event.message = {}, session.event);
1573
- session.app.emit(session, "send", session);
1574
- this.results.push(session.event.message);
1575
- Object.defineProperty(session.event.message, "channel", {
1576
- configurable: true,
1577
- get: () => session.event.channel
1578
- });
1579
- if (this.stack[0].type === "forward" && !this.stack[0].threadCreated) {
1580
- this.stack[0].threadCreated = true;
1581
- const thread = await this.bot.internal.startThreadFromMessage(this.channelId, result.id, {
1582
- name: "Forward",
1583
- auto_archive_duration: 60
1584
- });
1585
- this.stack[0].channel = thread;
1586
- }
1587
- return message;
1588
- } catch (e) {
1589
- if (import_satori3.Quester.Error.is(e) && e.response) {
1590
- if (e.response.data?.code === 10015) {
1591
- this.bot.logger.debug("webhook has been deleted, recreating..., %o", e.response.data);
1592
- if (!this.bot.webhookLock[this.channelId])
1593
- this.bot.webhooks[this.channelId] = null;
1594
- await this.ensureWebhook();
1595
- return this.post(data, headers);
1596
- } else {
1597
- e = new Error(`[${e.response.status}] ${JSON.stringify(e.response.data)}`);
1598
- }
1599
- }
1600
- this.errors.push(e);
1601
- }
1602
- }
1603
- async sendEmbed(attrs, payload) {
1604
- const { filename, data, mime } = await this.bot.ctx.http.file(attrs.src || attrs.url, attrs);
1605
- const form = new FormData();
1606
- const value = new Blob([data], { type: mime });
1607
- form.append("files[0]", value, attrs.file || filename);
1608
- form.append("payload_json", JSON.stringify(payload));
1609
- return this.post(form);
1610
- }
1611
- async sendAsset(type, attrs, addition) {
1612
- const { handleMixedContent, handleExternalAsset } = this.bot.config;
1613
- if (handleMixedContent === "separate" && addition.content) {
1614
- await this.post(addition);
1615
- addition.content = "";
1616
- }
1617
- const sendDirect = /* @__PURE__ */ __name(async () => {
1618
- if (addition.content) {
1619
- await this.post(addition);
1620
- }
1621
- return this.post({ ...addition, content: attrs.src || attrs.url });
1622
- }, "sendDirect");
1623
- if (await this.bot.http.isLocal(attrs.src || attrs.url)) {
1624
- return await this.sendEmbed(attrs, addition);
1625
- }
1626
- const mode = attrs.mode || handleExternalAsset;
1627
- if (mode === "download" || handleMixedContent === "attach" && addition.content || type === "file") {
1628
- return this.sendEmbed(attrs, addition);
1629
- } else if (mode === "direct") {
1630
- return sendDirect();
1631
- }
1632
- if (await this.checkMediaType(attrs.src || attrs.url, type)) {
1633
- return sendDirect();
1634
- } else {
1635
- return this.sendEmbed(attrs, addition);
1636
- }
1637
- }
1638
- checkMediaType(url, type) {
1639
- if (url.startsWith("https://cdn.discordapp.com/"))
1640
- return true;
1641
- return this.bot.ctx.http.head(url, {
1642
- headers: { accept: type + "/*" },
1643
- timeout: 1e3
1644
- }).then(
1645
- (headers) => headers.get("content-type").startsWith(type),
1646
- () => false
1647
- );
1648
- }
1649
- async ensureWebhook() {
1650
- return this.bot.ensureWebhook(this.channelId);
1651
- }
1652
- async flush() {
1653
- const content = this.buffer.trim();
1654
- this.trimButtons();
1655
- if (!content && !this.rows.length)
1656
- return;
1657
- this.addition.components = this.rows;
1658
- await this.post({ ...this.addition, content });
1659
- this.buffer = "";
1660
- this.addition = {};
1661
- this.rows = [];
1662
- }
1663
- decodeButton(attrs, label) {
1664
- let style = 1 /* PRIMARY */;
1665
- if (attrs.class === "secondary")
1666
- style = 2 /* SECONDARY */;
1667
- if (attrs.class === "danger")
1668
- style = 4 /* DANGER */;
1669
- if (attrs.class === "success")
1670
- style = 3 /* SUCCESS */;
1671
- if (attrs.type === "link") {
1672
- return {
1673
- type: 2 /* BUTTON */,
1674
- url: attrs.href,
1675
- label: label || "Link",
1676
- style: 5 /* LINK */
1677
- };
1678
- } else if (attrs.type === "input") {
1679
- return {
1680
- type: 2 /* BUTTON */,
1681
- custom_id: `input${attrs.id}:${attrs.text ?? ""}`,
1682
- label: label || "Input",
1683
- style
1684
- };
1685
- } else {
1686
- return {
1687
- type: 2 /* BUTTON */,
1688
- custom_id: attrs.id,
1689
- label: label || "Button",
1690
- style
1691
- };
1692
- }
1693
- }
1694
- lastRow() {
1695
- if (!this.rows.length) {
1696
- this.rows.push({
1697
- type: 1 /* ACTION_ROW */,
1698
- components: []
1699
- });
1700
- }
1701
- let last = this.rows[this.rows.length - 1];
1702
- if (last.components.length >= 5) {
1703
- this.rows.push({
1704
- type: 1 /* ACTION_ROW */,
1705
- components: []
1706
- });
1707
- last = this.rows[this.rows.length - 1];
1708
- }
1709
- return last;
1710
- }
1711
- trimButtons() {
1712
- if (this.rows.length && this.rows[this.rows.length - 1].components.length === 0)
1713
- this.rows.pop();
1714
- }
1715
- async visit(element) {
1716
- const { type, attrs, children } = element;
1717
- if (type === "text") {
1718
- this.buffer += sanitize(attrs.content);
1719
- } else if (type === "b" || type === "strong") {
1720
- this.buffer += "**";
1721
- await this.render(children);
1722
- this.buffer += "**";
1723
- } else if (type === "i" || type === "em") {
1724
- this.buffer += "*";
1725
- await this.render(children);
1726
- this.buffer += "*";
1727
- } else if (type === "u" || type === "ins") {
1728
- this.buffer += "__";
1729
- await this.render(children);
1730
- this.buffer += "__";
1731
- } else if (type === "s" || type === "del") {
1732
- this.buffer += "~~";
1733
- await this.render(children);
1734
- this.buffer += "~~";
1735
- } else if (type === "spl") {
1736
- this.buffer += "||";
1737
- await this.render(children);
1738
- this.buffer += "||";
1739
- } else if (type === "code") {
1740
- this.buffer += "`";
1741
- await this.render(children);
1742
- this.buffer += "`";
1743
- } else if (type === "a") {
1744
- this.buffer += "[";
1745
- await this.render(children);
1746
- this.buffer += "]";
1747
- if (this.options.linkPreview) {
1748
- this.buffer += `(${attrs.href})`;
1749
- } else {
1750
- this.buffer += `(<${attrs.href}>)`;
1751
- }
1752
- } else if (type === "br") {
1753
- this.buffer += "\n";
1754
- } else if (type === "p") {
1755
- if (!this.buffer.endsWith("\n"))
1756
- this.buffer += "\n";
1757
- await this.render(children);
1758
- if (!this.buffer.endsWith("\n"))
1759
- this.buffer += "\n";
1760
- } else if (type === "blockquote") {
1761
- if (!this.buffer.endsWith("\n"))
1762
- this.buffer += "\n";
1763
- this.buffer += "> ";
1764
- await this.render(children);
1765
- this.buffer += "\n";
1766
- } else if (type === "ul" || type === "ol") {
1767
- this.listType = type;
1768
- await this.render(children);
1769
- this.listType = null;
1770
- } else if (type === "li") {
1771
- if (!this.buffer.endsWith("\n"))
1772
- this.buffer += "\n";
1773
- if (this.listType === "ol") {
1774
- this.buffer += "0. ";
1775
- } else if (this.listType === "ul") {
1776
- this.buffer += "- ";
1777
- }
1778
- this.render(children);
1779
- this.buffer += "\n";
1780
- } else if (type === "at") {
1781
- if (attrs.id) {
1782
- this.buffer += `<@${attrs.id}>`;
1783
- } else if (attrs.type === "all") {
1784
- this.buffer += `@everyone`;
1785
- } else if (attrs.type === "here") {
1786
- this.buffer += `@here`;
1787
- }
1788
- } else if (type === "sharp" && attrs.id) {
1789
- this.buffer += `<#${attrs.id}>`;
1790
- } else if (type === "face") {
1791
- if (attrs.platform && attrs.platform !== this.bot.platform) {
1792
- return this.render(children);
1793
- } else {
1794
- this.buffer += `<${attrs.animated ? "a" : ""}:${attrs.name}:${attrs.id}>`;
1795
- }
1796
- } else if ((type === "img" || type === "image" || type === "video") && (attrs.src || attrs.url)) {
1797
- if (this.mode === "figure") {
1798
- this.figure = element;
1799
- } else {
1800
- await this.sendAsset(type, attrs, {
1801
- ...this.addition,
1802
- content: this.buffer.trim()
1803
- });
1804
- this.buffer = "";
1805
- }
1806
- } else if (type === "share") {
1807
- await this.flush();
1808
- await this.post({
1809
- ...this.addition,
1810
- embeds: [{ ...attrs }]
1811
- });
1812
- } else if (type === "audio") {
1813
- await this.sendAsset("file", attrs, {
1814
- ...this.addition,
1815
- content: "",
1816
- attachments: [
1817
- {
1818
- waveform: "",
1819
- // base64 encoded bytearray representing a sampled waveform
1820
- id: 0,
1821
- duration_secs: attrs.duration ?? 0
1822
- }
1823
- ],
1824
- flags: Message2.Flag.IS_VOICE_MESSAGE
1825
- });
1826
- this.buffer = "";
1827
- } else if (type === "author") {
1828
- const { avatar, name } = attrs;
1829
- if (avatar)
1830
- this.addition.avatar_url = avatar;
1831
- if (name)
1832
- this.addition.username = name;
1833
- if (this.stack[0].type === "message") {
1834
- this.stack[0].author = attrs;
1835
- }
1836
- if (this.stack[0].type === "forward") {
1837
- this.stack[1].author = attrs;
1838
- }
1839
- } else if (type === "quote") {
1840
- await this.flush();
1841
- const parse = /* @__PURE__ */ __name((val) => val.replace(/\\([\\*_`~|()\[\]])/g, "$1"), "parse");
1842
- const message = this.stack[this.stack[0].type === "forward" ? 1 : 0];
1843
- if (!message.author.avatar && !message.author.name && this.stack[0].type !== "forward") {
1844
- await this.flush();
1845
- this.addition.message_reference = {
1846
- message_id: attrs.id
1847
- };
1848
- } else {
1849
- let replyId = attrs.id, guildId = this.session.guildId, channelId = this.channelId;
1850
- if (this.stack[0].type === "forward" && this.stack[0].fakeMessageMap[attrs.id]?.length >= 1) {
1851
- replyId = this.stack[0].fakeMessageMap[attrs.id][0].id;
1852
- channelId = this.stack[0].fakeMessageMap[attrs.id][0].channel.id;
1853
- }
1854
- const quote = await this.bot.getMessage(channelId, replyId);
1855
- if (!guildId) {
1856
- const c = await this.bot.internal.getChannel(channelId);
1857
- if (c.guild_id)
1858
- guildId = c.guild_id;
1859
- }
1860
- if (!guildId) {
1861
- this.bot.logger.warn("skip <quote> due to missing guild id");
1862
- return;
1863
- }
1864
- this.addition.embeds = [{
1865
- description: [
1866
- sanitize(parse(quote.elements.filter((v) => v.type === "text").join("")).slice(0, 30)),
1867
- `<t:${Math.ceil(quote.timestamp / 1e3)}:R> [[ ↑ ]](https://discord.com/channels/${guildId}/${channelId}/${replyId})`
1868
- ].join("\n\n"),
1869
- author: {
1870
- name: quote.user.name,
1871
- icon_url: quote.user.avatar
1872
- }
1873
- }];
1874
- }
1875
- } else if (type === "figure") {
1876
- await this.flush();
1877
- this.mode = "figure";
1878
- await this.render(children);
1879
- await this.sendAsset(this.figure.type, this.figure.attrs, {
1880
- ...this.addition,
1881
- content: this.buffer.trim()
1882
- });
1883
- this.buffer = "";
1884
- this.mode = "default";
1885
- } else if (type === "message" && !attrs.forward) {
1886
- if (this.mode === "figure") {
1887
- await this.render(children);
1888
- this.buffer += "\n";
1889
- } else {
1890
- const resultLength = +this.results.length;
1891
- await this.flush();
1892
- await this.render(children);
1893
- await this.flush();
1894
- const newLength = +this.results.length;
1895
- const sentMessages = this.results.slice(resultLength, newLength);
1896
- if (this.stack[0].type === "forward" && attrs.id) {
1897
- this.stack[0].fakeMessageMap[attrs.id] = sentMessages;
1898
- }
1899
- if (this.stack[0].type === "message") {
1900
- this.stack[0].author = {};
1901
- }
1902
- if (this.stack[0].type === "forward") {
1903
- this.stack[1].author = {};
1904
- }
1905
- }
1906
- } else if (type === "button") {
1907
- const last = this.lastRow();
1908
- last.components.push(this.decodeButton(
1909
- attrs,
1910
- children.join("")
1911
- ));
1912
- } else if (type === "button-group") {
1913
- if (this.rows.length && this.rows[this.rows.length - 1].components.length) {
1914
- this.rows.push({
1915
- type: 1 /* ACTION_ROW */,
1916
- components: []
1917
- });
1918
- }
1919
- await this.render(children);
1920
- this.rows.push({
1921
- type: 1 /* ACTION_ROW */,
1922
- components: []
1923
- });
1924
- } else if (type === "message" && attrs.forward) {
1925
- this.stack.unshift(new State("forward"));
1926
- await this.render(children);
1927
- await this.flush();
1928
- await this.bot.internal.modifyChannel(this.stack[0].channel.id, {
1929
- archived: true,
1930
- locked: true
1931
- });
1932
- this.stack.shift();
1933
- } else {
1934
- await this.render(children);
1935
- }
1936
- }
1937
- };
1938
- ((DiscordMessageEncoder2) => {
1939
- DiscordMessageEncoder2.Config = import_satori3.Schema.object({
1940
- handleExternalAsset: import_satori3.Schema.union([
1941
- import_satori3.Schema.const("download").description("先下载后发送"),
1942
- import_satori3.Schema.const("direct").description("直接发送链接"),
1943
- import_satori3.Schema.const("auto").description("发送一个 HEAD 请求,根据返回的 Content-Type 决定发送方式")
1944
- ]).role("radio").description("发送外链资源时采用的方式。").default("auto"),
1945
- handleMixedContent: import_satori3.Schema.union([
1946
- import_satori3.Schema.const("separate").description("将每个不同形式的内容分开发送"),
1947
- import_satori3.Schema.const("attach").description("图片前如果有文本内容,则将文本作为图片的附带信息进行发送"),
1948
- import_satori3.Schema.const("auto").description("如果图片本身采用直接发送则与前面的文本分开,否则将文本作为图片的附带信息发送")
1949
- ]).role("radio").description("发送图文等混合内容时采用的方式。").default("auto")
1950
- }).description("发送设置");
1951
- })(DiscordMessageEncoder || (DiscordMessageEncoder = {}));
1952
-
1953
- // src/ws.ts
1954
- var import_satori4 = require("@satorijs/satori");
1955
- var WsClient = class extends import_satori4.Adapter.WsClient {
1956
- static {
1957
- __name(this, "WsClient");
1958
- }
1959
- _d = 0;
1960
- _ping;
1961
- _sessionId = "";
1962
- _resumeUrl;
1963
- async prepare() {
1964
- if (this._resumeUrl) {
1965
- return this.bot.http.ws(this._resumeUrl + "/?v=10&encoding=json");
1966
- }
1967
- const { url } = await this.bot.internal.getGatewayBot();
1968
- return this.bot.http.ws(url + "/?v=10&encoding=json");
1969
- }
1970
- heartbeat() {
1971
- this.bot.logger.debug(`heartbeat d ${this._d}`);
1972
- this.socket.send(JSON.stringify({
1973
- op: Gateway.Opcode.HEARTBEAT,
1974
- d: this._d
1975
- }));
1976
- }
1977
- accept() {
1978
- this.socket.addEventListener("message", async ({ data }) => {
1979
- let parsed;
1980
- data = data.toString();
1981
- try {
1982
- parsed = JSON.parse(data);
1983
- } catch (error) {
1984
- return this.bot.logger.warn("cannot parse message", data);
1985
- }
1986
- this.bot.logger.debug(parsed);
1987
- if (parsed.s) {
1988
- this._d = parsed.s;
1989
- }
1990
- if (parsed.op === Gateway.Opcode.HELLO) {
1991
- this._ping = setInterval(() => this.heartbeat(), parsed.d.heartbeat_interval);
1992
- if (this._sessionId) {
1993
- this.bot.logger.debug("resuming");
1994
- this.socket.send(JSON.stringify({
1995
- op: Gateway.Opcode.RESUME,
1996
- d: {
1997
- token: this.bot.config.token,
1998
- session_id: this._sessionId,
1999
- seq: this._d
2000
- }
2001
- }));
2002
- } else {
2003
- this.socket.send(JSON.stringify({
2004
- op: Gateway.Opcode.IDENTIFY,
2005
- d: {
2006
- token: this.bot.config.token,
2007
- properties: {},
2008
- compress: false,
2009
- intents: this.bot.config.intents
2010
- }
2011
- }));
2012
- }
2013
- }
2014
- if (parsed.op === Gateway.Opcode.INVALID_SESSION) {
2015
- if (parsed.d)
2016
- return;
2017
- this._sessionId = "";
2018
- this.bot.logger.warn("offline: invalid session");
2019
- this.socket?.close();
2020
- }
2021
- if (parsed.op === Gateway.Opcode.DISPATCH) {
2022
- this.bot.dispatch(this.bot.session({
2023
- type: "internal",
2024
- _type: "discord/" + parsed.t.toLowerCase().replace(/_/g, "-"),
2025
- _data: parsed.d
2026
- }));
2027
- if (parsed.t === "READY") {
2028
- this._sessionId = parsed.d.session_id;
2029
- this._resumeUrl = parsed.d.resume_gateway_url;
2030
- this.bot.user = decodeUser(parsed.d.user);
2031
- this.bot.logger.debug("session_id " + this._sessionId);
2032
- return this.bot.online();
2033
- }
2034
- if (parsed.t === "RESUMED") {
2035
- return this.bot.online();
2036
- }
2037
- const session = await adaptSession(this.bot, parsed);
2038
- if (session)
2039
- this.bot.dispatch(session);
2040
- }
2041
- if (parsed.op === Gateway.Opcode.RECONNECT) {
2042
- this.bot.logger.warn("offline: discord request reconnect");
2043
- this.socket?.close();
2044
- }
2045
- });
2046
- this.socket.addEventListener("close", () => {
2047
- clearInterval(this._ping);
2048
- });
2049
- }
2050
- };
2051
- ((WsClient2) => {
2052
- WsClient2.Options = import_satori4.Schema.intersect([
2053
- import_satori4.Schema.object({
2054
- intents: import_satori4.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)
2055
- }).description("推送设置"),
2056
- import_satori4.Adapter.WsClientConfig
2057
- ]);
2058
- })(WsClient || (WsClient = {}));
2059
-
2060
- // src/bot.ts
2061
- var import_package = require("../package.json");
2062
- var DiscordBot = class extends import_satori5.Bot {
2063
- static {
2064
- __name(this, "DiscordBot");
2065
- }
2066
- static MessageEncoder = DiscordMessageEncoder;
2067
- static inject = ["http"];
2068
- http;
2069
- internal;
2070
- webhooks = {};
2071
- webhookLock = {};
2072
- commands = [];
2073
- constructor(ctx, config) {
2074
- super(ctx, config, "discord");
2075
- this.http = ctx.http.extend({
2076
- ...config,
2077
- headers: {
2078
- Authorization: `Bot ${config.token}`,
2079
- "User-Agent": `Koishi (https://koishi.chat/, ${import_package.version})`,
2080
- ...config.headers
2081
- }
2082
- });
2083
- this.internal = new Internal(this);
2084
- ctx.plugin(WsClient, this);
2085
- }
2086
- async _ensureWebhook(channelId) {
2087
- let webhook;
2088
- const webhooks = await this.internal.getChannelWebhooks(channelId);
2089
- const selfId = this.selfId;
2090
- if (!webhooks.find((v) => v.name === "Koishi" && v.user.id === selfId)) {
2091
- webhook = await this.internal.createWebhook(channelId, {
2092
- name: "Koishi"
2093
- });
2094
- } else {
2095
- webhook = webhooks.find((v) => v.name === "Koishi" && v.user.id === this.selfId);
2096
- }
2097
- return this.webhooks[channelId] = webhook;
2098
- }
2099
- async ensureWebhook(channelId) {
2100
- if (this.webhooks[channelId] === null) {
2101
- delete this.webhooks[channelId];
2102
- delete this.webhookLock[channelId];
2103
- }
2104
- if (this.webhooks[channelId]) {
2105
- delete this.webhookLock[channelId];
2106
- return this.webhooks[channelId];
2107
- }
2108
- return this.webhookLock[channelId] ||= this._ensureWebhook(channelId);
2109
- }
2110
- async getLogin() {
2111
- const data = await this.internal.getCurrentUser();
2112
- this.user = decodeUser(data);
2113
- return this.toJSON();
2114
- }
2115
- async deleteMessage(channelId, messageId) {
2116
- await this.internal.deleteMessage(channelId, messageId);
2117
- }
2118
- async editMessage(channelId, messageId, content) {
2119
- const elements = import_satori5.h.normalize(content);
2120
- content = elements.toString();
2121
- const image = elements.find((v) => v.type === "img" || v.type === "image");
2122
- if (image) {
2123
- throw new Error("You can't include embed object(s) while editing message.");
2124
- }
2125
- await this.internal.editMessage(channelId, messageId, {
2126
- content
2127
- });
2128
- }
2129
- async getMessage(channelId, messageId, recursive = true) {
2130
- const data = await this.internal.getChannelMessage(channelId, messageId);
2131
- return await decodeMessage(this, data, {}, void 0, recursive);
2132
- }
2133
- async getMessageList(channelId, before) {
2134
- const messages = await this.internal.getChannelMessages(channelId, { before, limit: 100 });
2135
- const data = await Promise.all(messages.reverse().map((data2) => decodeMessage(this, data2, {}, void 0, false)));
2136
- return { data, next: data[0]?.id };
2137
- }
2138
- async getUser(userId) {
2139
- const data = await this.internal.getUser(userId);
2140
- return decodeUser(data);
2141
- }
2142
- async getGuildMemberList(guildId, after) {
2143
- const users = await this.internal.listGuildMembers(guildId, { after, limit: 1e3 });
2144
- const data = users.map((v) => decodeGuildMember(v));
2145
- return { data, next: data[999]?.user.id };
2146
- }
2147
- async getChannel(channelId) {
2148
- const data = await this.internal.getChannel(channelId);
2149
- return decodeChannel(data);
2150
- }
2151
- async getGuildMember(guildId, userId) {
2152
- const member = await this.internal.getGuildMember(guildId, userId);
2153
- return decodeGuildMember(member);
2154
- }
2155
- async kickGuildMember(guildId, userId) {
2156
- return this.internal.removeGuildMember(guildId, userId);
2157
- }
2158
- async getGuild(guildId) {
2159
- const data = await this.internal.getGuild(guildId);
2160
- return decodeGuild(data);
2161
- }
2162
- async getGuildList(after) {
2163
- const guilds = await this.internal.getCurrentUserGuilds({ after, limit: 200 });
2164
- const data = guilds.map(decodeGuild);
2165
- return { data, next: data[199]?.id };
2166
- }
2167
- async getChannelList(guildId) {
2168
- const channels = await this.internal.getGuildChannels(guildId);
2169
- return { data: channels.map(decodeChannel) };
2170
- }
2171
- createReaction(channelId, messageId, emoji) {
2172
- return this.internal.createReaction(channelId, messageId, emoji);
2173
- }
2174
- deleteReaction(channelId, messageId, emoji, userId) {
2175
- if (!userId) {
2176
- return this.internal.deleteOwnReaction(channelId, messageId, emoji);
2177
- } else {
2178
- return this.internal.deleteUserReaction(channelId, messageId, emoji, userId);
2179
- }
2180
- }
2181
- clearReaction(channelId, messageId, emoji) {
2182
- if (!emoji) {
2183
- return this.internal.deleteAllReactions(channelId, messageId);
2184
- } else {
2185
- return this.internal.deleteAllReactionsForEmoji(channelId, messageId, emoji);
2186
- }
2187
- }
2188
- async getReactionList(channelId, messageId, emoji, after) {
2189
- const data = await this.internal.getReactions(channelId, messageId, emoji, { after, limit: 100 });
2190
- return { data: data.map(decodeUser), next: data[99]?.id };
2191
- }
2192
- setGuildMemberRole(guildId, userId, roleId) {
2193
- return this.internal.addGuildMemberRole(guildId, userId, roleId);
2194
- }
2195
- unsetGuildMemberRole(guildId, userId, roleId) {
2196
- return this.internal.removeGuildMemberRole(guildId, userId, roleId);
2197
- }
2198
- async getGuildRoleList(guildId) {
2199
- const data = await this.internal.getGuildRoles(guildId);
2200
- return { data: data.map(decodeRole) };
2201
- }
2202
- async createGuildRole(guildId, data) {
2203
- const role = await this.internal.createGuildRole(guildId, encodeRole(data));
2204
- return decodeRole(role);
2205
- }
2206
- async updateGuildRole(guildId, roleId, data) {
2207
- await this.internal.modifyGuildRole(guildId, roleId, encodeRole(data));
2208
- }
2209
- deleteGuildRole(guildId, roleId) {
2210
- return this.internal.deleteGuildRole(guildId, roleId);
2211
- }
2212
- async createDirectChannel(userId) {
2213
- const channel = await this.internal.createDM({ recipient_id: userId });
2214
- return decodeChannel(channel);
2215
- }
2216
- async updateCommands(commands) {
2217
- if (!this.config.slash)
2218
- return;
2219
- this.commands = commands;
2220
- const updates = commands.map(encodeCommand);
2221
- if (updates.length) {
2222
- this.logger.debug("update %d command(s)", updates.length);
2223
- await this.internal.bulkOverwriteGlobalApplicationCommands(this.selfId, updates);
2224
- }
2225
- }
2226
- };
2227
- ((DiscordBot2) => {
2228
- DiscordBot2.Config = import_satori5.Schema.intersect([
2229
- import_satori5.Schema.object({
2230
- token: import_satori5.Schema.string().description("机器人的用户令牌。").role("secret").required()
2231
- }),
2232
- import_satori5.Schema.object({
2233
- slash: import_satori5.Schema.boolean().description("是否启用斜线指令。").default(true)
2234
- }).description("功能设置"),
2235
- WsClient.Options,
2236
- DiscordMessageEncoder.Config,
2237
- import_satori5.Quester.createConfig("https://discord.com/api/v10")
2238
- ]);
2239
- })(DiscordBot || (DiscordBot = {}));
2240
-
2241
- // src/index.ts
2242
- var src_default = DiscordBot;
2243
- // Annotate the CommonJS export names for ESM import in node:
2244
- 0 && (module.exports = {
2245
- Discord,
2246
- DiscordBot,
2247
- DiscordMessageEncoder,
2248
- WsClient
2249
- });
2250
- //# sourceMappingURL=index.js.map