@jnode/discord 1.0.2 → 1.0.4

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.2",
3
+ "version": "1.0.4",
4
4
  "description": "Simple Discord API package for Node.js.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -61,12 +61,12 @@ class DiscordClient {
61
61
  }, (body !== undefined) ? JSON.stringify(body) : undefined); //make an request
62
62
 
63
63
  if ((res.code === 429) && this.apiAutoRetry) { //retry if recieved 429
64
- await delay(res.json.retry_after);
64
+ await delay(res.json().retry_after);
65
65
  return this.apiRequest(method, path, body);
66
66
  }
67
67
 
68
68
  if (((res.code > 299) || (res.code < 200)) && this.apiThrowError) { //throw error if not 2xx
69
- throw new DiscordAPIError(res.code, res.json ?? res.body, res.headers);
69
+ throw new DiscordAPIError(res.code, res.json() ?? res.text(), res.headers);
70
70
  }
71
71
 
72
72
  return res;
@@ -97,12 +97,12 @@ class DiscordClient {
97
97
  }, request.generateMultipartBody(parts)); //make an request
98
98
 
99
99
  if ((res.code === 429) && this.apiAutoRetry) { //retry if recieved 429
100
- await delay(res.json.retry_after);
100
+ await delay(res.json().retry_after);
101
101
  return this.apiRequest(method, path, body, multipart, true);
102
102
  }
103
103
 
104
104
  if (((res.code > 299) || (res.code < 200)) && this.apiThrowError) { //throw error if not 2xx
105
- throw new DiscordAPIError(res.code, res.json ?? res.body, res.headers);
105
+ throw new DiscordAPIError(res.code, res.json() ?? res.text(), res.headers);
106
106
  }
107
107
 
108
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
package/src/index.js CHANGED
@@ -12,6 +12,6 @@ by JustNode Dev Team / JustApple
12
12
  const EventEmitter = require('events');
13
13
 
14
14
  module.exports = {
15
- client: require('./client.js'),
16
- gateway: require('./gateway.js')
15
+ Client: require('./client.js'),
16
+ Gateway: require('./gateway.js')
17
17
  };