@satorijs/adapter-discord 3.8.7 → 3.8.8

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
@@ -1575,26 +1575,31 @@ var _DiscordMessageEncoder = class _DiscordMessageEncoder extends import_satori3
1575
1575
  }
1576
1576
  return this.post({ ...addition, content: attrs.url });
1577
1577
  }, "sendDirect");
1578
- const sendDownload = /* @__PURE__ */ __name(() => this.sendEmbed(attrs, addition), "sendDownload");
1579
- if (["file:", "data:", "base64:"].some((prefix) => attrs.url.startsWith(prefix))) {
1580
- return await sendDownload();
1578
+ if (this.bot.http.isPrivate(attrs.url)) {
1579
+ return await this.sendEmbed(attrs, addition);
1581
1580
  }
1582
1581
  const mode = attrs.mode || handleExternalAsset;
1583
1582
  if (mode === "download" || handleMixedContent === "attach" && addition.content || type === "file") {
1584
- return sendDownload();
1583
+ return this.sendEmbed(attrs, addition);
1585
1584
  } else if (mode === "direct") {
1586
1585
  return sendDirect();
1587
1586
  }
1588
- return await this.bot.ctx.http.head(attrs.url, {
1587
+ if (await this.checkMediaType(attrs.url, type)) {
1588
+ return sendDirect();
1589
+ } else {
1590
+ return this.sendEmbed(attrs, addition);
1591
+ }
1592
+ }
1593
+ checkMediaType(url, type) {
1594
+ if (url.startsWith("https://cdn.discordapp.com/"))
1595
+ return true;
1596
+ return this.bot.ctx.http.head(url, {
1589
1597
  headers: { accept: type + "/*" },
1590
- timeout: +attrs.timeout || void 0
1591
- }).then((headers) => {
1592
- if (headers["content-type"].startsWith(type)) {
1593
- return sendDirect();
1594
- } else {
1595
- return sendDownload();
1596
- }
1597
- }, sendDownload);
1598
+ timeout: 1e3
1599
+ }).then(
1600
+ (headers) => headers["content-type"].startsWith(type),
1601
+ () => false
1602
+ );
1598
1603
  }
1599
1604
  async ensureWebhook() {
1600
1605
  return this.bot.ensureWebhook(this.channelId);