disgroove 2.2.2-dev.4aafdf4 → 2.2.2-dev.db6cb16

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/README.md CHANGED
@@ -26,7 +26,9 @@ const {
26
26
  MessageFlags,
27
27
  } = require("disgroove");
28
28
  const client = new Client("B0t.T0k3N", {
29
- intents: GatewayIntents.All,
29
+ gateway: {
30
+ intents: GatewayIntents.All,
31
+ },
30
32
  });
31
33
 
32
34
  client.once("ready", () => {
@@ -28,13 +28,23 @@ import type { Sticker, StickerPack } from "./types/sticker";
28
28
  import type { User, ApplicationRoleConnection, Connection } from "./types/user";
29
29
  import type { VoiceRegion, VoiceState } from "./types/voice";
30
30
  import type { Webhook } from "./types/webhook";
31
+ import type { ClientOptions as WebSocketOptions } from "ws";
31
32
  export interface ClientOptions {
32
- intents?: number | Array<number>;
33
33
  shardsCount?: number | "auto";
34
34
  auth?: "Bot" | "Bearer";
35
+ gateway?: {
36
+ intents?: number | Array<number>;
37
+ compress?: boolean;
38
+ largeThreshold?: number;
39
+ presence?: Partial<Pick<GatewayPresenceUpdate, "activities" | "status" | "afk">>;
40
+ };
41
+ ws?: WebSocketOptions;
35
42
  }
36
43
  export declare class Client extends EventEmitter {
37
44
  token: string;
45
+ compress?: boolean;
46
+ largeThreshold?: number;
47
+ presence?: Partial<Pick<GatewayPresenceUpdate, "activities" | "status" | "afk">>;
38
48
  intents: GatewayIntents | number;
39
49
  shardsCount: number | "auto";
40
50
  auth: "Bot" | "Bearer";
@@ -42,9 +52,10 @@ export declare class Client extends EventEmitter {
42
52
  rest: RequestManager;
43
53
  util: Util;
44
54
  guildShardMap: Record<string, number>;
45
- user: User;
55
+ user: User | null;
46
56
  guilds: Map<string, Guild>;
47
- application: Pick<Application, "id" | "flags">;
57
+ application: Pick<Application, "id" | "flags"> | null;
58
+ ws?: WebSocketOptions;
48
59
  constructor(token: string, options?: ClientOptions);
49
60
  /** https://discord.com/developers/docs/resources/channel#group-dm-add-recipient */
50
61
  addGroupRecipient(channelID: snowflake, userID: snowflake, options: {
@@ -68,7 +79,6 @@ export declare class Client extends EventEmitter {
68
79
  days: number;
69
80
  computePruneCount: boolean;
70
81
  includeRoles: Array<snowflake>;
71
- reason?: string;
72
82
  }, reason?: string): Promise<{
73
83
  pruned: number;
74
84
  }>;
@@ -1001,7 +1011,7 @@ export declare class Client extends EventEmitter {
1001
1011
  /** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
1002
1012
  updateApplicationRoleConnectionMetadataRecords(applicationID: snowflake): Promise<Array<ApplicationRoleConnectionMetadata>>;
1003
1013
  /** https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection */
1004
- updateCurrentApplicationRoleConnection(options: {
1014
+ updateCurrentApplicationRoleConnection(applicationID: snowflake, options: {
1005
1015
  platformName?: string;
1006
1016
  platformUsername?: string;
1007
1017
  metadata?: ApplicationRoleConnectionMetadata;
@@ -11,6 +11,9 @@ const node_events_1 = __importDefault(require("node:events"));
11
11
  const gateway_1 = require("./gateway");
12
12
  class Client extends node_events_1.default {
13
13
  token;
14
+ compress;
15
+ largeThreshold;
16
+ presence;
14
17
  intents;
15
18
  shardsCount;
16
19
  auth;
@@ -21,14 +24,22 @@ class Client extends node_events_1.default {
21
24
  user;
22
25
  guilds;
23
26
  application;
27
+ ws;
24
28
  constructor(token, options) {
25
29
  super();
26
30
  this.token = token;
31
+ this.compress = options?.gateway?.compress;
32
+ this.largeThreshold = options?.gateway?.largeThreshold;
33
+ this.presence = {
34
+ activities: options?.gateway?.presence?.activities,
35
+ status: options?.gateway?.presence?.status ?? constants_1.StatusTypes.Online,
36
+ afk: !!options?.gateway?.presence?.afk,
37
+ };
27
38
  this.intents =
28
- options?.intents !== undefined
29
- ? Array.isArray(options.intents)
30
- ? options.intents.reduce((sum, num) => sum + num, 0)
31
- : options.intents
39
+ options?.gateway?.intents !== undefined
40
+ ? Array.isArray(options.gateway.intents)
41
+ ? options.gateway.intents.reduce((sum, num) => sum + num, 0)
42
+ : options.gateway.intents
32
43
  : constants_1.GatewayIntents.AllNonPrivileged;
33
44
  this.shardsCount = options?.shardsCount ?? "auto";
34
45
  this.auth = options?.auth ?? "Bot";
@@ -36,7 +47,10 @@ class Client extends node_events_1.default {
36
47
  this.rest = new rest_1.RequestManager(token, this.auth);
37
48
  this.util = new utils_1.Util();
38
49
  this.guildShardMap = {};
50
+ this.user = null;
39
51
  this.guilds = new Map();
52
+ this.application = null;
53
+ this.ws = options?.ws;
40
54
  }
41
55
  /** https://discord.com/developers/docs/resources/channel#group-dm-add-recipient */
42
56
  addGroupRecipient(channelID, userID, options) {
@@ -77,7 +91,6 @@ class Client extends node_events_1.default {
77
91
  days: options.days,
78
92
  compute_prune_count: options.computePruneCount,
79
93
  include_roles: options.includeRoles,
80
- reason: options.reason,
81
94
  },
82
95
  reason,
83
96
  });
@@ -1987,9 +2000,9 @@ class Client extends node_events_1.default {
1987
2000
  }
1988
2001
  /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
1989
2002
  joinVoiceChannel(guildID, channelID, options) {
1990
- this.shards.get(this.guildShardMap[guildID])?.updateVoiceState({
1991
- guildID: guildID,
1992
- channelID: channelID,
2003
+ this.shards.get(this.guildShardMap[guildID]).updateVoiceState({
2004
+ guildID,
2005
+ channelID,
1993
2006
  selfMute: !!options?.selfMute,
1994
2007
  selfDeaf: !!options?.selfDeaf,
1995
2008
  });
@@ -2004,8 +2017,8 @@ class Client extends node_events_1.default {
2004
2017
  }
2005
2018
  /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
2006
2019
  leaveVoiceChannel(guildID) {
2007
- this.shards.get(this.guildShardMap[guildID])?.updateVoiceState({
2008
- guildID: guildID,
2020
+ this.shards.get(this.guildShardMap[guildID]).updateVoiceState({
2021
+ guildID,
2009
2022
  channelID: null,
2010
2023
  selfMute: false,
2011
2024
  selfDeaf: false,
@@ -2079,8 +2092,8 @@ class Client extends node_events_1.default {
2079
2092
  }));
2080
2093
  }
2081
2094
  /** https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection */
2082
- async updateCurrentApplicationRoleConnection(options) {
2083
- const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.userApplicationRoleConnection(this.application.id), {
2095
+ async updateCurrentApplicationRoleConnection(applicationID, options) {
2096
+ const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.userApplicationRoleConnection(applicationID), {
2084
2097
  json: {
2085
2098
  platform_name: options.platformName,
2086
2099
  platform_username: options.platformUsername,
@@ -6,7 +6,7 @@ export declare class Shard {
6
6
  private heartbeatInterval;
7
7
  client: Client;
8
8
  ws: WebSocket;
9
- sessionID: string;
9
+ sessionID: string | null;
10
10
  constructor(id: number, client: Client);
11
11
  /** https://discord.com/developers/docs/topics/gateway#connections */
12
12
  connect(): void;
@@ -39,8 +39,10 @@ class Shard {
39
39
  sessionID;
40
40
  constructor(id, client) {
41
41
  this.id = id;
42
+ this.heartbeatInterval = null;
42
43
  this.client = client;
43
- this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json");
44
+ this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json", client.ws);
45
+ this.sessionID = null;
44
46
  }
45
47
  /** https://discord.com/developers/docs/topics/gateway#connections */
46
48
  connect() {
@@ -496,13 +498,22 @@ class Shard {
496
498
  onWebSocketOpen() {
497
499
  this.identify({
498
500
  token: this.client.token,
499
- shard: [this.id, this.client.shardsCount],
500
- intents: this.client.intents,
501
501
  properties: {
502
502
  os: process.platform,
503
503
  browser: pkg.name,
504
504
  device: pkg.name,
505
505
  },
506
+ compress: this.client.compress,
507
+ largeThreshold: this.client.largeThreshold,
508
+ shard: [this.id, this.client.shardsCount],
509
+ presence: this.client.presence !== undefined
510
+ ? {
511
+ activities: this.client.presence.activities,
512
+ status: this.client.presence.status ?? constants_1.StatusTypes.Online,
513
+ afk: !!this.client.presence.afk,
514
+ }
515
+ : undefined,
516
+ intents: this.client.intents,
506
517
  });
507
518
  }
508
519
  onWebSocketMessage(data) {
@@ -12,7 +12,7 @@ export interface RequestData {
12
12
  form?: FormData;
13
13
  files?: Array<File> | null;
14
14
  reason?: string;
15
- query?: Partial<Record<string, string | number | boolean | Array<string>>>;
15
+ query?: Record<string, any>;
16
16
  authorization?: boolean;
17
17
  }
18
18
  /** https://discord.com/developers/docs/reference#error-messages */
@@ -357,7 +357,7 @@ export interface Identify {
357
357
  compress?: boolean;
358
358
  largeThreshold?: number;
359
359
  shard?: [number, number];
360
- presence?: GatewayPresenceUpdate;
360
+ presence?: Partial<Pick<GatewayPresenceUpdate, "activities" | "status" | "afk">>;
361
361
  intents: GatewayIntents;
362
362
  }
363
363
  export interface IdentifyConnectionProperties {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disgroove",
3
- "version": "2.2.2-dev.4aafdf4",
3
+ "version": "2.2.2-dev.db6cb16",
4
4
  "description": "A module to interface with Discord",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disgroove",
3
- "version": "2.2.2-dev.4aafdf4",
3
+ "version": "2.2.2-dev.db6cb16",
4
4
  "description": "A module to interface with Discord",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",