@satorijs/adapter-discord 3.4.0 → 3.4.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/bot.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Bot, Context, Fragment, Quester, Schema } from '@satorijs/satori';
1
+ import { Bot, Context, Fragment, Quester, Schema, SendOptions } from '@satorijs/satori';
2
2
  import { DiscordMessenger } from './message';
3
3
  import { Internal } from './types';
4
4
  import { WsClient } from './ws';
@@ -7,8 +7,8 @@ export declare class DiscordBot extends Bot<DiscordBot.Config> {
7
7
  internal: Internal;
8
8
  constructor(ctx: Context, config: DiscordBot.Config);
9
9
  getSelf(): Promise<import("@satorijs/core").Universal.User>;
10
- sendMessage(channelId: string, content: Fragment, guildId?: string): Promise<string[]>;
11
- sendPrivateMessage(channelId: string, content: Fragment): Promise<string[]>;
10
+ sendMessage(channelId: string, content: Fragment, guildId?: string, options?: SendOptions): Promise<string[]>;
11
+ sendPrivateMessage(channelId: string, content: Fragment, options?: SendOptions): Promise<string[]>;
12
12
  deleteMessage(channelId: string, messageId: string): Promise<void>;
13
13
  editMessage(channelId: string, messageId: string, content: Fragment): Promise<void>;
14
14
  getMessage(channelId: string, messageId: string): Promise<import("@satorijs/core").Universal.Message>;
package/lib/index.js CHANGED
@@ -1435,7 +1435,7 @@ var WsClient = class extends import_satori3.Adapter.WsClient {
1435
1435
  this._sessionId = "";
1436
1436
  }
1437
1437
  prepare() {
1438
- return this.bot.http.ws(this.bot.config.gateway);
1438
+ return this.bot.http.ws(this._resumeUrl || this.bot.config.gateway);
1439
1439
  }
1440
1440
  heartbeat() {
1441
1441
  logger.debug(`heartbeat d ${this._d}`);
@@ -1485,6 +1485,7 @@ var WsClient = class extends import_satori3.Adapter.WsClient {
1485
1485
  if (parsed.op === 0 /* DISPATCH */) {
1486
1486
  if (parsed.t === "READY") {
1487
1487
  this._sessionId = parsed.d.session_id;
1488
+ this._resumeUrl = parsed.d.resume_gateway_url;
1488
1489
  const self = adaptUser(parsed.d.user);
1489
1490
  self.selfId = self.userId;
1490
1491
  delete self.userId;
@@ -1531,11 +1532,11 @@ var DiscordBot = class extends import_satori4.Bot {
1531
1532
  const data = await this.internal.getCurrentUser();
1532
1533
  return adaptUser(data);
1533
1534
  }
1534
- async sendMessage(channelId, content, guildId) {
1535
- return new DiscordMessenger(this, channelId, guildId).send(content);
1535
+ async sendMessage(channelId, content, guildId, options) {
1536
+ return new DiscordMessenger(this, channelId, guildId, options).send(content);
1536
1537
  }
1537
- async sendPrivateMessage(channelId, content) {
1538
- return new DiscordMessenger(this, channelId).send(content);
1538
+ async sendPrivateMessage(channelId, content, options) {
1539
+ return new DiscordMessenger(this, channelId, null, options).send(content);
1539
1540
  }
1540
1541
  async deleteMessage(channelId, messageId) {
1541
1542
  await this.internal.deleteMessage(channelId, messageId);