@jnode/discord 1.0.10 → 1.0.11

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/client.js +8 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jnode/discord",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Simple Discord API package for Node.js.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -25,6 +25,6 @@
25
25
  "node": ">=22.4.0"
26
26
  },
27
27
  "dependencies": {
28
- "@jnode/request": ">=1.0.4 <2.0.0"
28
+ "@jnode/request": ">=1.1.3 <2.0.0"
29
29
  }
30
30
  }
package/src/client.js CHANGED
@@ -76,25 +76,24 @@ class DiscordClient {
76
76
  async apiRequestMultipart(method = 'GET', path = '/', body, attachments = []) {
77
77
  let parts = [];
78
78
  parts.push({ //json data
79
- disposition: 'name="payload_json"',
80
- contentType: 'application/json',
79
+ disposition: 'form-data; name="payload_json"',
80
+ type: 'application/json',
81
81
  data: JSON.stringify(body)
82
82
  });
83
83
 
84
84
  for (let i = 0; i < attachments.length; i++) { //add every attachment
85
85
  parts.push({
86
- disposition: `name="files[${i}]"; filename="${encodeURIComponent(attachments[i].name)}"`,
87
- contentType: attachments[i].type,
86
+ disposition: `form-data; name="files[${i}]"; filename="${encodeURIComponent(attachments[i].name)}"`,
87
+ type: attachments[i].type,
88
88
  data: attachments[i].data,
89
- encoded: attachments[i].encoded
89
+ base64: attachments[i].encoded
90
90
  });
91
91
  }
92
92
 
93
- const res = await request.request(method, this.apiUrl(path), {
93
+ const res = await request.multipartRequest(method, this.apiUrl(path), {
94
94
  'Authorization': `Bot ${this.token}`,
95
- 'User-Agent': 'DiscordBot',
96
- 'Content-Type': 'multipart/form-data; boundary=----JustRequestFormBoundary'
97
- }, request.generateMultipartBody(parts)); //make an request
95
+ 'User-Agent': 'DiscordBot'
96
+ }, parts); //make an request
98
97
 
99
98
  if ((res.code === 429) && this.apiAutoRetry) { //retry if recieved 429
100
99
  await delay(res.json().retry_after);