@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 +18 -13
- package/lib/index.js.map +2 -2
- package/lib/message.d.ts +1 -0
- package/package.json +2 -2
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
|
-
|
|
1579
|
-
|
|
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
|
|
1583
|
+
return this.sendEmbed(attrs, addition);
|
|
1585
1584
|
} else if (mode === "direct") {
|
|
1586
1585
|
return sendDirect();
|
|
1587
1586
|
}
|
|
1588
|
-
|
|
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:
|
|
1591
|
-
}).then(
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
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);
|