@satorijs/adapter-discord 3.2.3 → 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,13 +200,17 @@ 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
- var import_es_aggregate_error = __toESM(require("es-aggregate-error"));
207
+ var AggregateError = class extends Error {
208
+ constructor(errors, message = "") {
209
+ super(message);
210
+ this.errors = errors;
211
+ }
212
+ };
213
+ __name(AggregateError, "AggregateError");
210
214
  var Sender = class {
211
215
  constructor(bot, url) {
212
216
  this.bot = bot;
@@ -240,12 +244,9 @@ var Sender = class {
240
244
  await this.post(addition);
241
245
  addition.content = "";
242
246
  }
243
- if (data.url.startsWith("file://")) {
244
- const filename = (0, import_path.basename)(data.url.slice(7));
245
- return await this.sendEmbed((0, import_fs.readFileSync)(data.url.slice(7)), addition, data.file || filename);
246
- } else if (data.url.startsWith("base64://")) {
247
- const a = Buffer.from(data.url.slice(9), "base64");
248
- 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);
249
250
  }
250
251
  const sendDirect = /* @__PURE__ */ __name(async () => {
251
252
  if (addition.content) {
@@ -346,7 +347,7 @@ var Sender = class {
346
347
  await this.sendMessage(elements);
347
348
  if (!this.errors.length)
348
349
  return this.results;
349
- throw new import_es_aggregate_error.default(this.errors);
350
+ throw new AggregateError(this.errors);
350
351
  }
351
352
  };
352
353
  __name(Sender, "Sender");
@@ -365,7 +366,7 @@ __name(Sender, "Sender");
365
366
  }).description("发送设置");
366
367
  })(Sender || (Sender = {}));
367
368
 
368
- // satori/adapters/discord/src/types/index.ts
369
+ // adapters/discord/src/types/index.ts
369
370
  var types_exports = {};
370
371
  __export(types_exports, {
371
372
  ActivityFlag: () => ActivityFlag,
@@ -402,7 +403,7 @@ __export(types_exports, {
402
403
  Webhook: () => Webhook2
403
404
  });
404
405
 
405
- // satori/adapters/discord/src/types/internal.ts
406
+ // adapters/discord/src/types/internal.ts
406
407
  var import_cosmokit = require("cosmokit");
407
408
  var Internal = class {
408
409
  constructor(http) {
@@ -442,7 +443,7 @@ var Internal = class {
442
443
  };
443
444
  __name(Internal, "Internal");
444
445
 
445
- // satori/adapters/discord/src/types/application.ts
446
+ // adapters/discord/src/types/application.ts
446
447
  var ApplicationFlag = /* @__PURE__ */ ((ApplicationFlag2) => {
447
448
  ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE"] = 4096] = "GATEWAY_PRESENCE";
448
449
  ApplicationFlag2[ApplicationFlag2["GATEWAY_PRESENCE_LIMITED"] = 8192] = "GATEWAY_PRESENCE_LIMITED";
@@ -461,7 +462,7 @@ Internal.define({
461
462
  }
462
463
  });
463
464
 
464
- // satori/adapters/discord/src/types/audit-log.ts
465
+ // adapters/discord/src/types/audit-log.ts
465
466
  var AuditLog;
466
467
  ((AuditLog2) => {
467
468
  let Type;
@@ -528,7 +529,7 @@ Internal.define({
528
529
  }
529
530
  });
530
531
 
531
- // satori/adapters/discord/src/types/auto-moderation.ts
532
+ // adapters/discord/src/types/auto-moderation.ts
532
533
  var AutoModerationRule;
533
534
  ((AutoModerationRule2) => {
534
535
  let EventType;
@@ -570,7 +571,7 @@ Internal.define({
570
571
  }
571
572
  });
572
573
 
573
- // satori/adapters/discord/src/types/ban.ts
574
+ // adapters/discord/src/types/ban.ts
574
575
  Internal.define({
575
576
  "/guilds/{guild.id}/bans": {
576
577
  GET: "getGuildBans"
@@ -582,7 +583,7 @@ Internal.define({
582
583
  }
583
584
  });
584
585
 
585
- // satori/adapters/discord/src/types/channel.ts
586
+ // adapters/discord/src/types/channel.ts
586
587
  var Channel3;
587
588
  ((Channel11) => {
588
589
  let Type;
@@ -642,7 +643,7 @@ Internal.define({
642
643
  }
643
644
  });
644
645
 
645
- // satori/adapters/discord/src/types/command.ts
646
+ // adapters/discord/src/types/command.ts
646
647
  var ApplicationCommand;
647
648
  ((ApplicationCommand3) => {
648
649
  let Type;
@@ -701,7 +702,7 @@ Internal.define({
701
702
  }
702
703
  });
703
704
 
704
- // satori/adapters/discord/src/types/component.ts
705
+ // adapters/discord/src/types/component.ts
705
706
  var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
706
707
  ComponentType2[ComponentType2["ACTION_ROW"] = 1] = "ACTION_ROW";
707
708
  ComponentType2[ComponentType2["BUTTON"] = 2] = "BUTTON";
@@ -715,7 +716,7 @@ var TextInputStyles = /* @__PURE__ */ ((TextInputStyles2) => {
715
716
  return TextInputStyles2;
716
717
  })(TextInputStyles || {});
717
718
 
718
- // satori/adapters/discord/src/types/device.ts
719
+ // adapters/discord/src/types/device.ts
719
720
  var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
720
721
  DeviceType2["AUDIO_INPUT"] = "audioinput";
721
722
  DeviceType2["AUDIO_OUTPUT"] = "audiooutput";
@@ -723,7 +724,7 @@ var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
723
724
  return DeviceType2;
724
725
  })(DeviceType || {});
725
726
 
726
- // satori/adapters/discord/src/types/emoji.ts
727
+ // adapters/discord/src/types/emoji.ts
727
728
  Internal.define({
728
729
  "/guilds/{guild.id}/emojis": {
729
730
  GET: "listGuildEmojis",
@@ -736,7 +737,7 @@ Internal.define({
736
737
  }
737
738
  });
738
739
 
739
- // satori/adapters/discord/src/types/gateway.ts
740
+ // adapters/discord/src/types/gateway.ts
740
741
  var GatewayOpcode = /* @__PURE__ */ ((GatewayOpcode2) => {
741
742
  GatewayOpcode2[GatewayOpcode2["DISPATCH"] = 0] = "DISPATCH";
742
743
  GatewayOpcode2[GatewayOpcode2["HEARTBEAT"] = 1] = "HEARTBEAT";
@@ -782,7 +783,7 @@ Internal.define({
782
783
  }
783
784
  });
784
785
 
785
- // satori/adapters/discord/src/types/guild-member.ts
786
+ // adapters/discord/src/types/guild-member.ts
786
787
  Internal.define({
787
788
  "/guilds/{guild.id}/members/{user.id}": {
788
789
  GET: "getGuildMember",
@@ -809,7 +810,7 @@ Internal.define({
809
810
  }
810
811
  });
811
812
 
812
- // satori/adapters/discord/src/types/guild-template.ts
813
+ // adapters/discord/src/types/guild-template.ts
813
814
  Internal.define({
814
815
  "/guilds/templates/{template.code}": {
815
816
  GET: "getGuildTemplate",
@@ -826,7 +827,7 @@ Internal.define({
826
827
  }
827
828
  });
828
829
 
829
- // satori/adapters/discord/src/types/guild.ts
830
+ // adapters/discord/src/types/guild.ts
830
831
  var Guild4;
831
832
  ((Guild7) => {
832
833
  let Params;
@@ -911,7 +912,7 @@ Internal.define({
911
912
  }
912
913
  });
913
914
 
914
- // satori/adapters/discord/src/types/integration.ts
915
+ // adapters/discord/src/types/integration.ts
915
916
  var IntegrationExpireBehavior = /* @__PURE__ */ ((IntegrationExpireBehavior2) => {
916
917
  IntegrationExpireBehavior2[IntegrationExpireBehavior2["REMOVE_ROLE"] = 0] = "REMOVE_ROLE";
917
918
  IntegrationExpireBehavior2[IntegrationExpireBehavior2["KICK"] = 1] = "KICK";
@@ -926,7 +927,7 @@ Internal.define({
926
927
  }
927
928
  });
928
929
 
929
- // satori/adapters/discord/src/types/interaction.ts
930
+ // adapters/discord/src/types/interaction.ts
930
931
  var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
931
932
  InteractionType2[InteractionType2["PING"] = 1] = "PING";
932
933
  InteractionType2[InteractionType2["APPLICATION_COMMAND"] = 2] = "APPLICATION_COMMAND";
@@ -966,7 +967,7 @@ Internal.define({
966
967
  }
967
968
  });
968
969
 
969
- // satori/adapters/discord/src/types/invite.ts
970
+ // adapters/discord/src/types/invite.ts
970
971
  var Invite;
971
972
  ((Invite2) => {
972
973
  let TargetType;
@@ -992,7 +993,7 @@ Internal.define({
992
993
  }
993
994
  });
994
995
 
995
- // satori/adapters/discord/src/types/message.ts
996
+ // adapters/discord/src/types/message.ts
996
997
  var Message3;
997
998
  ((Message6) => {
998
999
  let Type;
@@ -1065,7 +1066,7 @@ Internal.define({
1065
1066
  }
1066
1067
  });
1067
1068
 
1068
- // satori/adapters/discord/src/types/presence.ts
1069
+ // adapters/discord/src/types/presence.ts
1069
1070
  var StatusType2 = /* @__PURE__ */ ((StatusType3) => {
1070
1071
  StatusType3["ONLINE"] = "ONLINE";
1071
1072
  StatusType3["DND"] = "DND";
@@ -1093,7 +1094,7 @@ var ActivityFlag = /* @__PURE__ */ ((ActivityFlag2) => {
1093
1094
  return ActivityFlag2;
1094
1095
  })(ActivityFlag || {});
1095
1096
 
1096
- // satori/adapters/discord/src/types/reaction.ts
1097
+ // adapters/discord/src/types/reaction.ts
1097
1098
  Internal.define({
1098
1099
  "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me": {
1099
1100
  PUT: "createReaction",
@@ -1111,7 +1112,7 @@ Internal.define({
1111
1112
  }
1112
1113
  });
1113
1114
 
1114
- // satori/adapters/discord/src/types/role.ts
1115
+ // adapters/discord/src/types/role.ts
1115
1116
  var Permission = /* @__PURE__ */ ((Permission2) => {
1116
1117
  Permission2[Permission2["CREATE_INSTANT_INVITE"] = 1] = "CREATE_INSTANT_INVITE";
1117
1118
  Permission2[Permission2["KICK_MEMBERS"] = 2] = "KICK_MEMBERS";
@@ -1166,7 +1167,7 @@ Internal.define({
1166
1167
  }
1167
1168
  });
1168
1169
 
1169
- // satori/adapters/discord/src/types/scheduled-event.ts
1170
+ // adapters/discord/src/types/scheduled-event.ts
1170
1171
  var GuildScheduledEvent;
1171
1172
  ((GuildScheduledEvent2) => {
1172
1173
  let PrivacyLevel;
@@ -1202,7 +1203,7 @@ Internal.define({
1202
1203
  }
1203
1204
  });
1204
1205
 
1205
- // satori/adapters/discord/src/types/stage-instance.ts
1206
+ // adapters/discord/src/types/stage-instance.ts
1206
1207
  Internal.define({
1207
1208
  "/stage-instances": {
1208
1209
  POST: "createStageInstance"
@@ -1214,7 +1215,7 @@ Internal.define({
1214
1215
  }
1215
1216
  });
1216
1217
 
1217
- // satori/adapters/discord/src/types/sticker.ts
1218
+ // adapters/discord/src/types/sticker.ts
1218
1219
  var Sticker3;
1219
1220
  ((Sticker4) => {
1220
1221
  let Type;
@@ -1247,14 +1248,14 @@ Internal.define({
1247
1248
  }
1248
1249
  });
1249
1250
 
1250
- // satori/adapters/discord/src/types/team.ts
1251
+ // adapters/discord/src/types/team.ts
1251
1252
  var MembershipState = /* @__PURE__ */ ((MembershipState2) => {
1252
1253
  MembershipState2[MembershipState2["INVITED"] = 1] = "INVITED";
1253
1254
  MembershipState2[MembershipState2["ACCEPTED"] = 2] = "ACCEPTED";
1254
1255
  return MembershipState2;
1255
1256
  })(MembershipState || {});
1256
1257
 
1257
- // satori/adapters/discord/src/types/thread.ts
1258
+ // adapters/discord/src/types/thread.ts
1258
1259
  Internal.define({
1259
1260
  "/guilds/{guild.id}/threads/active": {
1260
1261
  GET: "listActiveGuildThreads"
@@ -1291,7 +1292,7 @@ Internal.define({
1291
1292
  }
1292
1293
  });
1293
1294
 
1294
- // satori/adapters/discord/src/types/user.ts
1295
+ // adapters/discord/src/types/user.ts
1295
1296
  var UserFlag = /* @__PURE__ */ ((UserFlag2) => {
1296
1297
  UserFlag2[UserFlag2["NONE"] = 0] = "NONE";
1297
1298
  UserFlag2[UserFlag2["DISCORD_EMPLOYEE"] = 1] = "DISCORD_EMPLOYEE";
@@ -1327,7 +1328,7 @@ Internal.define({
1327
1328
  }
1328
1329
  });
1329
1330
 
1330
- // satori/adapters/discord/src/types/voice.ts
1331
+ // adapters/discord/src/types/voice.ts
1331
1332
  Internal.define({
1332
1333
  "/voice/regions": {
1333
1334
  GET: "listVoiceRegions"
@@ -1343,7 +1344,7 @@ Internal.define({
1343
1344
  }
1344
1345
  });
1345
1346
 
1346
- // satori/adapters/discord/src/types/webhook.ts
1347
+ // adapters/discord/src/types/webhook.ts
1347
1348
  var Webhook2;
1348
1349
  ((Webhook3) => {
1349
1350
  let Type;
@@ -1385,7 +1386,7 @@ Internal.define({
1385
1386
  }
1386
1387
  });
1387
1388
 
1388
- // satori/adapters/discord/src/ws.ts
1389
+ // adapters/discord/src/ws.ts
1389
1390
  var import_satori3 = require("@satorijs/satori");
1390
1391
  var logger = new import_satori3.Logger("discord");
1391
1392
  var WsClient = class extends import_satori3.Adapter.WsClient {
@@ -1473,7 +1474,7 @@ __name(WsClient, "WsClient");
1473
1474
  ]);
1474
1475
  })(WsClient || (WsClient = {}));
1475
1476
 
1476
- // satori/adapters/discord/src/bot.ts
1477
+ // adapters/discord/src/bot.ts
1477
1478
  var DiscordBot = class extends import_satori4.Bot {
1478
1479
  constructor(ctx, config) {
1479
1480
  super(ctx, config);
@@ -1590,7 +1591,7 @@ __name(DiscordBot, "DiscordBot");
1590
1591
  })(DiscordBot || (DiscordBot = {}));
1591
1592
  DiscordBot.prototype.platform = "discord";
1592
1593
 
1593
- // satori/adapters/discord/src/index.ts
1594
+ // adapters/discord/src/index.ts
1594
1595
  var src_default = DiscordBot;
1595
1596
  // Annotate the CommonJS export names for ESM import in node:
1596
1597
  0 && (module.exports = {