@satorijs/adapter-discord 3.1.1 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bot.d.ts +3 -4
- package/lib/index.js +172 -94
- package/lib/index.js.map +4 -4
- package/lib/sender.d.ts +7 -4
- package/lib/types/audit-log.d.ts +65 -1
- package/lib/types/auto-moderation.d.ts +165 -0
- package/lib/types/ban.d.ts +17 -10
- package/lib/types/channel.d.ts +5 -1
- package/lib/types/command.d.ts +28 -10
- package/lib/types/component.d.ts +34 -4
- package/lib/types/gateway.d.ts +48 -2
- package/lib/types/index.d.ts +3 -0
- package/lib/types/interaction.d.ts +16 -3
- package/lib/types/thread.d.ts +9 -1
- package/lib/ws.d.ts +2 -1
- package/package.json +2 -2
package/lib/bot.d.ts
CHANGED
|
@@ -7,13 +7,12 @@ export declare class DiscordBot<C extends Context = Context> extends Bot<C, Disc
|
|
|
7
7
|
internal: Internal;
|
|
8
8
|
constructor(ctx: C, config: DiscordBot.Config);
|
|
9
9
|
getSelf(): Promise<import("@satorijs/core").User>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
sendPrivateMessage(channelId: string, content: string | segment): Promise<string[]>;
|
|
10
|
+
sendMessage(channelId: string, content: string | segment, guildId?: string): any;
|
|
11
|
+
sendPrivateMessage(channelId: string, content: string | segment): any;
|
|
13
12
|
deleteMessage(channelId: string, messageId: string): Promise<void>;
|
|
14
13
|
editMessage(channelId: string, messageId: string, content: string | segment): Promise<void>;
|
|
15
14
|
getMessage(channelId: string, messageId: string): Promise<Message>;
|
|
16
|
-
getMessageList(channelId: string, before?: string):
|
|
15
|
+
getMessageList(channelId: string, before?: string): Promise<Message[]>;
|
|
17
16
|
getUser(userId: string): Promise<import("@satorijs/core").User>;
|
|
18
17
|
getGuildMemberList(guildId: string): Promise<import("@satorijs/core").User[]>;
|
|
19
18
|
getChannel(channelId: string): Promise<import("@satorijs/core").Channel>;
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
|
|
26
|
-
// adapters/discord/src/index.ts
|
|
26
|
+
// satori/adapters/discord/src/index.ts
|
|
27
27
|
var src_exports = {};
|
|
28
28
|
__export(src_exports, {
|
|
29
29
|
Discord: () => types_exports,
|
|
@@ -41,10 +41,10 @@ __export(src_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(src_exports);
|
|
43
43
|
|
|
44
|
-
// adapters/discord/src/bot.ts
|
|
44
|
+
// satori/adapters/discord/src/bot.ts
|
|
45
45
|
var import_satori4 = require("@satorijs/satori");
|
|
46
46
|
|
|
47
|
-
// adapters/discord/src/utils.ts
|
|
47
|
+
// satori/adapters/discord/src/utils.ts
|
|
48
48
|
var import_satori = require("@satorijs/satori");
|
|
49
49
|
var adaptUser = /* @__PURE__ */ __name((user) => ({
|
|
50
50
|
userId: user.id,
|
|
@@ -200,7 +200,7 @@ async function adaptSession(bot, input) {
|
|
|
200
200
|
}
|
|
201
201
|
__name(adaptSession, "adaptSession");
|
|
202
202
|
|
|
203
|
-
// adapters/discord/src/sender.ts
|
|
203
|
+
// satori/adapters/discord/src/sender.ts
|
|
204
204
|
var import_satori2 = require("@satorijs/satori");
|
|
205
205
|
var import_fs = require("fs");
|
|
206
206
|
var import_path = require("path");
|
|
@@ -213,10 +213,8 @@ var Sender = class {
|
|
|
213
213
|
this.url = url;
|
|
214
214
|
this.results = [];
|
|
215
215
|
this.errors = [];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const sender = new Sender(bot, url);
|
|
219
|
-
return sender.sendMessage.bind(sender);
|
|
216
|
+
this.buffer = "";
|
|
217
|
+
this.addition = {};
|
|
220
218
|
}
|
|
221
219
|
async post(data, headers) {
|
|
222
220
|
try {
|
|
@@ -278,52 +276,70 @@ var Sender = class {
|
|
|
278
276
|
}
|
|
279
277
|
}, sendDownload);
|
|
280
278
|
}
|
|
281
|
-
async
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
for (const code of chain) {
|
|
293
|
-
const { type, data } = code;
|
|
279
|
+
async sendBuffer() {
|
|
280
|
+
const content = this.buffer.trim();
|
|
281
|
+
if (!content)
|
|
282
|
+
return;
|
|
283
|
+
await this.post({ ...this.addition, content });
|
|
284
|
+
this.buffer = "";
|
|
285
|
+
this.addition = {};
|
|
286
|
+
}
|
|
287
|
+
async sendMessage(elements) {
|
|
288
|
+
for (const code of elements) {
|
|
289
|
+
const { type, attrs, children } = code;
|
|
294
290
|
if (type === "text") {
|
|
295
|
-
|
|
296
|
-
} else if (type === "at"
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
} else if (type === "
|
|
305
|
-
|
|
306
|
-
} else if (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
291
|
+
this.buffer += attrs.content.trim();
|
|
292
|
+
} else if (type === "at") {
|
|
293
|
+
if (attrs.id) {
|
|
294
|
+
this.buffer += `<@${attrs.id}>`;
|
|
295
|
+
} else if (attrs.type === "all") {
|
|
296
|
+
this.buffer += `@everyone`;
|
|
297
|
+
} else if (attrs.type === "here") {
|
|
298
|
+
this.buffer += `@here`;
|
|
299
|
+
}
|
|
300
|
+
} else if (type === "sharp" && attrs.id) {
|
|
301
|
+
this.buffer += `<#${attrs.id}>`;
|
|
302
|
+
} else if (type === "face" && attrs.name && attrs.id) {
|
|
303
|
+
this.buffer += `<:${attrs.name}:${attrs.id}>`;
|
|
304
|
+
} else if ((type === "image" || type === "video") && attrs.url) {
|
|
305
|
+
await this.sendAsset(type, attrs, {
|
|
306
|
+
...this.addition,
|
|
307
|
+
content: this.buffer.trim()
|
|
310
308
|
});
|
|
311
|
-
|
|
309
|
+
this.buffer = "";
|
|
312
310
|
} else if (type === "share") {
|
|
313
|
-
await sendBuffer();
|
|
311
|
+
await this.sendBuffer();
|
|
314
312
|
await this.post({
|
|
315
|
-
...addition,
|
|
316
|
-
embeds: [{ ...
|
|
313
|
+
...this.addition,
|
|
314
|
+
embeds: [{ ...attrs }]
|
|
317
315
|
});
|
|
318
316
|
} else if (type === "record") {
|
|
319
|
-
await this.sendAsset("file",
|
|
320
|
-
...addition,
|
|
321
|
-
content:
|
|
317
|
+
await this.sendAsset("file", attrs, {
|
|
318
|
+
...this.addition,
|
|
319
|
+
content: this.buffer.trim()
|
|
322
320
|
});
|
|
323
|
-
|
|
321
|
+
this.buffer = "";
|
|
322
|
+
} else if (type === "quote") {
|
|
323
|
+
await this.sendBuffer();
|
|
324
|
+
this.addition.message_reference = {
|
|
325
|
+
message_id: attrs.id
|
|
326
|
+
};
|
|
327
|
+
} else if (type === "message") {
|
|
328
|
+
await this.sendBuffer();
|
|
329
|
+
if ("quote" in attrs) {
|
|
330
|
+
this.addition.message_reference = {
|
|
331
|
+
message_id: attrs.id
|
|
332
|
+
};
|
|
333
|
+
} else {
|
|
334
|
+
await this.sendMessage(children);
|
|
335
|
+
}
|
|
324
336
|
}
|
|
325
337
|
}
|
|
326
|
-
await sendBuffer();
|
|
338
|
+
await this.sendBuffer();
|
|
339
|
+
}
|
|
340
|
+
async send(content) {
|
|
341
|
+
const elements = import_satori2.segment.parse(content);
|
|
342
|
+
await this.sendMessage(elements);
|
|
327
343
|
if (!this.errors.length)
|
|
328
344
|
return this.results;
|
|
329
345
|
throw new import_es_aggregate_error.default(this.errors);
|
|
@@ -345,7 +361,7 @@ __name(Sender, "Sender");
|
|
|
345
361
|
}).description("发送设置");
|
|
346
362
|
})(Sender || (Sender = {}));
|
|
347
363
|
|
|
348
|
-
// adapters/discord/src/types/index.ts
|
|
364
|
+
// satori/adapters/discord/src/types/index.ts
|
|
349
365
|
var types_exports = {};
|
|
350
366
|
__export(types_exports, {
|
|
351
367
|
ActivityFlag: () => ActivityFlag,
|
|
@@ -354,6 +370,8 @@ __export(types_exports, {
|
|
|
354
370
|
ApplicationCommand: () => ApplicationCommand,
|
|
355
371
|
ApplicationFlag: () => ApplicationFlag,
|
|
356
372
|
AuditLog: () => AuditLog,
|
|
373
|
+
AutoModerationAction: () => AutoModerationAction,
|
|
374
|
+
AutoModerationRule: () => AutoModerationRule,
|
|
357
375
|
Channel: () => Channel3,
|
|
358
376
|
ComponentType: () => ComponentType,
|
|
359
377
|
DeviceType: () => DeviceType,
|
|
@@ -374,12 +392,13 @@ __export(types_exports, {
|
|
|
374
392
|
StatusType: () => StatusType2,
|
|
375
393
|
Sticker: () => Sticker3,
|
|
376
394
|
SystemChannelFlag: () => SystemChannelFlag,
|
|
395
|
+
TextInputStyles: () => TextInputStyles,
|
|
377
396
|
UserFlag: () => UserFlag,
|
|
378
397
|
VisibilityType: () => VisibilityType,
|
|
379
398
|
Webhook: () => Webhook2
|
|
380
399
|
});
|
|
381
400
|
|
|
382
|
-
// adapters/discord/src/types/internal.ts
|
|
401
|
+
// satori/adapters/discord/src/types/internal.ts
|
|
383
402
|
var import_cosmokit = require("cosmokit");
|
|
384
403
|
var Internal = class {
|
|
385
404
|
constructor(http) {
|
|
@@ -419,7 +438,7 @@ var Internal = class {
|
|
|
419
438
|
};
|
|
420
439
|
__name(Internal, "Internal");
|
|
421
440
|
|
|
422
|
-
// adapters/discord/src/types/application.ts
|
|
441
|
+
// satori/adapters/discord/src/types/application.ts
|
|
423
442
|
var ApplicationFlag = /* @__PURE__ */ ((ApplicationFlag2) => {
|
|
424
443
|
ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE"] = 4096] = "GATEWAY_PRESENCE";
|
|
425
444
|
ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE_LIMITED"] = 8192] = "GATEWAY_PRESENCE_LIMITED";
|
|
@@ -438,7 +457,7 @@ Internal.define({
|
|
|
438
457
|
}
|
|
439
458
|
});
|
|
440
459
|
|
|
441
|
-
// adapters/discord/src/types/audit-log.ts
|
|
460
|
+
// satori/adapters/discord/src/types/audit-log.ts
|
|
442
461
|
var AuditLog;
|
|
443
462
|
((AuditLog2) => {
|
|
444
463
|
let Type;
|
|
@@ -484,9 +503,19 @@ var AuditLog;
|
|
|
484
503
|
Type2[Type2["STICKER_CREATE"] = 90] = "STICKER_CREATE";
|
|
485
504
|
Type2[Type2["STICKER_UPDATE"] = 91] = "STICKER_UPDATE";
|
|
486
505
|
Type2[Type2["STICKER_DELETE"] = 92] = "STICKER_DELETE";
|
|
506
|
+
Type2[Type2["GUILD_SCHEDULED_EVENT_CREATE"] = 100] = "GUILD_SCHEDULED_EVENT_CREATE";
|
|
507
|
+
Type2[Type2["GUILD_SCHEDULED_EVENT_UPDATE"] = 101] = "GUILD_SCHEDULED_EVENT_UPDATE";
|
|
508
|
+
Type2[Type2["GUILD_SCHEDULED_EVENT_DELETE"] = 102] = "GUILD_SCHEDULED_EVENT_DELETE";
|
|
487
509
|
Type2[Type2["THREAD_CREATE"] = 110] = "THREAD_CREATE";
|
|
488
510
|
Type2[Type2["THREAD_UPDATE"] = 111] = "THREAD_UPDATE";
|
|
489
511
|
Type2[Type2["THREAD_DELETE"] = 112] = "THREAD_DELETE";
|
|
512
|
+
Type2[Type2["APPLICATION_COMMAND_PERMISSION_UPDATE"] = 121] = "APPLICATION_COMMAND_PERMISSION_UPDATE";
|
|
513
|
+
Type2[Type2["AUTO_MODERATION_RULE_CREATE"] = 140] = "AUTO_MODERATION_RULE_CREATE";
|
|
514
|
+
Type2[Type2["AUTO_MODERATION_RULE_UPDATE"] = 141] = "AUTO_MODERATION_RULE_UPDATE";
|
|
515
|
+
Type2[Type2["AUTO_MODERATION_RULE_DELETE"] = 142] = "AUTO_MODERATION_RULE_DELETE";
|
|
516
|
+
Type2[Type2["AUTO_MODERATION_BLOCK_MESSAGE"] = 143] = "AUTO_MODERATION_BLOCK_MESSAGE";
|
|
517
|
+
Type2[Type2["AUTO_MODERATION_FLAG_TO_CHANNEL"] = 144] = "AUTO_MODERATION_FLAG_TO_CHANNEL";
|
|
518
|
+
Type2[Type2["AUTO_MODERATION_USER_COMMUNICATION_DISABLED"] = 145] = "AUTO_MODERATION_USER_COMMUNICATION_DISABLED";
|
|
490
519
|
})(Type = AuditLog2.Type || (AuditLog2.Type = {}));
|
|
491
520
|
})(AuditLog || (AuditLog = {}));
|
|
492
521
|
Internal.define({
|
|
@@ -495,7 +524,49 @@ Internal.define({
|
|
|
495
524
|
}
|
|
496
525
|
});
|
|
497
526
|
|
|
498
|
-
// adapters/discord/src/types/
|
|
527
|
+
// satori/adapters/discord/src/types/auto-moderation.ts
|
|
528
|
+
var AutoModerationRule;
|
|
529
|
+
((AutoModerationRule2) => {
|
|
530
|
+
let EventType;
|
|
531
|
+
((EventType2) => {
|
|
532
|
+
EventType2[EventType2["MESSAGE_SEND"] = 1] = "MESSAGE_SEND";
|
|
533
|
+
})(EventType = AutoModerationRule2.EventType || (AutoModerationRule2.EventType = {}));
|
|
534
|
+
let TriggerType;
|
|
535
|
+
((TriggerType2) => {
|
|
536
|
+
TriggerType2[TriggerType2["KEYWORD"] = 1] = "KEYWORD";
|
|
537
|
+
TriggerType2[TriggerType2["SPAM"] = 3] = "SPAM";
|
|
538
|
+
TriggerType2[TriggerType2["KEYWORD_PRESET"] = 4] = "KEYWORD_PRESET";
|
|
539
|
+
TriggerType2[TriggerType2["MENTION_SPAM"] = 5] = "MENTION_SPAM";
|
|
540
|
+
})(TriggerType = AutoModerationRule2.TriggerType || (AutoModerationRule2.TriggerType = {}));
|
|
541
|
+
let KeywordPresetType;
|
|
542
|
+
((KeywordPresetType2) => {
|
|
543
|
+
KeywordPresetType2[KeywordPresetType2["PROFANITY"] = 1] = "PROFANITY";
|
|
544
|
+
KeywordPresetType2[KeywordPresetType2["SEXUAL_CONTEN"] = 2] = "SEXUAL_CONTEN";
|
|
545
|
+
KeywordPresetType2[KeywordPresetType2["SLURS"] = 3] = "SLURS";
|
|
546
|
+
})(KeywordPresetType = AutoModerationRule2.KeywordPresetType || (AutoModerationRule2.KeywordPresetType = {}));
|
|
547
|
+
})(AutoModerationRule || (AutoModerationRule = {}));
|
|
548
|
+
var AutoModerationAction;
|
|
549
|
+
((AutoModerationAction2) => {
|
|
550
|
+
let Type;
|
|
551
|
+
((Type2) => {
|
|
552
|
+
Type2[Type2["BLOCK_MESSAGE"] = 1] = "BLOCK_MESSAGE";
|
|
553
|
+
Type2[Type2["SEND_ALERT_MESSAGE"] = 2] = "SEND_ALERT_MESSAGE";
|
|
554
|
+
Type2[Type2["TIMEOUT"] = 3] = "TIMEOUT";
|
|
555
|
+
})(Type = AutoModerationAction2.Type || (AutoModerationAction2.Type = {}));
|
|
556
|
+
})(AutoModerationAction || (AutoModerationAction = {}));
|
|
557
|
+
Internal.define({
|
|
558
|
+
"/guilds/{guild.id}/auto-moderation/rules": {
|
|
559
|
+
GET: "listAutoModerationRules",
|
|
560
|
+
POST: "createAutoModerationRule"
|
|
561
|
+
},
|
|
562
|
+
"/guilds/{guild.id}/auto-moderation/rules/{rule.id}": {
|
|
563
|
+
GET: "getAutoModerationRule",
|
|
564
|
+
PATCH: "modifyAutoModerationRule",
|
|
565
|
+
DELETE: "deleteAutoModerationRule"
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
// satori/adapters/discord/src/types/ban.ts
|
|
499
570
|
Internal.define({
|
|
500
571
|
"/guilds/{guild.id}/bans": {
|
|
501
572
|
GET: "getGuildBans"
|
|
@@ -507,7 +578,7 @@ Internal.define({
|
|
|
507
578
|
}
|
|
508
579
|
});
|
|
509
580
|
|
|
510
|
-
// adapters/discord/src/types/channel.ts
|
|
581
|
+
// satori/adapters/discord/src/types/channel.ts
|
|
511
582
|
var Channel3;
|
|
512
583
|
((Channel11) => {
|
|
513
584
|
let Type;
|
|
@@ -523,6 +594,8 @@ var Channel3;
|
|
|
523
594
|
Type2[Type2["GUILD_PUBLIC_THREAD"] = 11] = "GUILD_PUBLIC_THREAD";
|
|
524
595
|
Type2[Type2["GUILD_PRIVATE_THREAD"] = 12] = "GUILD_PRIVATE_THREAD";
|
|
525
596
|
Type2[Type2["GUILD_STAGE_VOICE"] = 13] = "GUILD_STAGE_VOICE";
|
|
597
|
+
Type2[Type2["GUILD_DIRECTORY"] = 14] = "GUILD_DIRECTORY";
|
|
598
|
+
Type2[Type2["GUILD_FORUM"] = 15] = "GUILD_FORUM";
|
|
526
599
|
})(Type = Channel11.Type || (Channel11.Type = {}));
|
|
527
600
|
})(Channel3 || (Channel3 = {}));
|
|
528
601
|
var AllowedMentionType = /* @__PURE__ */ ((AllowedMentionType2) => {
|
|
@@ -565,7 +638,7 @@ Internal.define({
|
|
|
565
638
|
}
|
|
566
639
|
});
|
|
567
640
|
|
|
568
|
-
// adapters/discord/src/types/command.ts
|
|
641
|
+
// satori/adapters/discord/src/types/command.ts
|
|
569
642
|
var ApplicationCommand;
|
|
570
643
|
((ApplicationCommand3) => {
|
|
571
644
|
let Type;
|
|
@@ -591,6 +664,7 @@ var ApplicationCommand;
|
|
|
591
664
|
((PermissionType2) => {
|
|
592
665
|
PermissionType2[PermissionType2["ROLE"] = 1] = "ROLE";
|
|
593
666
|
PermissionType2[PermissionType2["USER"] = 2] = "USER";
|
|
667
|
+
PermissionType2[PermissionType2["CHANNEL"] = 3] = "CHANNEL";
|
|
594
668
|
})(PermissionType = ApplicationCommand3.PermissionType || (ApplicationCommand3.PermissionType = {}));
|
|
595
669
|
})(ApplicationCommand || (ApplicationCommand = {}));
|
|
596
670
|
Internal.define({
|
|
@@ -615,8 +689,7 @@ Internal.define({
|
|
|
615
689
|
DELETE: "deleteGuildApplicationCommand"
|
|
616
690
|
},
|
|
617
691
|
"/applications/{application.id}/guilds/{guild.id}/commands/permissions": {
|
|
618
|
-
GET: "getGuildApplicationCommandPermissions"
|
|
619
|
-
PUT: "batchEditApplicationCommandPermissions"
|
|
692
|
+
GET: "getGuildApplicationCommandPermissions"
|
|
620
693
|
},
|
|
621
694
|
"/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions": {
|
|
622
695
|
GET: "getApplicationCommandPermissions",
|
|
@@ -624,15 +697,21 @@ Internal.define({
|
|
|
624
697
|
}
|
|
625
698
|
});
|
|
626
699
|
|
|
627
|
-
// adapters/discord/src/types/component.ts
|
|
700
|
+
// satori/adapters/discord/src/types/component.ts
|
|
628
701
|
var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
|
|
629
702
|
ComponentType2[ComponentType2["ACTION_ROW"] = 1] = "ACTION_ROW";
|
|
630
703
|
ComponentType2[ComponentType2["BUTTON"] = 2] = "BUTTON";
|
|
631
704
|
ComponentType2[ComponentType2["SELECT_MENU"] = 3] = "SELECT_MENU";
|
|
705
|
+
ComponentType2[ComponentType2["TEXT_INPUT"] = 4] = "TEXT_INPUT";
|
|
632
706
|
return ComponentType2;
|
|
633
707
|
})(ComponentType || {});
|
|
708
|
+
var TextInputStyles = /* @__PURE__ */ ((TextInputStyles2) => {
|
|
709
|
+
TextInputStyles2[TextInputStyles2["SHORT"] = 1] = "SHORT";
|
|
710
|
+
TextInputStyles2[TextInputStyles2["PARAGRAPH"] = 2] = "PARAGRAPH";
|
|
711
|
+
return TextInputStyles2;
|
|
712
|
+
})(TextInputStyles || {});
|
|
634
713
|
|
|
635
|
-
// adapters/discord/src/types/device.ts
|
|
714
|
+
// satori/adapters/discord/src/types/device.ts
|
|
636
715
|
var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
|
|
637
716
|
DeviceType2["AUDIO_INPUT"] = "audioinput";
|
|
638
717
|
DeviceType2["AUDIO_OUTPUT"] = "audiooutput";
|
|
@@ -640,7 +719,7 @@ var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
|
|
|
640
719
|
return DeviceType2;
|
|
641
720
|
})(DeviceType || {});
|
|
642
721
|
|
|
643
|
-
// adapters/discord/src/types/emoji.ts
|
|
722
|
+
// satori/adapters/discord/src/types/emoji.ts
|
|
644
723
|
Internal.define({
|
|
645
724
|
"/guilds/{guild.id}/emojis": {
|
|
646
725
|
GET: "listGuildEmojis",
|
|
@@ -653,7 +732,7 @@ Internal.define({
|
|
|
653
732
|
}
|
|
654
733
|
});
|
|
655
734
|
|
|
656
|
-
// adapters/discord/src/types/gateway.ts
|
|
735
|
+
// satori/adapters/discord/src/types/gateway.ts
|
|
657
736
|
var GatewayOpcode = /* @__PURE__ */ ((GatewayOpcode2) => {
|
|
658
737
|
GatewayOpcode2[GatewayOpcode2["DISPATCH"] = 0] = "DISPATCH";
|
|
659
738
|
GatewayOpcode2[GatewayOpcode2["HEARTBEAT"] = 1] = "HEARTBEAT";
|
|
@@ -684,6 +763,10 @@ var GatewayIntent = /* @__PURE__ */ ((GatewayIntent2) => {
|
|
|
684
763
|
GatewayIntent2[GatewayIntent2["DIRECT_MESSAGES"] = 4096] = "DIRECT_MESSAGES";
|
|
685
764
|
GatewayIntent2[GatewayIntent2["DIRECT_MESSAGE_REACTIONS"] = 8192] = "DIRECT_MESSAGE_REACTIONS";
|
|
686
765
|
GatewayIntent2[GatewayIntent2["DIRECT_MESSAGE_TYPING"] = 16384] = "DIRECT_MESSAGE_TYPING";
|
|
766
|
+
GatewayIntent2[GatewayIntent2["MESSAGE_CONTENT"] = 32768] = "MESSAGE_CONTENT";
|
|
767
|
+
GatewayIntent2[GatewayIntent2["GUILD_SCHEDULED_EVENTS"] = 65536] = "GUILD_SCHEDULED_EVENTS";
|
|
768
|
+
GatewayIntent2[GatewayIntent2["AUTO_MODERATION_CONFIGURATION"] = 131072] = "AUTO_MODERATION_CONFIGURATION";
|
|
769
|
+
GatewayIntent2[GatewayIntent2["AUTO_MODERATION_EXECUTION"] = 262144] = "AUTO_MODERATION_EXECUTION";
|
|
687
770
|
return GatewayIntent2;
|
|
688
771
|
})(GatewayIntent || {});
|
|
689
772
|
Internal.define({
|
|
@@ -695,7 +778,7 @@ Internal.define({
|
|
|
695
778
|
}
|
|
696
779
|
});
|
|
697
780
|
|
|
698
|
-
// adapters/discord/src/types/guild-member.ts
|
|
781
|
+
// satori/adapters/discord/src/types/guild-member.ts
|
|
699
782
|
Internal.define({
|
|
700
783
|
"/guilds/{guild.id}/members/{user.id}": {
|
|
701
784
|
GET: "getGuildMember",
|
|
@@ -722,7 +805,7 @@ Internal.define({
|
|
|
722
805
|
}
|
|
723
806
|
});
|
|
724
807
|
|
|
725
|
-
// adapters/discord/src/types/guild-template.ts
|
|
808
|
+
// satori/adapters/discord/src/types/guild-template.ts
|
|
726
809
|
Internal.define({
|
|
727
810
|
"/guilds/templates/{template.code}": {
|
|
728
811
|
GET: "getGuildTemplate",
|
|
@@ -739,7 +822,7 @@ Internal.define({
|
|
|
739
822
|
}
|
|
740
823
|
});
|
|
741
824
|
|
|
742
|
-
// adapters/discord/src/types/guild.ts
|
|
825
|
+
// satori/adapters/discord/src/types/guild.ts
|
|
743
826
|
var Guild4;
|
|
744
827
|
((Guild7) => {
|
|
745
828
|
let Params;
|
|
@@ -824,7 +907,7 @@ Internal.define({
|
|
|
824
907
|
}
|
|
825
908
|
});
|
|
826
909
|
|
|
827
|
-
// adapters/discord/src/types/integration.ts
|
|
910
|
+
// satori/adapters/discord/src/types/integration.ts
|
|
828
911
|
var IntegrationExpireBehavior = /* @__PURE__ */ ((IntegrationExpireBehavior2) => {
|
|
829
912
|
IntegrationExpireBehavior2[IntegrationExpireBehavior2["REMOVE_ROLE"] = 0] = "REMOVE_ROLE";
|
|
830
913
|
IntegrationExpireBehavior2[IntegrationExpireBehavior2["KICK"] = 1] = "KICK";
|
|
@@ -839,7 +922,7 @@ Internal.define({
|
|
|
839
922
|
}
|
|
840
923
|
});
|
|
841
924
|
|
|
842
|
-
// adapters/discord/src/types/interaction.ts
|
|
925
|
+
// satori/adapters/discord/src/types/interaction.ts
|
|
843
926
|
var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
|
|
844
927
|
InteractionType2[InteractionType2["PING"] = 1] = "PING";
|
|
845
928
|
InteractionType2[InteractionType2["APPLICATION_COMMAND"] = 2] = "APPLICATION_COMMAND";
|
|
@@ -852,6 +935,8 @@ var InteractionCallbackType = /* @__PURE__ */ ((InteractionCallbackType2) => {
|
|
|
852
935
|
InteractionCallbackType2[InteractionCallbackType2["DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE"] = 5] = "DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE";
|
|
853
936
|
InteractionCallbackType2[InteractionCallbackType2["DEFERRED_UPDATE_MESSAGE"] = 6] = "DEFERRED_UPDATE_MESSAGE";
|
|
854
937
|
InteractionCallbackType2[InteractionCallbackType2["UPDATE_MESSAGE"] = 7] = "UPDATE_MESSAGE";
|
|
938
|
+
InteractionCallbackType2[InteractionCallbackType2["APPLICATION_COMMAND_AUTOCOMPLETE_RESULT"] = 8] = "APPLICATION_COMMAND_AUTOCOMPLETE_RESULT";
|
|
939
|
+
InteractionCallbackType2[InteractionCallbackType2["MODAL"] = 9] = "MODAL";
|
|
855
940
|
return InteractionCallbackType2;
|
|
856
941
|
})(InteractionCallbackType || {});
|
|
857
942
|
var InteractionCallbackDataFlag = /* @__PURE__ */ ((InteractionCallbackDataFlag2) => {
|
|
@@ -877,7 +962,7 @@ Internal.define({
|
|
|
877
962
|
}
|
|
878
963
|
});
|
|
879
964
|
|
|
880
|
-
// adapters/discord/src/types/invite.ts
|
|
965
|
+
// satori/adapters/discord/src/types/invite.ts
|
|
881
966
|
var Invite;
|
|
882
967
|
((Invite2) => {
|
|
883
968
|
let TargetType;
|
|
@@ -903,7 +988,7 @@ Internal.define({
|
|
|
903
988
|
}
|
|
904
989
|
});
|
|
905
990
|
|
|
906
|
-
// adapters/discord/src/types/message.ts
|
|
991
|
+
// satori/adapters/discord/src/types/message.ts
|
|
907
992
|
var Message3;
|
|
908
993
|
((Message6) => {
|
|
909
994
|
let Type;
|
|
@@ -976,7 +1061,7 @@ Internal.define({
|
|
|
976
1061
|
}
|
|
977
1062
|
});
|
|
978
1063
|
|
|
979
|
-
// adapters/discord/src/types/presence.ts
|
|
1064
|
+
// satori/adapters/discord/src/types/presence.ts
|
|
980
1065
|
var StatusType2 = /* @__PURE__ */ ((StatusType3) => {
|
|
981
1066
|
StatusType3["ONLINE"] = "ONLINE";
|
|
982
1067
|
StatusType3["DND"] = "DND";
|
|
@@ -1004,7 +1089,7 @@ var ActivityFlag = /* @__PURE__ */ ((ActivityFlag2) => {
|
|
|
1004
1089
|
return ActivityFlag2;
|
|
1005
1090
|
})(ActivityFlag || {});
|
|
1006
1091
|
|
|
1007
|
-
// adapters/discord/src/types/reaction.ts
|
|
1092
|
+
// satori/adapters/discord/src/types/reaction.ts
|
|
1008
1093
|
Internal.define({
|
|
1009
1094
|
"/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me": {
|
|
1010
1095
|
PUT: "createReaction",
|
|
@@ -1022,7 +1107,7 @@ Internal.define({
|
|
|
1022
1107
|
}
|
|
1023
1108
|
});
|
|
1024
1109
|
|
|
1025
|
-
// adapters/discord/src/types/role.ts
|
|
1110
|
+
// satori/adapters/discord/src/types/role.ts
|
|
1026
1111
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
1027
1112
|
Permission2[Permission2["CREATE_INSTANT_INVITE"] = 1] = "CREATE_INSTANT_INVITE";
|
|
1028
1113
|
Permission2[Permission2["KICK_MEMBERS"] = 2] = "KICK_MEMBERS";
|
|
@@ -1077,7 +1162,7 @@ Internal.define({
|
|
|
1077
1162
|
}
|
|
1078
1163
|
});
|
|
1079
1164
|
|
|
1080
|
-
// adapters/discord/src/types/scheduled-event.ts
|
|
1165
|
+
// satori/adapters/discord/src/types/scheduled-event.ts
|
|
1081
1166
|
var GuildScheduledEvent;
|
|
1082
1167
|
((GuildScheduledEvent2) => {
|
|
1083
1168
|
let PrivacyLevel;
|
|
@@ -1113,7 +1198,7 @@ Internal.define({
|
|
|
1113
1198
|
}
|
|
1114
1199
|
});
|
|
1115
1200
|
|
|
1116
|
-
// adapters/discord/src/types/stage-instance.ts
|
|
1201
|
+
// satori/adapters/discord/src/types/stage-instance.ts
|
|
1117
1202
|
Internal.define({
|
|
1118
1203
|
"/stage-instances": {
|
|
1119
1204
|
POST: "createStageInstance"
|
|
@@ -1125,7 +1210,7 @@ Internal.define({
|
|
|
1125
1210
|
}
|
|
1126
1211
|
});
|
|
1127
1212
|
|
|
1128
|
-
// adapters/discord/src/types/sticker.ts
|
|
1213
|
+
// satori/adapters/discord/src/types/sticker.ts
|
|
1129
1214
|
var Sticker3;
|
|
1130
1215
|
((Sticker4) => {
|
|
1131
1216
|
let Type;
|
|
@@ -1158,15 +1243,18 @@ Internal.define({
|
|
|
1158
1243
|
}
|
|
1159
1244
|
});
|
|
1160
1245
|
|
|
1161
|
-
// adapters/discord/src/types/team.ts
|
|
1246
|
+
// satori/adapters/discord/src/types/team.ts
|
|
1162
1247
|
var MembershipState = /* @__PURE__ */ ((MembershipState2) => {
|
|
1163
1248
|
MembershipState2[MembershipState2["INVITED"] = 1] = "INVITED";
|
|
1164
1249
|
MembershipState2[MembershipState2["ACCEPTED"] = 2] = "ACCEPTED";
|
|
1165
1250
|
return MembershipState2;
|
|
1166
1251
|
})(MembershipState || {});
|
|
1167
1252
|
|
|
1168
|
-
// adapters/discord/src/types/thread.ts
|
|
1253
|
+
// satori/adapters/discord/src/types/thread.ts
|
|
1169
1254
|
Internal.define({
|
|
1255
|
+
"/guilds/{guild.id}/threads/active": {
|
|
1256
|
+
GET: "listActiveGuildThreads"
|
|
1257
|
+
},
|
|
1170
1258
|
"/channels/{channel.id}/messages/{message.id}/threads": {
|
|
1171
1259
|
POST: "startThreadwithMessage"
|
|
1172
1260
|
},
|
|
@@ -1199,7 +1287,7 @@ Internal.define({
|
|
|
1199
1287
|
}
|
|
1200
1288
|
});
|
|
1201
1289
|
|
|
1202
|
-
// adapters/discord/src/types/user.ts
|
|
1290
|
+
// satori/adapters/discord/src/types/user.ts
|
|
1203
1291
|
var UserFlag = /* @__PURE__ */ ((UserFlag2) => {
|
|
1204
1292
|
UserFlag2[UserFlag2["NONE"] = 0] = "NONE";
|
|
1205
1293
|
UserFlag2[UserFlag2["DISCORD_EMPLOYEE"] = 1] = "DISCORD_EMPLOYEE";
|
|
@@ -1235,7 +1323,7 @@ Internal.define({
|
|
|
1235
1323
|
}
|
|
1236
1324
|
});
|
|
1237
1325
|
|
|
1238
|
-
// adapters/discord/src/types/voice.ts
|
|
1326
|
+
// satori/adapters/discord/src/types/voice.ts
|
|
1239
1327
|
Internal.define({
|
|
1240
1328
|
"/voice/regions": {
|
|
1241
1329
|
GET: "listVoiceRegions"
|
|
@@ -1251,7 +1339,7 @@ Internal.define({
|
|
|
1251
1339
|
}
|
|
1252
1340
|
});
|
|
1253
1341
|
|
|
1254
|
-
// adapters/discord/src/types/webhook.ts
|
|
1342
|
+
// satori/adapters/discord/src/types/webhook.ts
|
|
1255
1343
|
var Webhook2;
|
|
1256
1344
|
((Webhook3) => {
|
|
1257
1345
|
let Type;
|
|
@@ -1293,7 +1381,7 @@ Internal.define({
|
|
|
1293
1381
|
}
|
|
1294
1382
|
});
|
|
1295
1383
|
|
|
1296
|
-
// adapters/discord/src/ws.ts
|
|
1384
|
+
// satori/adapters/discord/src/ws.ts
|
|
1297
1385
|
var import_satori3 = require("@satorijs/satori");
|
|
1298
1386
|
var logger = new import_satori3.Logger("discord");
|
|
1299
1387
|
var WsClient = class extends import_satori3.Adapter.WsClient {
|
|
@@ -1374,14 +1462,14 @@ __name(WsClient, "WsClient");
|
|
|
1374
1462
|
((WsClient2) => {
|
|
1375
1463
|
WsClient2.Config = import_satori3.Schema.intersect([
|
|
1376
1464
|
import_satori3.Schema.object({
|
|
1377
|
-
gateway: import_satori3.Schema.string().default("wss://gateway.discord.gg/?v=
|
|
1378
|
-
intents: import_satori3.Schema.bitset(GatewayIntent).description("需要订阅的机器人事件。").default(0 | 512 /* GUILD_MESSAGES */ | 1024 /* GUILD_MESSAGE_REACTIONS */ | 4096 /* DIRECT_MESSAGES */ | 8192 /* DIRECT_MESSAGE_REACTIONS */)
|
|
1465
|
+
gateway: import_satori3.Schema.string().default("wss://gateway.discord.gg/?v=10&encoding=json").description("要连接的 WebSocket 网关。"),
|
|
1466
|
+
intents: import_satori3.Schema.bitset(GatewayIntent).description("需要订阅的机器人事件。").default(0 | 512 /* GUILD_MESSAGES */ | 1024 /* GUILD_MESSAGE_REACTIONS */ | 4096 /* DIRECT_MESSAGES */ | 8192 /* DIRECT_MESSAGE_REACTIONS */ | 32768 /* MESSAGE_CONTENT */)
|
|
1379
1467
|
}).description("推送设置"),
|
|
1380
1468
|
import_satori3.Adapter.WsClient.Config
|
|
1381
1469
|
]);
|
|
1382
1470
|
})(WsClient || (WsClient = {}));
|
|
1383
1471
|
|
|
1384
|
-
// adapters/discord/src/bot.ts
|
|
1472
|
+
// satori/adapters/discord/src/bot.ts
|
|
1385
1473
|
var DiscordBot = class extends import_satori4.Bot {
|
|
1386
1474
|
constructor(ctx, config) {
|
|
1387
1475
|
super(ctx, config);
|
|
@@ -1399,11 +1487,6 @@ var DiscordBot = class extends import_satori4.Bot {
|
|
|
1399
1487
|
const data = await this.internal.getCurrentUser();
|
|
1400
1488
|
return adaptUser(data);
|
|
1401
1489
|
}
|
|
1402
|
-
parseQuote(chain) {
|
|
1403
|
-
if (chain[0].type !== "quote")
|
|
1404
|
-
return;
|
|
1405
|
-
return chain.shift().attrs.id;
|
|
1406
|
-
}
|
|
1407
1490
|
async sendMessage(channelId, content, guildId) {
|
|
1408
1491
|
const fragment = import_satori4.segment.normalize(content);
|
|
1409
1492
|
const elements = fragment.children;
|
|
@@ -1421,13 +1504,8 @@ var DiscordBot = class extends import_satori4.Bot {
|
|
|
1421
1504
|
return;
|
|
1422
1505
|
if (!(session == null ? void 0 : session.content))
|
|
1423
1506
|
return [];
|
|
1424
|
-
const
|
|
1425
|
-
const
|
|
1426
|
-
const message_reference = quote ? {
|
|
1427
|
-
message_id: quote
|
|
1428
|
-
} : void 0;
|
|
1429
|
-
const send = Sender.from(this, `/channels/${channelId}/messages`);
|
|
1430
|
-
const results = await send(session.content, { message_reference });
|
|
1507
|
+
const sender = new Sender(this, `/channels/${channelId}/messages`);
|
|
1508
|
+
const results = await sender.send(session.content);
|
|
1431
1509
|
for (const id of results) {
|
|
1432
1510
|
session.messageId = id;
|
|
1433
1511
|
this.context.emit(session, "send", session);
|
|
@@ -1503,12 +1581,12 @@ __name(DiscordBot, "DiscordBot");
|
|
|
1503
1581
|
}),
|
|
1504
1582
|
WsClient.Config,
|
|
1505
1583
|
Sender.Config,
|
|
1506
|
-
import_satori4.Quester.createConfig("https://discord.com/api/
|
|
1584
|
+
import_satori4.Quester.createConfig("https://discord.com/api/v10")
|
|
1507
1585
|
]);
|
|
1508
1586
|
})(DiscordBot || (DiscordBot = {}));
|
|
1509
1587
|
DiscordBot.prototype.platform = "discord";
|
|
1510
1588
|
|
|
1511
|
-
// adapters/discord/src/index.ts
|
|
1589
|
+
// satori/adapters/discord/src/index.ts
|
|
1512
1590
|
var src_default = DiscordBot;
|
|
1513
1591
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1514
1592
|
0 && (module.exports = {
|