@jnode/discord 1.0.11 → 1.0.13
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 +7 -1
- package/package.json +1 -1
- package/src/client.js +4 -2
package/README.md
CHANGED
|
@@ -77,7 +77,13 @@ new discord.Client(token, options = {})
|
|
|
77
77
|
- `method`: HTTP method (e.g. `GET`, `POST`, `PUT`, `DELETE`). Default is `GET`.
|
|
78
78
|
- `path`: API endpoint path. Default is `/`. Example: `/channels/123456789/messages`.
|
|
79
79
|
- `body`: Request body data (will be stringified). Example: `{ content: 'Hello, Discord!' }`.
|
|
80
|
-
- `attachments`: An array of attachments, each attachment is an object
|
|
80
|
+
- `attachments`: An array of attachments, each attachment is an object:
|
|
81
|
+
- `name`: Name of the file. Example: `image.png`
|
|
82
|
+
- `type` (Optional): Content type of the data. Defaults to `application/octet-stream`.
|
|
83
|
+
- `data` (Option 1): Data (string or Buffer) of this file.
|
|
84
|
+
- `file` (Option 2): Path to a local file.
|
|
85
|
+
- `encoded`/`base64` (Option 3): base64 encoded data string.
|
|
86
|
+
- `stream` (Option 4): Any readable stream.
|
|
81
87
|
- **Returns**: `Promise<RequestResponse>` - A promise that resolves to a `RequestResponse` object.
|
|
82
88
|
- **Example**:
|
|
83
89
|
```js
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -86,7 +86,9 @@ class DiscordClient {
|
|
|
86
86
|
disposition: `form-data; name="files[${i}]"; filename="${encodeURIComponent(attachments[i].name)}"`,
|
|
87
87
|
type: attachments[i].type,
|
|
88
88
|
data: attachments[i].data,
|
|
89
|
-
base64: attachments[i].encoded
|
|
89
|
+
base64: attachments[i].encoded ?? attachments[i].base64,
|
|
90
|
+
stream: attachments[i].stream,
|
|
91
|
+
file: attachments[i].file
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -110,7 +112,7 @@ class DiscordClient {
|
|
|
110
112
|
async connectGateway(cb) {
|
|
111
113
|
await this.gateway.getGatewayUrl();
|
|
112
114
|
this.gateway.connect();
|
|
113
|
-
cb(this.gateway);
|
|
115
|
+
if (cb) cb(this.gateway);
|
|
114
116
|
return this.gateway;
|
|
115
117
|
}
|
|
116
118
|
}
|