@satorijs/adapter-discord 3.8.3 → 3.8.4

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/bot.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare class DiscordBot extends Bot<DiscordBot.Config> {
11
11
  webhookLock: Record<string, Promise<Webhook>>;
12
12
  commands: Universal.Command[];
13
13
  constructor(ctx: Context, config: DiscordBot.Config);
14
- session(payload?: {}): import("@satorijs/core").Session;
14
+ session(payload?: any, input?: any): import("@satorijs/core").Session;
15
15
  private _ensureWebhook;
16
16
  ensureWebhook(channelId: string): Promise<Discord.Webhook>;
17
17
  getSelf(): Promise<Universal.User>;
package/lib/index.js CHANGED
@@ -1315,7 +1315,7 @@ function setupReaction(session, data) {
1315
1315
  }
1316
1316
  __name(setupReaction, "setupReaction");
1317
1317
  async function adaptSession(bot, input) {
1318
- const session = bot.session();
1318
+ const session = bot.session({}, input);
1319
1319
  if (input.t === "MESSAGE_CREATE") {
1320
1320
  if (input.d.webhook_id) {
1321
1321
  const webhook = await bot.ensureWebhook(input.d.channel_id);
@@ -1489,6 +1489,7 @@ var _DiscordMessageEncoder = class _DiscordMessageEncoder extends import_satori3
1489
1489
  this.addition = {};
1490
1490
  this.figure = null;
1491
1491
  this.mode = "default";
1492
+ this.listType = null;
1492
1493
  }
1493
1494
  async getUrl() {
1494
1495
  var _a, _b, _c, _d;
@@ -1633,8 +1634,30 @@ var _DiscordMessageEncoder = class _DiscordMessageEncoder extends import_satori3
1633
1634
  this.buffer += ` (<${attrs.href}>) `;
1634
1635
  }
1635
1636
  } else if (type === "p") {
1637
+ if (!this.buffer.endsWith("\n"))
1638
+ this.buffer += "\n";
1639
+ await this.render(children);
1640
+ this.buffer += "\n";
1641
+ } else if (type === "blockquote") {
1642
+ if (!this.buffer.endsWith("\n"))
1643
+ this.buffer += "\n";
1644
+ this.buffer += "> ";
1636
1645
  await this.render(children);
1637
1646
  this.buffer += "\n";
1647
+ } else if (type === "ul" || type === "ol") {
1648
+ this.listType = type;
1649
+ await this.render(children);
1650
+ this.listType = null;
1651
+ } else if (type === "li") {
1652
+ if (!this.buffer.endsWith("\n"))
1653
+ this.buffer += "\n";
1654
+ if (this.listType === "ol") {
1655
+ this.buffer += "0. ";
1656
+ } else if (this.listType === "ul") {
1657
+ this.buffer += "- ";
1658
+ }
1659
+ this.render(children);
1660
+ this.buffer += "\n";
1638
1661
  } else if (type === "at") {
1639
1662
  if (attrs.id) {
1640
1663
  this.buffer += `<@${attrs.id}>`;
@@ -1903,8 +1926,8 @@ var _DiscordBot = class _DiscordBot extends import_satori5.Bot {
1903
1926
  this.internal = new Internal(this.http);
1904
1927
  ctx.plugin(WsClient, this);
1905
1928
  }
1906
- session(payload = {}) {
1907
- return (0, import_satori5.defineProperty)(super.session(), "discord", Object.assign(Object.create(this.internal), payload));
1929
+ session(payload, input) {
1930
+ return (0, import_satori5.defineProperty)(super.session(payload), "discord", Object.assign(Object.create(this.internal), input));
1908
1931
  }
1909
1932
  async _ensureWebhook(channelId) {
1910
1933
  let webhook;