@jnode/discord 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jnode/discord",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Simple Discord API package for Node.js.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -13,7 +13,6 @@ const request = require('@jnode/request');
13
13
 
14
14
  //load classes and functions
15
15
  const DiscordGateway = require('./gateway.js');
16
- const error = require('./error.js');
17
16
 
18
17
  //error types
19
18
  //errors from Discord API
@@ -62,12 +61,12 @@ class DiscordClient {
62
61
  }, (body !== undefined) ? JSON.stringify(body) : undefined); //make an request
63
62
 
64
63
  if ((res.code === 429) && this.apiAutoRetry) { //retry if recieved 429
65
- await delay(res.json.retry_after);
64
+ await delay(res.json().retry_after);
66
65
  return this.apiRequest(method, path, body);
67
66
  }
68
67
 
69
68
  if (((res.code > 299) || (res.code < 200)) && this.apiThrowError) { //throw error if not 2xx
70
- throw new DiscordAPIError(res.code, res.json ?? res.body, res.headers);
69
+ throw new DiscordAPIError(res.code, res.json() ?? res.text(), res.headers);
71
70
  }
72
71
 
73
72
  return res;
@@ -98,12 +97,12 @@ class DiscordClient {
98
97
  }, request.generateMultipartBody(parts)); //make an request
99
98
 
100
99
  if ((res.code === 429) && this.apiAutoRetry) { //retry if recieved 429
101
- await delay(res.json.retry_after);
100
+ await delay(res.json().retry_after);
102
101
  return this.apiRequest(method, path, body, multipart, true);
103
102
  }
104
103
 
105
104
  if (((res.code > 299) || (res.code < 200)) && this.apiThrowError) { //throw error if not 2xx
106
- throw new DiscordAPIError(res.code, res.json ?? res.body, res.headers);
105
+ throw new DiscordAPIError(res.code, res.json() ?? res.text(), res.headers);
107
106
  }
108
107
 
109
108
  return res;
package/src/gateway.js CHANGED
@@ -28,9 +28,9 @@ class DiscordGateway extends EventEmitter {
28
28
  //get gateway url from api
29
29
  async getGatewayUrl() {
30
30
  const res = await this.client.apiRequest('GET', '/gateway/bot'); //make an api request
31
- this.client.gatewayUrl = res.json.url;
32
- this.client.gatewayOriginalUrl = res.json.url;
33
- return res.json.url;
31
+ this.client.gatewayUrl = res.json().url;
32
+ this.client.gatewayOriginalUrl = res.json().url;
33
+ return res.json().url;
34
34
  }
35
35
 
36
36
  //connect to gateway