@satorijs/adapter-discord 3.2.4 → 3.2.5

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 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
- // satori/adapters/discord/src/index.ts
26
+ // 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
- // satori/adapters/discord/src/bot.ts
44
+ // adapters/discord/src/bot.ts
45
45
  var import_satori4 = require("@satorijs/satori");
46
46
 
47
- // satori/adapters/discord/src/utils.ts
47
+ // 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,10 +200,8 @@ async function adaptSession(bot, input) {
200
200
  }
201
201
  __name(adaptSession, "adaptSession");
202
202
 
203
- // satori/adapters/discord/src/sender.ts
203
+ // adapters/discord/src/sender.ts
204
204
  var import_satori2 = require("@satorijs/satori");
205
- var import_fs = require("fs");
206
- var import_path = require("path");
207
205
  var import_file_type = require("file-type");
208
206
  var import_form_data = __toESM(require("form-data"));
209
207
  var AggregateError = class extends Error {
@@ -246,12 +244,9 @@ var Sender = class {
246
244
  await this.post(addition);
247
245
  addition.content = "";
248
246
  }
249
- if (data.url.startsWith("file://")) {
250
- const filename = (0, import_path.basename)(data.url.slice(7));
251
- return await this.sendEmbed((0, import_fs.readFileSync)(data.url.slice(7)), addition, data.file || filename);
252
- } else if (data.url.startsWith("base64://")) {
253
- const a = Buffer.from(data.url.slice(9), "base64");
254
- return await this.sendEmbed(a, addition, data.file);
247
+ if (["file:", "data:", "base64:"].some((prefix) => data.url.startsWith(prefix))) {
248
+ const result = await this.bot.ctx.http.file(data.url);
249
+ return await this.sendEmbed(result.data, addition, data.file || result.filename);
255
250
  }
256
251
  const sendDirect = /* @__PURE__ */ __name(async () => {
257
252
  if (addition.content) {
@@ -371,7 +366,7 @@ __name(Sender, "Sender");
371
366
  }).description("发送设置");
372
367
  })(Sender || (Sender = {}));
373
368
 
374
- // satori/adapters/discord/src/types/index.ts
369
+ // adapters/discord/src/types/index.ts
375
370
  var types_exports = {};
376
371
  __export(types_exports, {
377
372
  ActivityFlag: () => ActivityFlag,
@@ -408,7 +403,7 @@ __export(types_exports, {
408
403
  Webhook: () => Webhook2
409
404
  });
410
405
 
411
- // satori/adapters/discord/src/types/internal.ts
406
+ // adapters/discord/src/types/internal.ts
412
407
  var import_cosmokit = require("cosmokit");
413
408
  var Internal = class {
414
409
  constructor(http) {
@@ -448,7 +443,7 @@ var Internal = class {
448
443
  };
449
444
  __name(Internal, "Internal");
450
445
 
451
- // satori/adapters/discord/src/types/application.ts
446
+ // adapters/discord/src/types/application.ts
452
447
  var ApplicationFlag = /* @__PURE__ */ ((ApplicationFlag2) => {
453
448
  ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE"] = 4096] = "GATEWAY_PRESENCE";
454
449
  ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE_LIMITED"] = 8192] = "GATEWAY_PRESENCE_LIMITED";
@@ -467,7 +462,7 @@ Internal.define({
467
462
  }
468
463
  });
469
464
 
470
- // satori/adapters/discord/src/types/audit-log.ts
465
+ // adapters/discord/src/types/audit-log.ts
471
466
  var AuditLog;
472
467
  ((AuditLog2) => {
473
468
  let Type;
@@ -534,7 +529,7 @@ Internal.define({
534
529
  }
535
530
  });
536
531
 
537
- // satori/adapters/discord/src/types/auto-moderation.ts
532
+ // adapters/discord/src/types/auto-moderation.ts
538
533
  var AutoModerationRule;
539
534
  ((AutoModerationRule2) => {
540
535
  let EventType;
@@ -576,7 +571,7 @@ Internal.define({
576
571
  }
577
572
  });
578
573
 
579
- // satori/adapters/discord/src/types/ban.ts
574
+ // adapters/discord/src/types/ban.ts
580
575
  Internal.define({
581
576
  "/guilds/{guild.id}/bans": {
582
577
  GET: "getGuildBans"
@@ -588,7 +583,7 @@ Internal.define({
588
583
  }
589
584
  });
590
585
 
591
- // satori/adapters/discord/src/types/channel.ts
586
+ // adapters/discord/src/types/channel.ts
592
587
  var Channel3;
593
588
  ((Channel11) => {
594
589
  let Type;
@@ -648,7 +643,7 @@ Internal.define({
648
643
  }
649
644
  });
650
645
 
651
- // satori/adapters/discord/src/types/command.ts
646
+ // adapters/discord/src/types/command.ts
652
647
  var ApplicationCommand;
653
648
  ((ApplicationCommand3) => {
654
649
  let Type;
@@ -707,7 +702,7 @@ Internal.define({
707
702
  }
708
703
  });
709
704
 
710
- // satori/adapters/discord/src/types/component.ts
705
+ // adapters/discord/src/types/component.ts
711
706
  var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
712
707
  ComponentType2[ComponentType2["ACTION_ROW"] = 1] = "ACTION_ROW";
713
708
  ComponentType2[ComponentType2["BUTTON"] = 2] = "BUTTON";
@@ -721,7 +716,7 @@ var TextInputStyles = /* @__PURE__ */ ((TextInputStyles2) => {
721
716
  return TextInputStyles2;
722
717
  })(TextInputStyles || {});
723
718
 
724
- // satori/adapters/discord/src/types/device.ts
719
+ // adapters/discord/src/types/device.ts
725
720
  var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
726
721
  DeviceType2["AUDIO_INPUT"] = "audioinput";
727
722
  DeviceType2["AUDIO_OUTPUT"] = "audiooutput";
@@ -729,7 +724,7 @@ var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
729
724
  return DeviceType2;
730
725
  })(DeviceType || {});
731
726
 
732
- // satori/adapters/discord/src/types/emoji.ts
727
+ // adapters/discord/src/types/emoji.ts
733
728
  Internal.define({
734
729
  "/guilds/{guild.id}/emojis": {
735
730
  GET: "listGuildEmojis",
@@ -742,7 +737,7 @@ Internal.define({
742
737
  }
743
738
  });
744
739
 
745
- // satori/adapters/discord/src/types/gateway.ts
740
+ // adapters/discord/src/types/gateway.ts
746
741
  var GatewayOpcode = /* @__PURE__ */ ((GatewayOpcode2) => {
747
742
  GatewayOpcode2[GatewayOpcode2["DISPATCH"] = 0] = "DISPATCH";
748
743
  GatewayOpcode2[GatewayOpcode2["HEARTBEAT"] = 1] = "HEARTBEAT";
@@ -788,7 +783,7 @@ Internal.define({
788
783
  }
789
784
  });
790
785
 
791
- // satori/adapters/discord/src/types/guild-member.ts
786
+ // adapters/discord/src/types/guild-member.ts
792
787
  Internal.define({
793
788
  "/guilds/{guild.id}/members/{user.id}": {
794
789
  GET: "getGuildMember",
@@ -815,7 +810,7 @@ Internal.define({
815
810
  }
816
811
  });
817
812
 
818
- // satori/adapters/discord/src/types/guild-template.ts
813
+ // adapters/discord/src/types/guild-template.ts
819
814
  Internal.define({
820
815
  "/guilds/templates/{template.code}": {
821
816
  GET: "getGuildTemplate",
@@ -832,7 +827,7 @@ Internal.define({
832
827
  }
833
828
  });
834
829
 
835
- // satori/adapters/discord/src/types/guild.ts
830
+ // adapters/discord/src/types/guild.ts
836
831
  var Guild4;
837
832
  ((Guild7) => {
838
833
  let Params;
@@ -917,7 +912,7 @@ Internal.define({
917
912
  }
918
913
  });
919
914
 
920
- // satori/adapters/discord/src/types/integration.ts
915
+ // adapters/discord/src/types/integration.ts
921
916
  var IntegrationExpireBehavior = /* @__PURE__ */ ((IntegrationExpireBehavior2) => {
922
917
  IntegrationExpireBehavior2[IntegrationExpireBehavior2["REMOVE_ROLE"] = 0] = "REMOVE_ROLE";
923
918
  IntegrationExpireBehavior2[IntegrationExpireBehavior2["KICK"] = 1] = "KICK";
@@ -932,7 +927,7 @@ Internal.define({
932
927
  }
933
928
  });
934
929
 
935
- // satori/adapters/discord/src/types/interaction.ts
930
+ // adapters/discord/src/types/interaction.ts
936
931
  var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
937
932
  InteractionType2[InteractionType2["PING"] = 1] = "PING";
938
933
  InteractionType2[InteractionType2["APPLICATION_COMMAND"] = 2] = "APPLICATION_COMMAND";
@@ -972,7 +967,7 @@ Internal.define({
972
967
  }
973
968
  });
974
969
 
975
- // satori/adapters/discord/src/types/invite.ts
970
+ // adapters/discord/src/types/invite.ts
976
971
  var Invite;
977
972
  ((Invite2) => {
978
973
  let TargetType;
@@ -998,7 +993,7 @@ Internal.define({
998
993
  }
999
994
  });
1000
995
 
1001
- // satori/adapters/discord/src/types/message.ts
996
+ // adapters/discord/src/types/message.ts
1002
997
  var Message3;
1003
998
  ((Message6) => {
1004
999
  let Type;
@@ -1071,7 +1066,7 @@ Internal.define({
1071
1066
  }
1072
1067
  });
1073
1068
 
1074
- // satori/adapters/discord/src/types/presence.ts
1069
+ // adapters/discord/src/types/presence.ts
1075
1070
  var StatusType2 = /* @__PURE__ */ ((StatusType3) => {
1076
1071
  StatusType3["ONLINE"] = "ONLINE";
1077
1072
  StatusType3["DND"] = "DND";
@@ -1099,7 +1094,7 @@ var ActivityFlag = /* @__PURE__ */ ((ActivityFlag2) => {
1099
1094
  return ActivityFlag2;
1100
1095
  })(ActivityFlag || {});
1101
1096
 
1102
- // satori/adapters/discord/src/types/reaction.ts
1097
+ // adapters/discord/src/types/reaction.ts
1103
1098
  Internal.define({
1104
1099
  "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me": {
1105
1100
  PUT: "createReaction",
@@ -1117,7 +1112,7 @@ Internal.define({
1117
1112
  }
1118
1113
  });
1119
1114
 
1120
- // satori/adapters/discord/src/types/role.ts
1115
+ // adapters/discord/src/types/role.ts
1121
1116
  var Permission = /* @__PURE__ */ ((Permission2) => {
1122
1117
  Permission2[Permission2["CREATE_INSTANT_INVITE"] = 1] = "CREATE_INSTANT_INVITE";
1123
1118
  Permission2[Permission2["KICK_MEMBERS"] = 2] = "KICK_MEMBERS";
@@ -1172,7 +1167,7 @@ Internal.define({
1172
1167
  }
1173
1168
  });
1174
1169
 
1175
- // satori/adapters/discord/src/types/scheduled-event.ts
1170
+ // adapters/discord/src/types/scheduled-event.ts
1176
1171
  var GuildScheduledEvent;
1177
1172
  ((GuildScheduledEvent2) => {
1178
1173
  let PrivacyLevel;
@@ -1208,7 +1203,7 @@ Internal.define({
1208
1203
  }
1209
1204
  });
1210
1205
 
1211
- // satori/adapters/discord/src/types/stage-instance.ts
1206
+ // adapters/discord/src/types/stage-instance.ts
1212
1207
  Internal.define({
1213
1208
  "/stage-instances": {
1214
1209
  POST: "createStageInstance"
@@ -1220,7 +1215,7 @@ Internal.define({
1220
1215
  }
1221
1216
  });
1222
1217
 
1223
- // satori/adapters/discord/src/types/sticker.ts
1218
+ // adapters/discord/src/types/sticker.ts
1224
1219
  var Sticker3;
1225
1220
  ((Sticker4) => {
1226
1221
  let Type;
@@ -1253,14 +1248,14 @@ Internal.define({
1253
1248
  }
1254
1249
  });
1255
1250
 
1256
- // satori/adapters/discord/src/types/team.ts
1251
+ // adapters/discord/src/types/team.ts
1257
1252
  var MembershipState = /* @__PURE__ */ ((MembershipState2) => {
1258
1253
  MembershipState2[MembershipState2["INVITED"] = 1] = "INVITED";
1259
1254
  MembershipState2[MembershipState2["ACCEPTED"] = 2] = "ACCEPTED";
1260
1255
  return MembershipState2;
1261
1256
  })(MembershipState || {});
1262
1257
 
1263
- // satori/adapters/discord/src/types/thread.ts
1258
+ // adapters/discord/src/types/thread.ts
1264
1259
  Internal.define({
1265
1260
  "/guilds/{guild.id}/threads/active": {
1266
1261
  GET: "listActiveGuildThreads"
@@ -1297,7 +1292,7 @@ Internal.define({
1297
1292
  }
1298
1293
  });
1299
1294
 
1300
- // satori/adapters/discord/src/types/user.ts
1295
+ // adapters/discord/src/types/user.ts
1301
1296
  var UserFlag = /* @__PURE__ */ ((UserFlag2) => {
1302
1297
  UserFlag2[UserFlag2["NONE"] = 0] = "NONE";
1303
1298
  UserFlag2[UserFlag2["DISCORD_EMPLOYEE"] = 1] = "DISCORD_EMPLOYEE";
@@ -1333,7 +1328,7 @@ Internal.define({
1333
1328
  }
1334
1329
  });
1335
1330
 
1336
- // satori/adapters/discord/src/types/voice.ts
1331
+ // adapters/discord/src/types/voice.ts
1337
1332
  Internal.define({
1338
1333
  "/voice/regions": {
1339
1334
  GET: "listVoiceRegions"
@@ -1349,7 +1344,7 @@ Internal.define({
1349
1344
  }
1350
1345
  });
1351
1346
 
1352
- // satori/adapters/discord/src/types/webhook.ts
1347
+ // adapters/discord/src/types/webhook.ts
1353
1348
  var Webhook2;
1354
1349
  ((Webhook3) => {
1355
1350
  let Type;
@@ -1391,7 +1386,7 @@ Internal.define({
1391
1386
  }
1392
1387
  });
1393
1388
 
1394
- // satori/adapters/discord/src/ws.ts
1389
+ // adapters/discord/src/ws.ts
1395
1390
  var import_satori3 = require("@satorijs/satori");
1396
1391
  var logger = new import_satori3.Logger("discord");
1397
1392
  var WsClient = class extends import_satori3.Adapter.WsClient {
@@ -1479,7 +1474,7 @@ __name(WsClient, "WsClient");
1479
1474
  ]);
1480
1475
  })(WsClient || (WsClient = {}));
1481
1476
 
1482
- // satori/adapters/discord/src/bot.ts
1477
+ // adapters/discord/src/bot.ts
1483
1478
  var DiscordBot = class extends import_satori4.Bot {
1484
1479
  constructor(ctx, config) {
1485
1480
  super(ctx, config);
@@ -1596,7 +1591,7 @@ __name(DiscordBot, "DiscordBot");
1596
1591
  })(DiscordBot || (DiscordBot = {}));
1597
1592
  DiscordBot.prototype.platform = "discord";
1598
1593
 
1599
- // satori/adapters/discord/src/index.ts
1594
+ // adapters/discord/src/index.ts
1600
1595
  var src_default = DiscordBot;
1601
1596
  // Annotate the CommonJS export names for ESM import in node:
1602
1597
  0 && (module.exports = {