@satorijs/adapter-discord 3.6.0 → 3.6.2

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
@@ -288,7 +288,7 @@ var DiscordMessenger = class extends import_satori2.Messenger {
288
288
  }
289
289
  }
290
290
  async sendEmbed(attrs, payload) {
291
- const { filename, data, mime } = await this.bot.ctx.http.file(attrs.url);
291
+ const { filename, data, mime } = await this.bot.ctx.http.file(attrs.url, attrs);
292
292
  const form = new import_form_data.default();
293
293
  const value = process.env.KOISHI_ENV === "browser" ? new Blob([data], { type: mime }) : Buffer.from(data);
294
294
  form.append("file", value, attrs.file || filename);
@@ -318,7 +318,8 @@ var DiscordMessenger = class extends import_satori2.Messenger {
318
318
  return sendDirect();
319
319
  }
320
320
  return await this.bot.ctx.http.head(attrs.url, {
321
- headers: { accept: type + "/*" }
321
+ headers: { accept: type + "/*" },
322
+ timeout: +attrs.timeout || void 0
322
323
  }).then((headers) => {
323
324
  if (headers["content-type"].startsWith(type)) {
324
325
  return sendDirect();
@@ -463,9 +464,10 @@ var DiscordMessenger = class extends import_satori2.Messenger {
463
464
  }
464
465
  const quoted = await this.bot.getMessage(channelId, replyId);
465
466
  this.addition.embeds = [{
466
- description: `${sanitize(parse(quoted.elements.filter((v) => v.type === "text").join("")).slice(0, 30))}
467
-
468
- <t:${Math.ceil(quoted.timestamp / 1e3)}:R> [[ ↑ ]](https://discord.com/channels/${this.guildId}/${channelId}/${replyId})`,
467
+ description: [
468
+ sanitize(parse(quoted.elements.filter((v) => v.type === "text").join("")).slice(0, 30)),
469
+ `<t:${Math.ceil(quoted.timestamp / 1e3)}:R> [[ ↑ ]](https://discord.com/channels/${this.guildId}/${channelId}/${replyId})`
470
+ ].join("\n\n"),
469
471
  author: {
470
472
  name: quoted.author.nickname || quoted.author.username,
471
473
  icon_url: quoted.author.avatar
@@ -1607,10 +1609,10 @@ var WsClient = class extends import_satori4.Adapter.WsClient {
1607
1609
  }
1608
1610
  async prepare() {
1609
1611
  if (this._resumeUrl) {
1610
- return this.bot.http.ws(this._resumeUrl);
1612
+ return this.bot.http.ws(this._resumeUrl + "/?v=10&encoding=json");
1611
1613
  }
1612
1614
  const { url } = await this.bot.internal.getGatewayBot();
1613
- return this.bot.http.ws(url);
1615
+ return this.bot.http.ws(url + "/?v=10&encoding=json");
1614
1616
  }
1615
1617
  heartbeat() {
1616
1618
  logger2.debug(`heartbeat d ${this._d}`);