disgroove 2.2.2-dev.23938d8 → 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,14 +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 { VoiceConnectionManager } from "./voice";
31
+ import type { ClientOptions as WebSocketOptions } from "ws";
32
32
  export interface ClientOptions {
33
- intents?: number | Array<number>;
34
33
  shardsCount?: number | "auto";
35
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;
36
42
  }
37
43
  export declare class Client extends EventEmitter {
38
44
  token: string;
45
+ compress?: boolean;
46
+ largeThreshold?: number;
47
+ presence?: Partial<Pick<GatewayPresenceUpdate, "activities" | "status" | "afk">>;
39
48
  intents: GatewayIntents | number;
40
49
  shardsCount: number | "auto";
41
50
  auth: "Bot" | "Bearer";
@@ -43,10 +52,10 @@ export declare class Client extends EventEmitter {
43
52
  rest: RequestManager;
44
53
  util: Util;
45
54
  guildShardMap: Record<string, number>;
46
- user: User;
55
+ user: User | null;
47
56
  guilds: Map<string, Guild>;
48
- application: Pick<Application, "id" | "flags">;
49
- voiceConnections: VoiceConnectionManager;
57
+ application: Pick<Application, "id" | "flags"> | null;
58
+ ws?: WebSocketOptions;
50
59
  constructor(token: string, options?: ClientOptions);
51
60
  /** https://discord.com/developers/docs/resources/channel#group-dm-add-recipient */
52
61
  addGroupRecipient(channelID: snowflake, userID: snowflake, options: {
@@ -70,7 +79,6 @@ export declare class Client extends EventEmitter {
70
79
  days: number;
71
80
  computePruneCount: boolean;
72
81
  includeRoles: Array<snowflake>;
73
- reason?: string;
74
82
  }, reason?: string): Promise<{
75
83
  pruned: number;
76
84
  }>;
@@ -1003,7 +1011,7 @@ export declare class Client extends EventEmitter {
1003
1011
  /** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
1004
1012
  updateApplicationRoleConnectionMetadataRecords(applicationID: snowflake): Promise<Array<ApplicationRoleConnectionMetadata>>;
1005
1013
  /** https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection */
1006
- updateCurrentApplicationRoleConnection(options: {
1014
+ updateCurrentApplicationRoleConnection(applicationID: snowflake, options: {
1007
1015
  platformName?: string;
1008
1016
  platformUsername?: string;
1009
1017
  metadata?: ApplicationRoleConnectionMetadata;
@@ -9,9 +9,11 @@ const utils_1 = require("./utils");
9
9
  const rest_1 = require("./rest");
10
10
  const node_events_1 = __importDefault(require("node:events"));
11
11
  const gateway_1 = require("./gateway");
12
- const voice_1 = require("./voice");
13
12
  class Client extends node_events_1.default {
14
13
  token;
14
+ compress;
15
+ largeThreshold;
16
+ presence;
15
17
  intents;
16
18
  shardsCount;
17
19
  auth;
@@ -22,15 +24,22 @@ class Client extends node_events_1.default {
22
24
  user;
23
25
  guilds;
24
26
  application;
25
- voiceConnections;
27
+ ws;
26
28
  constructor(token, options) {
27
29
  super();
28
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
+ };
29
38
  this.intents =
30
- options?.intents !== undefined
31
- ? Array.isArray(options.intents)
32
- ? options.intents.reduce((sum, num) => sum + num, 0)
33
- : 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
34
43
  : constants_1.GatewayIntents.AllNonPrivileged;
35
44
  this.shardsCount = options?.shardsCount ?? "auto";
36
45
  this.auth = options?.auth ?? "Bot";
@@ -38,8 +47,10 @@ class Client extends node_events_1.default {
38
47
  this.rest = new rest_1.RequestManager(token, this.auth);
39
48
  this.util = new utils_1.Util();
40
49
  this.guildShardMap = {};
50
+ this.user = null;
41
51
  this.guilds = new Map();
42
- this.voiceConnections = new voice_1.VoiceConnectionManager();
52
+ this.application = null;
53
+ this.ws = options?.ws;
43
54
  }
44
55
  /** https://discord.com/developers/docs/resources/channel#group-dm-add-recipient */
45
56
  addGroupRecipient(channelID, userID, options) {
@@ -80,7 +91,6 @@ class Client extends node_events_1.default {
80
91
  days: options.days,
81
92
  compute_prune_count: options.computePruneCount,
82
93
  include_roles: options.includeRoles,
83
- reason: options.reason,
84
94
  },
85
95
  reason,
86
96
  });
@@ -1990,9 +2000,9 @@ class Client extends node_events_1.default {
1990
2000
  }
1991
2001
  /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
1992
2002
  joinVoiceChannel(guildID, channelID, options) {
1993
- this.shards.get(this.guildShardMap[guildID])?.updateVoiceState({
1994
- guildID: guildID,
1995
- channelID: channelID,
2003
+ this.shards.get(this.guildShardMap[guildID]).updateVoiceState({
2004
+ guildID,
2005
+ channelID,
1996
2006
  selfMute: !!options?.selfMute,
1997
2007
  selfDeaf: !!options?.selfDeaf,
1998
2008
  });
@@ -2007,9 +2017,8 @@ class Client extends node_events_1.default {
2007
2017
  }
2008
2018
  /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
2009
2019
  leaveVoiceChannel(guildID) {
2010
- this.voiceConnections.disconnect(guildID);
2011
- this.shards.get(this.guildShardMap[guildID])?.updateVoiceState({
2012
- guildID: guildID,
2020
+ this.shards.get(this.guildShardMap[guildID]).updateVoiceState({
2021
+ guildID,
2013
2022
  channelID: null,
2014
2023
  selfMute: false,
2015
2024
  selfDeaf: false,
@@ -2083,8 +2092,8 @@ class Client extends node_events_1.default {
2083
2092
  }));
2084
2093
  }
2085
2094
  /** https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection */
2086
- async updateCurrentApplicationRoleConnection(options) {
2087
- 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), {
2088
2097
  json: {
2089
2098
  platform_name: options.platformName,
2090
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() {
@@ -463,12 +465,6 @@ class Shard {
463
465
  break;
464
466
  case "VOICE_SERVER_UPDATE":
465
467
  {
466
- this.client.voiceConnections.connect(packet.d.endpoint, {
467
- serverID: packet.d.guild_id,
468
- userID: this.client.user.id,
469
- sessionID: this.sessionID,
470
- token: packet.d.token,
471
- });
472
468
  this.client.emit(constants_1.GatewayEvents.VoiceServerUpdate, {
473
469
  token: packet.d.token,
474
470
  guildID: packet.d.guild_id,
@@ -502,13 +498,22 @@ class Shard {
502
498
  onWebSocketOpen() {
503
499
  this.identify({
504
500
  token: this.client.token,
505
- shard: [this.id, this.client.shardsCount],
506
- intents: this.client.intents,
507
501
  properties: {
508
502
  os: process.platform,
509
503
  browser: pkg.name,
510
504
  device: pkg.name,
511
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,
512
517
  });
513
518
  }
514
519
  onWebSocketMessage(data) {
@@ -26,6 +26,5 @@ export * from "./types/user";
26
26
  export * from "./types/voice";
27
27
  export * from "./types/webhook";
28
28
  export * from "./utils";
29
- export * from "./voice";
30
29
  export * from "./Client";
31
30
  export * from "./constants";
package/dist/lib/index.js CHANGED
@@ -42,6 +42,5 @@ __exportStar(require("./types/user"), exports);
42
42
  __exportStar(require("./types/voice"), exports);
43
43
  __exportStar(require("./types/webhook"), exports);
44
44
  __exportStar(require("./utils"), exports);
45
- __exportStar(require("./voice"), exports);
46
45
  __exportStar(require("./Client"), exports);
47
46
  __exportStar(require("./constants"), exports);
@@ -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.23938d8",
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.23938d8",
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",