disgroove 2.2.0 → 2.2.1-dev.64c7abc

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.
@@ -994,7 +994,7 @@ export declare class Client extends EventEmitter {
994
994
  }): Promise<Array<GuildMember>>;
995
995
  /** https://discord.com/developers/docs/topics/gateway-events#update-presence */
996
996
  setPresence(options: {
997
- activity?: Pick<Activity, "name" | "type" | "url" | "state">;
997
+ activities: Array<Pick<Activity, "name" | "type" | "url" | "state">>;
998
998
  status?: StatusTypes;
999
999
  afk?: boolean;
1000
1000
  }): void;
@@ -11,7 +11,7 @@ export declare class Shard {
11
11
  constructor(id: number, client: Client);
12
12
  /** https://discord.com/developers/docs/topics/gateway-events#update-presence */
13
13
  setPresence(options: {
14
- activity?: Pick<Activity, "name" | "type" | "url" | "state">;
14
+ activities?: Array<Pick<Activity, "name" | "type" | "url" | "state">>;
15
15
  status?: StatusTypes;
16
16
  afk?: boolean;
17
17
  }): void;
@@ -48,7 +48,7 @@ class Shard {
48
48
  op: constants_1.GatewayOPCodes.PresenceUpdate,
49
49
  d: {
50
50
  since: options.status === constants_1.StatusTypes.Idle ? Date.now() : null,
51
- activities: options.activity !== undefined ? [options.activity] : null,
51
+ activities: options.activities,
52
52
  status: options.status ?? constants_1.StatusTypes.Online,
53
53
  afk: !!options.afk,
54
54
  },
@@ -105,8 +105,8 @@ class RequestManager {
105
105
  else {
106
106
  const responseJSON = await response.json();
107
107
  reject(responseJSON.code !== 0
108
- ? new utils_1.RESTError(`[${responseJSON.code}] ${responseJSON.message}`)
109
- : new utils_1.HTTPError(`[${response.status}] ${response.statusText}`));
108
+ ? new utils_1.RESTError(responseJSON.code, responseJSON.message, responseJSON.errors, method, endpoint)
109
+ : new utils_1.HTTPError(response.status, response.statusText, method, endpoint));
110
110
  }
111
111
  }
112
112
  else if (response.status === constants_1.HTTPResponseCodes.NoContent) {
@@ -1,10 +1,16 @@
1
+ import type { JSONErrorCodes } from "../constants";
1
2
  export declare class RESTError extends Error {
2
3
  name: string;
3
- constructor(message: string);
4
+ method: string;
5
+ endpoint: string;
6
+ constructor(code: JSONErrorCodes, message: string, errors: Record<string, unknown>, method: string, endpoint: string);
7
+ flattenErrors(errors: Record<string, unknown> | undefined, prefix?: string): string;
4
8
  }
5
9
  export declare class HTTPError extends Error {
6
10
  name: string;
7
- constructor(message: string);
11
+ method: string;
12
+ endpoint: string;
13
+ constructor(status: number, statusText: string, method: string, endpoint: string);
8
14
  }
9
15
  export declare class GatewayError extends Error {
10
16
  name: string;
@@ -3,15 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GatewayError = exports.HTTPError = exports.RESTError = void 0;
4
4
  class RESTError extends Error {
5
5
  name = "RESTError";
6
- constructor(message) {
7
- super(message);
6
+ method;
7
+ endpoint;
8
+ constructor(code, message, errors, method, endpoint) {
9
+ super();
10
+ this.method = method;
11
+ this.endpoint = endpoint;
12
+ this.message = `[${code}] ${message}\n${this.flattenErrors(errors)}`;
13
+ }
14
+ flattenErrors(errors, prefix = "") {
15
+ let result = "";
16
+ if (errors) {
17
+ for (const [key, value] of Object.entries(errors)) {
18
+ if (errors.hasOwnProperty(key)) {
19
+ if (key === "_errors" && Array.isArray(value)) {
20
+ for (const error of value) {
21
+ if (typeof error === "object" &&
22
+ error !== null &&
23
+ "message" in error) {
24
+ result += `${prefix ? `${prefix}: [${error.code}]` : `[${error.code}]`} ${error.message}\n`;
25
+ }
26
+ }
27
+ }
28
+ else if (typeof value === "object" && value !== null) {
29
+ result += this.flattenErrors(value, prefix ? `${prefix}.${key}` : key);
30
+ }
31
+ }
32
+ }
33
+ }
34
+ return result;
8
35
  }
9
36
  }
10
37
  exports.RESTError = RESTError;
11
38
  class HTTPError extends Error {
12
39
  name = "HTTPError";
13
- constructor(message) {
14
- super(message);
40
+ method;
41
+ endpoint;
42
+ constructor(status, statusText, method, endpoint) {
43
+ super();
44
+ this.method = method;
45
+ this.endpoint = endpoint;
46
+ this.message = `[${status}] ${statusText}`;
15
47
  }
16
48
  }
17
49
  exports.HTTPError = HTTPError;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disgroove",
3
- "version": "2.2.0",
3
+ "version": "2.2.1-dev.64c7abc",
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.0",
3
+ "version": "2.2.1-dev.64c7abc",
4
4
  "description": "A module to interface with Discord",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",