snowtransfer 0.17.7 → 0.18.1
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/CHANGELOG.md +60 -0
- package/LICENSE.md +1 -1
- package/README.md +4 -5
- package/dist/Constants.d.ts +59 -0
- package/dist/Constants.js +123 -0
- package/dist/Endpoints.d.ts +120 -0
- package/dist/Endpoints.js +121 -0
- package/dist/RequestHandler.d.ts +258 -0
- package/dist/RequestHandler.js +629 -0
- package/dist/SnowTransfer.d.ts +70 -0
- package/dist/SnowTransfer.js +105 -0
- package/dist/StateMachine.d.ts +89 -0
- package/dist/StateMachine.js +208 -0
- package/dist/StateMachineGraph.d.ts +3 -0
- package/dist/StateMachineGraph.js +23 -0
- package/dist/Types.d.ts +76 -0
- package/dist/Types.js +2 -0
- package/dist/index.d.ts +25 -4102
- package/dist/index.js +63 -46
- package/dist/methods/Assets.d.ts +290 -0
- package/dist/methods/Assets.js +326 -0
- package/dist/methods/AuditLog.d.ts +40 -0
- package/dist/methods/AuditLog.js +44 -0
- package/dist/methods/AutoModeration.d.ts +122 -0
- package/dist/methods/AutoModeration.js +135 -0
- package/dist/methods/Bot.d.ts +65 -0
- package/dist/methods/Bot.js +75 -0
- package/dist/methods/Channel.d.ts +866 -0
- package/dist/methods/Channel.js +982 -0
- package/dist/methods/Entitlements.d.ts +87 -0
- package/dist/methods/Entitlements.js +99 -0
- package/dist/methods/Guild.d.ts +722 -0
- package/dist/methods/Guild.js +785 -0
- package/dist/methods/GuildScheduledEvent.d.ts +138 -0
- package/dist/methods/GuildScheduledEvent.js +155 -0
- package/dist/methods/GuildTemplate.d.ts +110 -0
- package/dist/methods/GuildTemplate.js +124 -0
- package/dist/methods/Interaction.d.ts +339 -0
- package/dist/methods/Interaction.js +359 -0
- package/dist/methods/Invite.d.ts +81 -0
- package/dist/methods/Invite.js +107 -0
- package/dist/methods/Sku.d.ts +58 -0
- package/dist/methods/Sku.js +66 -0
- package/dist/methods/StageInstance.d.ts +86 -0
- package/dist/methods/StageInstance.js +97 -0
- package/dist/methods/User.d.ts +167 -0
- package/dist/methods/User.js +184 -0
- package/dist/methods/Voice.d.ts +44 -0
- package/dist/methods/Voice.js +52 -0
- package/dist/methods/Webhook.d.ts +265 -0
- package/dist/methods/Webhook.js +256 -0
- package/dist/tokenless.d.ts +19 -0
- package/dist/tokenless.js +31 -0
- package/package.json +16 -11
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# 0.18.1
|
|
2
|
+
A few bugs I failed to catch last round. Sorry about that.
|
|
3
|
+
|
|
4
|
+
- Fixed request retries with retryRequests/retryFailed deadlocking the route's rate limit bucket.
|
|
5
|
+
- The retry was enqueued into the same bucket that was blocked waiting for the retry to finish, so the request promise never settled and every later request on that route hung forever. Retries now free the bucket before re-queueing.
|
|
6
|
+
- Retries also now preserve the rawResponse flag. Previously a retried InviteMethods#getInviteTargetUsers would explode because it got parsed JSON instead of a Response.
|
|
7
|
+
- Fixed the baseURL option being silently ignored by the RequestHandler. It's also exposed on the SnowTransfer options now, along with a custom fetch implementation.
|
|
8
|
+
- Requests without a body no longer send the literal string "undefined" as the JSON body (with a Content-Type to match). Discord tolerated it, but yuck.
|
|
9
|
+
- DiscordAPIError#code is now the actual Discord error code (e.g. 10008 Unknown Message) parsed from JSON error bodies instead of always being 4000. Validation error details are still included in the message.
|
|
10
|
+
- Bucket cooldowns now only wait on the counters that are actually exhausted. Previously the wait was the max across all counters, so e.g. reaction routes with a 250ms reset could stall for up to a second on the global counter's window.
|
|
11
|
+
- 400 responses are no longer retried when retryRequests is enabled. Retrying a malformed request was never going to go differently.
|
|
12
|
+
- The hourly bucket sweep no longer deletes buckets that still have queued calls or are mid-cooldown, which could briefly let two buckets for the same route run in parallel.
|
|
13
|
+
- ChannelMethods#createVoiceMessage now uses the configured fetch implementation for the CDN upload, actually checks that the upload succeeded, and uses MessageFlags.IsVoiceMessage instead of a magic number.
|
|
14
|
+
- Query params/data objects passed to methods are no longer mutated (appendQuery deleted undefined keys from your object, createInteractionResponse wrote allowed_mentions into your data).
|
|
15
|
+
- This is now backed by Constants#cloneUserInput, which copies payloads before the library writes to them: plain objects and arrays are deep cloned, while Buffers, Blobs and streams are intentionally shared by reference (copying those is either wasteful or impossible). Your payloads stay reusable across calls and retries.
|
|
16
|
+
- The file property of files now also accepts a factory function returning (or resolving to) a file, and Blob/File are now properly advertised in the method signatures (the form handler always supported them).
|
|
17
|
+
- Streams are single use - once a request consumed one, sending the same payload again would upload nothing. Pass file: () => fs.createReadStream(path) and the factory is called once per materialization, so reusing the payload just works. The new FileInput and SendableFile types document this right where your editor's hover can see it.
|
|
18
|
+
- Fixed multipart uploads crashing with "Received non-Uint8Array chunk" when given a Readable that emits strings (e.g. Readable.from(["text"])). Stream contents are now collected through Blob, which is fine with string and Buffer chunks alike.
|
|
19
|
+
- WebhookMethods#executeWebhook now treats empty embeds/components/files arrays as missing, matching ChannelMethods#createMessage.
|
|
20
|
+
- Fixed the JSDoc example for AssetsMethods#createGuildSticker passing tags as an array - it's a comma separated string.
|
|
21
|
+
- strings added to forms without a filename param route through the overload for strings instead of wrapping them in a Blob
|
|
22
|
+
- Tokens are only considered pre-prefixed if they start with "Bot " or "Bearer " (with the space).
|
|
23
|
+
- Fixed the StateMachine onEnter error message naming the wrong state.
|
|
24
|
+
- Added a test suite (node:test, no new dependencies, `npm test`) covering the ratelimiter/request handler core, request transformations, client-side validation, and pure functions. Deliberately no fixture tests of endpoint wrappers - those only test the mock.
|
|
25
|
+
- Removed dep on broken tsup.
|
|
26
|
+
- This also allows the emitted code to be more readable which eliminates the "need" for a sourcemap.
|
|
27
|
+
- Also fixes needing to use funny naming schemes for imports of classes across different files lest tsup minification for the dts and js would start naming the base class something else entirely and wrap it instead of.. yknow. Using the name the dev defined even though it'd be valid in that context.
|
|
28
|
+
- Removed @protected tag from classes so that they'd be visible in the docs by default.
|
|
29
|
+
|
|
30
|
+
# 0.18.0
|
|
31
|
+
First entry in this changelog. This is a major one - possibly the biggest one save for the js -> ts rewrite. We'll start with the most interesting/impactful.
|
|
32
|
+
|
|
33
|
+
- Consistency changes across the board. This includes method names, code formatting, etc. (I finally updated eslint to v10)
|
|
34
|
+
- This is quite a few breaking changes and makes up a good chunk of this update. The original method names didn't get a redirect to the new ones. Sorry in advance for the migration struggle.
|
|
35
|
+
- I had to struggle migrating Discord.js a few times, don't think this library is safe from the same struggles >:D jk. I think this will be the only time this kinda thing happens.
|
|
36
|
+
- PATCH methods have been changed from a mix of update/edit/??? prefixes to just edit* preferably. Some methods are special snowflakes.
|
|
37
|
+
- DELETE methods have been changed to prefix with delete*
|
|
38
|
+
- Bulk methods like channel bulk delete messages was simplified to deleteMessages. There were more though.
|
|
39
|
+
- SkuMethods#getSkus was SkuMethods#GetSkus (PascalCase instead of camelCase like literally every other method)
|
|
40
|
+
- Found and fixed some actual bugs.
|
|
41
|
+
- GuildScheduledEventMethods#getGuildScheduledEvent and UserMethods#getGuild was accidentally passing the query string params to the JSON body param for the request.
|
|
42
|
+
- IntervalCounter#take would continue to decrement remaining past 0 into the negatives. It would still return false regardless, but this could probably have been problematic in external use cases outside of this lib.
|
|
43
|
+
- request retry logic would go indefinitely instead of decrementing the remaining amount.
|
|
44
|
+
- Removed some types being exported from the package.
|
|
45
|
+
- These types were actually just straight up deleted as discord-api-types added them.
|
|
46
|
+
- Added a generateWaveform function to Constants.
|
|
47
|
+
- This function is supposed to be used for ChannelMethods#createVoiceMessage, but it doesn't do the whole thing for you. Please read the JSDoc for it!
|
|
48
|
+
- Huge thank you to @Lulalaby for her original C# implementation.
|
|
49
|
+
- Removed any lingering references to removeEveryone.
|
|
50
|
+
- Fixed some errors with docs.
|
|
51
|
+
- Some of it was spelling related.
|
|
52
|
+
- Some docs entries had invalid JS in it, so anyone who copy pasted and saw an error... Oops! My bad.
|
|
53
|
+
- Changed some method return types to be from discord-api-types.
|
|
54
|
+
- Previously for HTTP 204 routes, the return type was never, which was incorrect and made some design patterns, specifically mock test writing annoying as you cannot naturally return the type never in JS without unconditionally throwing an Error or calling process.exit()
|
|
55
|
+
- A PR from yours truly changed it to undefined. I had changed them to void locally for a bit and commented out the types from dapi types, but now that's fixed so they're back.
|
|
56
|
+
- VSCode settings deprecated the setting originally used to specify the TS version in editor, so the path was changed.
|
|
57
|
+
- Deleted the old travis.yml
|
|
58
|
+
- Updated the examples.
|
|
59
|
+
- Added a build script that runs both build:src and build:docs.
|
|
60
|
+
- Added a lint script.
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ I've written a general whitepaper on the idea of microservice bots, which you ca
|
|
|
26
26
|
### Documentation:
|
|
27
27
|
You can find the docs at [https://daswolke.github.io/SnowTransfer/](https://daswolke.github.io/SnowTransfer/)
|
|
28
28
|
|
|
29
|
+
For a changelog, read here: [Changelog](./CHANGELOG.md)
|
|
30
|
+
|
|
29
31
|
### Installation:
|
|
30
32
|
To install SnowTransfer, make sure that you have node 22.0.0 or higher and npm installed on your computer.
|
|
31
33
|
|
|
@@ -35,11 +37,8 @@ Then run the following command in a terminal `npm install snowtransfer`
|
|
|
35
37
|
```js
|
|
36
38
|
const { SnowTransfer } = require('snowtransfer');
|
|
37
39
|
const client = new SnowTransfer('DISCORD BOT TOKEN');
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.log(message);
|
|
41
|
-
};
|
|
42
|
-
request().then(() => {
|
|
40
|
+
|
|
41
|
+
client.channel.createMessage('channel id', 'hi there').then(() => {
|
|
43
42
|
// message was sent to discord
|
|
44
43
|
}).catch(e => {
|
|
45
44
|
// an error occurred
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { FileInput } from "./Types";
|
|
2
|
+
declare const Constants: {
|
|
3
|
+
REST_API_VERSION: 10;
|
|
4
|
+
GET_CHANNEL_MESSAGES_MIN_RESULTS: 1;
|
|
5
|
+
GET_CHANNEL_MESSAGES_MAX_RESULTS: 100;
|
|
6
|
+
GET_GUILD_SCHEDULED_EVENT_USERS_MIN_RESULTS: 1;
|
|
7
|
+
GET_GUILD_SCHEDULED_EVENT_USERS_MAX_RESULTS: 100;
|
|
8
|
+
SEARCH_MEMBERS_MIN_RESULTS: 1;
|
|
9
|
+
SEARCH_MEMBERS_MAX_RESULTS: 1000;
|
|
10
|
+
BULK_DELETE_MESSAGES_MIN: 2;
|
|
11
|
+
BULK_DELETE_MESSAGES_MAX: 100;
|
|
12
|
+
OK_STATUS_CODES: Set<number>;
|
|
13
|
+
DO_NOT_RETRY_STATUS_CODES: Set<number>;
|
|
14
|
+
DEFAULT_RETRY_LIMIT: number;
|
|
15
|
+
GLOBAL_REQUESTS_PER_SECOND: number;
|
|
16
|
+
/**
|
|
17
|
+
* Deep clones arrays and plain objects, passing everything else (Buffers, Blobs, streams, class instances) through by reference.
|
|
18
|
+
*
|
|
19
|
+
* Used to copy user supplied payloads before the library writes to them (defaulting allowed_mentions, deleting keys, etc),
|
|
20
|
+
* so the caller's objects stay reusable across calls and are unchanged by retries. Exotic values are intentionally shared,
|
|
21
|
+
* since they are either wasteful (Buffer) or impossible (streams) to copy.
|
|
22
|
+
* @since 0.18.1
|
|
23
|
+
* @param value Value to clone
|
|
24
|
+
*/
|
|
25
|
+
cloneUserInput<T>(value: T): T;
|
|
26
|
+
standardMultipartHandler(data: {
|
|
27
|
+
files: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
file: FileInput;
|
|
30
|
+
}>;
|
|
31
|
+
data?: any;
|
|
32
|
+
}): Promise<FormData>;
|
|
33
|
+
standardAddToFormHandler(form: FormData, name: string, value: string | FileInput, filename?: string): Promise<void>;
|
|
34
|
+
reasonHeader(reason?: string): {
|
|
35
|
+
"X-Audit-Log-Reason"?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Generates a waveform from mono PCM samples
|
|
39
|
+
*
|
|
40
|
+
* Discord expects 1 byte per datapoint (0-255), at most 256 datapoints, base64 encoded.
|
|
41
|
+
* SnowTransfer does not do the whole process of converting the audio Buffer to a waveform string,
|
|
42
|
+
* since doing so properly requires decoding the actual audio (Opus, MP3, AAC, FLAC, ...) into raw PCM samples,
|
|
43
|
+
* and that needs a real audio codec library or an `ffmpeg` binary, neither of which this package depends on.
|
|
44
|
+
*
|
|
45
|
+
* This function just does the important part - chunking samples sequentially in time (not interleaving/round-robin),
|
|
46
|
+
* so each byte represents the amplitude of one time slice of the recording, left to right.
|
|
47
|
+
*
|
|
48
|
+
* To get `pcmSamples` in the first place:
|
|
49
|
+
* WAV is the only format decodable without extra tooling, since it's just a header followed by raw PCM.
|
|
50
|
+
* For Ogg/Opus, MP3, M4A, FLAC, etc., you'll need to decode to PCM first, e.g. by shelling out to ffmpeg
|
|
51
|
+
* (`ffmpeg -i input -f s16le -ac 1 -ar 48000 -`) or using a native/wasm decoder of your choice.
|
|
52
|
+
* prism-media is an option and is the backend of discord.js' voice package for the purpose of converting arbitrary
|
|
53
|
+
* audio formats into PCM for some functionality, like gain modification, to then convert into opus packets for Discord.
|
|
54
|
+
* Though it does depend on ffmpeg for unrecognized formats.
|
|
55
|
+
* @param pcmSamples mono PCM, e.g. Int16 samples in the range -32768..32767
|
|
56
|
+
*/
|
|
57
|
+
generateWaveform(pcmSamples: Array<number>, durationSeconds: number, maxPoints?: number): string;
|
|
58
|
+
};
|
|
59
|
+
export = Constants;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const node_stream_1 = require("node:stream");
|
|
3
|
+
const Constants = {
|
|
4
|
+
REST_API_VERSION: 10,
|
|
5
|
+
GET_CHANNEL_MESSAGES_MIN_RESULTS: 1,
|
|
6
|
+
GET_CHANNEL_MESSAGES_MAX_RESULTS: 100,
|
|
7
|
+
GET_GUILD_SCHEDULED_EVENT_USERS_MIN_RESULTS: 1,
|
|
8
|
+
GET_GUILD_SCHEDULED_EVENT_USERS_MAX_RESULTS: 100,
|
|
9
|
+
SEARCH_MEMBERS_MIN_RESULTS: 1,
|
|
10
|
+
SEARCH_MEMBERS_MAX_RESULTS: 1000,
|
|
11
|
+
BULK_DELETE_MESSAGES_MIN: 2,
|
|
12
|
+
BULK_DELETE_MESSAGES_MAX: 100,
|
|
13
|
+
OK_STATUS_CODES: new Set([200, 201, 204, 304]),
|
|
14
|
+
DO_NOT_RETRY_STATUS_CODES: new Set([400, 401, 403, 404, 405, 411, 413]),
|
|
15
|
+
DEFAULT_RETRY_LIMIT: 3,
|
|
16
|
+
GLOBAL_REQUESTS_PER_SECOND: 50,
|
|
17
|
+
/**
|
|
18
|
+
* Deep clones arrays and plain objects, passing everything else (Buffers, Blobs, streams, class instances) through by reference.
|
|
19
|
+
*
|
|
20
|
+
* Used to copy user supplied payloads before the library writes to them (defaulting allowed_mentions, deleting keys, etc),
|
|
21
|
+
* so the caller's objects stay reusable across calls and are unchanged by retries. Exotic values are intentionally shared,
|
|
22
|
+
* since they are either wasteful (Buffer) or impossible (streams) to copy.
|
|
23
|
+
* @since 0.18.1
|
|
24
|
+
* @param value Value to clone
|
|
25
|
+
*/
|
|
26
|
+
cloneUserInput(value) {
|
|
27
|
+
if (Array.isArray(value))
|
|
28
|
+
return value.map(v => Constants.cloneUserInput(v));
|
|
29
|
+
if (value !== null && typeof value === "object") {
|
|
30
|
+
const proto = Object.getPrototypeOf(value);
|
|
31
|
+
if (proto === Object.prototype || proto === null) {
|
|
32
|
+
const cloned = {};
|
|
33
|
+
for (const [key, v] of Object.entries(value)) {
|
|
34
|
+
cloned[key] = Constants.cloneUserInput(v);
|
|
35
|
+
}
|
|
36
|
+
return cloned;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
},
|
|
41
|
+
async standardMultipartHandler(data) {
|
|
42
|
+
const form = new FormData();
|
|
43
|
+
// Cloned so the deletes below can't spend the caller's payload. File contents are shared by reference, not copied
|
|
44
|
+
const payload = Constants.cloneUserInput(data);
|
|
45
|
+
if (payload.files && Array.isArray(payload.files) && payload.files.every(f => !!f.name && !!f.file)) {
|
|
46
|
+
let index = 0;
|
|
47
|
+
for (const file of payload.files) {
|
|
48
|
+
await Constants.standardAddToFormHandler(form, `files[${index}]`, file.file, file.name);
|
|
49
|
+
// @ts-expect-error Cannot delete non optional, but I have to
|
|
50
|
+
delete file.file;
|
|
51
|
+
index++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// @ts-expect-error Cannot delete non optional, but I have to
|
|
55
|
+
if (payload.data)
|
|
56
|
+
delete payload.files; // Interactions responses are weird, but I need to support it
|
|
57
|
+
form.append("payload_json", JSON.stringify(payload));
|
|
58
|
+
return form;
|
|
59
|
+
},
|
|
60
|
+
async standardAddToFormHandler(form, name, value, filename) {
|
|
61
|
+
// Factories produce a fresh file per materialization, so payloads containing streams can be reused across calls
|
|
62
|
+
if (typeof value === "function")
|
|
63
|
+
value = await value();
|
|
64
|
+
if (typeof value === "string" && !filename)
|
|
65
|
+
form.append(name, value);
|
|
66
|
+
// @ts-expect-error It's a Buffer and it works. If node changes the backend to not accept a plain Buffer, then we can talk
|
|
67
|
+
else if (value instanceof Buffer || typeof value === "string")
|
|
68
|
+
form.append(name, new Blob([value]), filename);
|
|
69
|
+
else if (value instanceof Blob || value instanceof File)
|
|
70
|
+
form.append(name, value, filename);
|
|
71
|
+
// Node Readables may emit string or Buffer chunks; Blob accepts both as parts, unlike Response which only takes bytes
|
|
72
|
+
else if (value instanceof node_stream_1.Readable)
|
|
73
|
+
form.set(name, new Blob(await value.toArray()), filename);
|
|
74
|
+
else if (value instanceof ReadableStream)
|
|
75
|
+
form.set(name, await new Response(value).blob(), filename);
|
|
76
|
+
else
|
|
77
|
+
throw new Error(`Don't know how to add ${value?.constructor?.name ?? typeof value} to form`);
|
|
78
|
+
},
|
|
79
|
+
reasonHeader(reason) {
|
|
80
|
+
return reason ? { "X-Audit-Log-Reason": reason } : {};
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Generates a waveform from mono PCM samples
|
|
84
|
+
*
|
|
85
|
+
* Discord expects 1 byte per datapoint (0-255), at most 256 datapoints, base64 encoded.
|
|
86
|
+
* SnowTransfer does not do the whole process of converting the audio Buffer to a waveform string,
|
|
87
|
+
* since doing so properly requires decoding the actual audio (Opus, MP3, AAC, FLAC, ...) into raw PCM samples,
|
|
88
|
+
* and that needs a real audio codec library or an `ffmpeg` binary, neither of which this package depends on.
|
|
89
|
+
*
|
|
90
|
+
* This function just does the important part - chunking samples sequentially in time (not interleaving/round-robin),
|
|
91
|
+
* so each byte represents the amplitude of one time slice of the recording, left to right.
|
|
92
|
+
*
|
|
93
|
+
* To get `pcmSamples` in the first place:
|
|
94
|
+
* WAV is the only format decodable without extra tooling, since it's just a header followed by raw PCM.
|
|
95
|
+
* For Ogg/Opus, MP3, M4A, FLAC, etc., you'll need to decode to PCM first, e.g. by shelling out to ffmpeg
|
|
96
|
+
* (`ffmpeg -i input -f s16le -ac 1 -ar 48000 -`) or using a native/wasm decoder of your choice.
|
|
97
|
+
* prism-media is an option and is the backend of discord.js' voice package for the purpose of converting arbitrary
|
|
98
|
+
* audio formats into PCM for some functionality, like gain modification, to then convert into opus packets for Discord.
|
|
99
|
+
* Though it does depend on ffmpeg for unrecognized formats.
|
|
100
|
+
* @param pcmSamples mono PCM, e.g. Int16 samples in the range -32768..32767
|
|
101
|
+
*/
|
|
102
|
+
generateWaveform(pcmSamples, durationSeconds, maxPoints = 256) {
|
|
103
|
+
if (maxPoints > 256)
|
|
104
|
+
maxPoints = 256;
|
|
105
|
+
const points = Math.min(maxPoints, Math.ceil(durationSeconds * 10)); // Discord samples at most once per 100ms
|
|
106
|
+
const chunkSize = Math.ceil(pcmSamples.length / points);
|
|
107
|
+
const waveformArr = [];
|
|
108
|
+
for (let i = 0; i < points; i++) {
|
|
109
|
+
const start = i * chunkSize;
|
|
110
|
+
const end = Math.min(start + chunkSize, pcmSamples.length);
|
|
111
|
+
const chunk = pcmSamples.slice(start, end);
|
|
112
|
+
if (chunk.length === 0) {
|
|
113
|
+
waveformArr[i] = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const sumSquares = chunk.reduce((acc, cur) => acc + (cur * cur), 0);
|
|
117
|
+
const rms = Math.sqrt(sumSquares / chunk.length); // root-mean-square amplitude of this chunk
|
|
118
|
+
waveformArr[i] = Math.round((rms / 32768) * 255);
|
|
119
|
+
}
|
|
120
|
+
return Buffer.from(waveformArr).toString("base64");
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
module.exports = Constants;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import Constants = require("./Constants");
|
|
2
|
+
/**
|
|
3
|
+
* Mostly taken from https://github.com/abalabahaha/eris/blob/master/lib/rest/Endpoints.js
|
|
4
|
+
*
|
|
5
|
+
* Removed User-only endpoints
|
|
6
|
+
*/
|
|
7
|
+
declare const Endpoints: {
|
|
8
|
+
BASE_URL: `/api/v${typeof Constants.REST_API_VERSION}`;
|
|
9
|
+
BASE_HOST: "https://discord.com";
|
|
10
|
+
CDN_URL: "https://cdn.discordapp.com";
|
|
11
|
+
APPLICATION_COMMAND: (appId: string, cmdId: string) => `${ReturnType<typeof Endpoints.APPLICATION_COMMANDS>}/{cmd_id}`;
|
|
12
|
+
APPLICATION_COMMANDS: (appId: string) => "/applications/{app_id}/commands";
|
|
13
|
+
APPLICATION_EMOJI: (appId: string, emojiId: string) => `${ReturnType<typeof Endpoints.APPLICATION_EMOJIS>}/{emoji_id}`;
|
|
14
|
+
APPLICATION_EMOJIS: (appId: string) => "/applications/{app_id}/emojis";
|
|
15
|
+
APPLICATION_ENTITLEMENT: (appId: string, entitlementId: string) => `${ReturnType<typeof Endpoints.APPLICATION_ENTITLEMENTS>}/{entitlement_id}`;
|
|
16
|
+
APPLICATION_ENTITLEMENT_CONSUME: (appId: string, entitlementId: string) => `${ReturnType<typeof Endpoints.APPLICATION_ENTITLEMENT>}/consume`;
|
|
17
|
+
APPLICATION_ENTITLEMENTS: (appId: string) => "/applications/{app_id}/entitlements";
|
|
18
|
+
APPLICATION_GUILD_COMMANDS_PERMISSIONS: (appId: string, guildId: string) => `${ReturnType<typeof Endpoints.APPLICATION_GUILD_COMMANDS>}/permissions`;
|
|
19
|
+
APPLICATION_GUILD_COMMAND_PERMISSIONS: (appId: string, guildId: string, cmdId: string) => `${ReturnType<typeof Endpoints.APPLICATION_GUILD_COMMAND>}/permissions`;
|
|
20
|
+
APPLICATION_GUILD_COMMAND: (appId: string, guildId: string, cmdId: string) => `${ReturnType<typeof Endpoints.APPLICATION_GUILD_COMMANDS>}/{cmd_id}`;
|
|
21
|
+
APPLICATION_GUILD_COMMANDS: (appId: string, guildId: string) => "/applications/{app_id}/guilds/{guild_id}/commands";
|
|
22
|
+
APPLICATION_SKUS: (appId: string) => "/applications/{app_id}/skus";
|
|
23
|
+
ATTACHMENTS_REFRESH_URLS: "/attachments/refresh-urls";
|
|
24
|
+
CHANNEL: (chanId: string) => `${typeof Endpoints.CHANNELS}/{channel_id}`;
|
|
25
|
+
CHANNEL_ATTACHMENTS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/attachments`;
|
|
26
|
+
CHANNEL_BULK_DELETE: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL_MESSAGES>}/bulk-delete`;
|
|
27
|
+
CHANNEL_FOLLOWERS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/followers`;
|
|
28
|
+
CHANNEL_INVITES: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/invites`;
|
|
29
|
+
CHANNEL_MESSAGE: (chanId: string, msgId: string) => `${ReturnType<typeof Endpoints.CHANNEL_MESSAGES>}/{message_id}`;
|
|
30
|
+
CHANNEL_MESSAGE_CROSSPOST: (chanId: string, msgId: string) => `${ReturnType<typeof Endpoints.CHANNEL_MESSAGE>}/crosspost`;
|
|
31
|
+
CHANNEL_MESSAGE_REACTION: (chanId: string, msgId: string, reaction: string) => `${ReturnType<typeof Endpoints.CHANNEL_MESSAGE_REACTIONS>}/{reaction}`;
|
|
32
|
+
CHANNEL_MESSAGE_REACTION_USER: (chanId: string, msgId: string, reaction: string, userId: string) => `${ReturnType<typeof Endpoints.CHANNEL_MESSAGE_REACTION>}/{user_id}`;
|
|
33
|
+
CHANNEL_MESSAGE_REACTIONS: (chanId: string, msgId: string) => `${ReturnType<typeof Endpoints.CHANNEL_MESSAGE>}/reactions`;
|
|
34
|
+
CHANNEL_MESSAGE_THREADS: (chanId: string, msgId: string) => `${ReturnType<typeof Endpoints.CHANNEL_MESSAGE>}/threads`;
|
|
35
|
+
CHANNEL_MESSAGES: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/messages`;
|
|
36
|
+
CHANNEL_PERMISSION: (chanId: string, permId: string) => `${ReturnType<typeof Endpoints.CHANNEL_PERMISSIONS>}/{perm_id}`;
|
|
37
|
+
CHANNEL_PERMISSIONS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/permissions`;
|
|
38
|
+
CHANNEL_PIN: (chanId: string, msgId: string) => `${ReturnType<typeof Endpoints.CHANNEL_PINS>}/{message_id}`;
|
|
39
|
+
CHANNEL_PINS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/messages/pins`;
|
|
40
|
+
CHANNEL_RECIPIENT: (chanId: string, userId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/recipients/{user_id}`;
|
|
41
|
+
CHANNEL_THREADS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/threads`;
|
|
42
|
+
CHANNEL_THREAD_MEMBER: (chanId: string, memberId: string) => `${ReturnType<typeof Endpoints.CHANNEL_THREAD_MEMBERS>}/{member_id}`;
|
|
43
|
+
CHANNEL_THREAD_MEMBERS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/thread-members`;
|
|
44
|
+
CHANNEL_THREADS_ARCHIVED_PRIVATE: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL_THREADS>}/archived/private`;
|
|
45
|
+
CHANNEL_THREADS_ARCHIVED_PRIVATE_USER: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/users/@me/threads/archived/private`;
|
|
46
|
+
CHANNEL_THREADS_ARCHIVED_PUBLIC: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL_THREADS>}/archived/public`;
|
|
47
|
+
CHANNEL_TYPING: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/typing`;
|
|
48
|
+
CHANNEL_VOICE_STATUS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/voice-status`;
|
|
49
|
+
CHANNEL_VOICE_HANGOUT: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/voice-hangout`;
|
|
50
|
+
CHANNEL_WEBHOOKS: (chanId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/webhooks`;
|
|
51
|
+
CHANNELS: "/channels";
|
|
52
|
+
GATEWAY: "/gateway";
|
|
53
|
+
GATEWAY_BOT: "/gateway/bot";
|
|
54
|
+
GUILD: (guildId: string) => `${typeof Endpoints.GUILDS}/{guild_id}`;
|
|
55
|
+
GUILD_AUDIT_LOGS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/audit-logs`;
|
|
56
|
+
GUILD_AUTO_MOD_RULE: (guildId: string, ruleId: string) => `${ReturnType<typeof Endpoints.GUILD_AUTO_MOD_RULES>}/{rule_id}`;
|
|
57
|
+
GUILD_AUTO_MOD_RULES: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/auto-moderation/rules`;
|
|
58
|
+
GUILD_BAN: (guildId: string, memberId: string) => `${ReturnType<typeof Endpoints.GUILD_BANS>}/{member_id}`;
|
|
59
|
+
GUILD_BANS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/bans`;
|
|
60
|
+
GUILD_CHANNELS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/channels`;
|
|
61
|
+
GUILD_EMOJI: (guildId: string, emojiId: string) => `${ReturnType<typeof Endpoints.GUILD_EMOJIS>}/{emoji_id}`;
|
|
62
|
+
GUILD_EMOJIS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/emojis`;
|
|
63
|
+
GUILD_INVITES: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/invites`;
|
|
64
|
+
GUILD_INTEGRATION: (guildId: string, integrationId: string) => `${ReturnType<typeof Endpoints.GUILD_INTEGRATIONS>}/{integration_id}`;
|
|
65
|
+
GUILD_INTEGRATIONS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/integrations`;
|
|
66
|
+
GUILD_MEMBER: (guildId: string, memberId: string) => `${ReturnType<typeof Endpoints.GUILD_MEMBERS>}/{member_id}`;
|
|
67
|
+
GUILD_MEMBER_ROLE: (guildId: string, memberId: string, roleId: string) => `${ReturnType<typeof Endpoints.GUILD_MEMBER>}/roles/{role_id}`;
|
|
68
|
+
GUILD_MEMBERS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/members`;
|
|
69
|
+
GUILD_MEMBERS_SEARCH: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD_MEMBERS>}/search`;
|
|
70
|
+
GUILD_MESSAGES_SEARCH: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/messages/search`;
|
|
71
|
+
GUILD_PREVIEW: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/preview`;
|
|
72
|
+
GUILD_PRUNE: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/prune`;
|
|
73
|
+
GUILD_ROLE: (guildId: string, roleId: string) => `${ReturnType<typeof Endpoints.GUILD_ROLES>}/{role_id}`;
|
|
74
|
+
GUILD_ROLES: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/roles`;
|
|
75
|
+
GUILD_SCHEDULED_EVENTS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/scheduled-events`;
|
|
76
|
+
GUILD_SCHEDULED_EVENT: (guildId: string, eventId: string) => `${ReturnType<typeof Endpoints.GUILD_SCHEDULED_EVENTS>}/{event_id}`;
|
|
77
|
+
GUILD_SCHEDULED_EVENT_USERS: (guildId: string, eventId: string) => `${ReturnType<typeof Endpoints.GUILD_SCHEDULED_EVENT>}/users`;
|
|
78
|
+
GUILD_STICKER: (guildId: string, stickerId: string) => `${ReturnType<typeof Endpoints.GUILD_STICKERS>}/{sticker_id}`;
|
|
79
|
+
GUILD_STICKERS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/stickers`;
|
|
80
|
+
GUILD_TEMPLATE: (guildId: string, code: string) => `${ReturnType<typeof Endpoints.GUILD_TEMPLATES>}/{code}`;
|
|
81
|
+
GUILD_THREADS_ACTIVE: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/threads/active`;
|
|
82
|
+
GUILD_TEMPLATES: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/templates`;
|
|
83
|
+
GUILD_VANITY: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/vanity-url`;
|
|
84
|
+
GUILD_VOICE_REGIONS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/regions`;
|
|
85
|
+
GUILD_VOICE_STATE_USER: (guildId: string, memberId: string) => `${ReturnType<typeof Endpoints.GUILD>}/voice-states/{member_id}`;
|
|
86
|
+
GUILD_WEBHOOKS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/webhooks`;
|
|
87
|
+
GUILD_WELCOME_SCREEN: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/welcome-screen`;
|
|
88
|
+
GUILD_WIDGET: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/widget.json`;
|
|
89
|
+
GUILD_WIDGET_SETTINGS: (guildId: string) => `${ReturnType<typeof Endpoints.GUILD>}/widget`;
|
|
90
|
+
GUILDS: "/guilds";
|
|
91
|
+
INTERACTION_CALLBACK: (interactionId: string, token: string) => "/interactions/{interaction_id}/{token}/callback";
|
|
92
|
+
INVITES: (inviteId: string) => "/invites/{invite_id}";
|
|
93
|
+
INVITE_TARGET_USERS: (inviteId: string) => `${ReturnType<typeof Endpoints.INVITES>}/target-users`;
|
|
94
|
+
INVITE_TARGET_USERS_JOB_STATUS: (inviteId: string) => `${ReturnType<typeof Endpoints.INVITE_TARGET_USERS>}/job-status`;
|
|
95
|
+
OAUTH2_APPLICATION: (appId: string) => "/oauth2/applications/{app_id}";
|
|
96
|
+
OAUTH2_TOKEN: "/api/oauth2/token";
|
|
97
|
+
POLL_ANSWER: (chanId: string, msgId: string, answerId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/polls/{message_id}/answers/{answer_id}`;
|
|
98
|
+
POLL_EXPIRE: (chanId: string, msgId: string) => `${ReturnType<typeof Endpoints.CHANNEL>}/polls/{message_id}/expire`;
|
|
99
|
+
SKU_SUBSCRIPTIONS: (skuId: string) => "/skus/{sku_id}/subscriptions";
|
|
100
|
+
SKU_SUBSCRIPTION: (skuId: string, subscriptionId: string) => `${ReturnType<typeof Endpoints.SKU_SUBSCRIPTIONS>}/{subscription_id}`;
|
|
101
|
+
STAGE_INSTANCE_CHANNEL: (chanId: string) => `${typeof Endpoints.STAGE_INSTANCES}/{channel_id}`;
|
|
102
|
+
STAGE_INSTANCES: "/stage-instances";
|
|
103
|
+
STICKER: (stickerId: string) => "/stickers/{sticker_id}";
|
|
104
|
+
TEMPLATE: (code: string) => "/guilds/templates/{code}";
|
|
105
|
+
USER: (userId: string) => `${typeof Endpoints.USERS}/{user_id}`;
|
|
106
|
+
USER_APPLICATION_ROLE_CONNECTION: (userId: string, appId: string) => `${ReturnType<typeof Endpoints.USER>}/applications/{app_id}/role-connection`;
|
|
107
|
+
USER_CHANNELS: (userId: string) => `${ReturnType<typeof Endpoints.USER>}/channels`;
|
|
108
|
+
USER_CONNECTIONS: (userId: string) => `${ReturnType<typeof Endpoints.USER>}/connections`;
|
|
109
|
+
USER_GUILD: (userId: string, guildId: string) => `${ReturnType<typeof Endpoints.USER_GUILDS>}/{guild_id}`;
|
|
110
|
+
USER_GUILDS: (userId: string) => `${ReturnType<typeof Endpoints.USER>}/guilds`;
|
|
111
|
+
USER_GUILD_VOICE_STATE: (guildId: string, userId: string) => `${ReturnType<typeof Endpoints.GUILD>}/voice-states/{user_id}`;
|
|
112
|
+
USERS: "/users";
|
|
113
|
+
VOICE_REGIONS: "/voice/regions";
|
|
114
|
+
WEBHOOK: (hookId: string) => "/webhooks/{hook_id}";
|
|
115
|
+
WEBHOOK_TOKEN: (hookId: string, token: string) => `${ReturnType<typeof Endpoints.WEBHOOK>}/{token}`;
|
|
116
|
+
WEBHOOK_TOKEN_GITHUB: (hookId: string, token: string) => `${ReturnType<typeof Endpoints.WEBHOOK_TOKEN>}/github`;
|
|
117
|
+
WEBHOOK_TOKEN_MESSAGE: (hookId: string, token: string, msgId: string) => `${ReturnType<typeof Endpoints.WEBHOOK_TOKEN>}/messages/{message_id}`;
|
|
118
|
+
WEBHOOK_TOKEN_SLACK: (hookId: string, token: string) => `${ReturnType<typeof Endpoints.WEBHOOK_TOKEN>}/slack`;
|
|
119
|
+
};
|
|
120
|
+
export = Endpoints;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Constants = require("./Constants");
|
|
3
|
+
/**
|
|
4
|
+
* Mostly taken from https://github.com/abalabahaha/eris/blob/master/lib/rest/Endpoints.js
|
|
5
|
+
*
|
|
6
|
+
* Removed User-only endpoints
|
|
7
|
+
*/
|
|
8
|
+
const Endpoints = {
|
|
9
|
+
BASE_URL: "/api/v" + Constants.REST_API_VERSION,
|
|
10
|
+
BASE_HOST: "https://discord.com",
|
|
11
|
+
CDN_URL: "https://cdn.discordapp.com",
|
|
12
|
+
APPLICATION_COMMAND: (appId, cmdId) => `${Endpoints.APPLICATION_COMMANDS(appId)}/${cmdId}`,
|
|
13
|
+
APPLICATION_COMMANDS: (appId) => `/applications/${appId}/commands`,
|
|
14
|
+
APPLICATION_EMOJI: (appId, emojiId) => `${Endpoints.APPLICATION_EMOJIS(appId)}/${emojiId}`,
|
|
15
|
+
APPLICATION_EMOJIS: (appId) => `/applications/${appId}/emojis`,
|
|
16
|
+
APPLICATION_ENTITLEMENT: (appId, entitlementId) => `${Endpoints.APPLICATION_ENTITLEMENTS(appId)}/${entitlementId}`,
|
|
17
|
+
APPLICATION_ENTITLEMENT_CONSUME: (appId, entitlementId) => `${Endpoints.APPLICATION_ENTITLEMENT(appId, entitlementId)}/consume`,
|
|
18
|
+
APPLICATION_ENTITLEMENTS: (appId) => `/applications/${appId}/entitlements`,
|
|
19
|
+
APPLICATION_GUILD_COMMANDS_PERMISSIONS: (appId, guildId) => `${Endpoints.APPLICATION_GUILD_COMMANDS(appId, guildId)}/permissions`,
|
|
20
|
+
APPLICATION_GUILD_COMMAND_PERMISSIONS: (appId, guildId, cmdId) => `${Endpoints.APPLICATION_GUILD_COMMAND(appId, guildId, cmdId)}/permissions`,
|
|
21
|
+
APPLICATION_GUILD_COMMAND: (appId, guildId, cmdId) => `${Endpoints.APPLICATION_GUILD_COMMANDS(appId, guildId)}/${cmdId}`,
|
|
22
|
+
APPLICATION_GUILD_COMMANDS: (appId, guildId) => `/applications/${appId}/guilds/${guildId}/commands`,
|
|
23
|
+
APPLICATION_SKUS: (appId) => `/applications/${appId}/skus`,
|
|
24
|
+
ATTACHMENTS_REFRESH_URLS: "/attachments/refresh-urls",
|
|
25
|
+
CHANNEL: (chanId) => `${Endpoints.CHANNELS}/${chanId}`,
|
|
26
|
+
CHANNEL_ATTACHMENTS: (chanId) => `${Endpoints.CHANNEL(chanId)}/attachments`,
|
|
27
|
+
CHANNEL_BULK_DELETE: (chanId) => `${Endpoints.CHANNEL_MESSAGES(chanId)}/bulk-delete`,
|
|
28
|
+
CHANNEL_FOLLOWERS: (chanId) => `${Endpoints.CHANNEL(chanId)}/followers`,
|
|
29
|
+
CHANNEL_INVITES: (chanId) => `${Endpoints.CHANNEL(chanId)}/invites`,
|
|
30
|
+
CHANNEL_MESSAGE: (chanId, msgId) => `${Endpoints.CHANNEL_MESSAGES(chanId)}/${msgId}`,
|
|
31
|
+
CHANNEL_MESSAGE_CROSSPOST: (chanId, msgId) => `${Endpoints.CHANNEL_MESSAGE(chanId, msgId)}/crosspost`,
|
|
32
|
+
CHANNEL_MESSAGE_REACTION: (chanId, msgId, reaction) => `${Endpoints.CHANNEL_MESSAGE_REACTIONS(chanId, msgId)}/${reaction}`,
|
|
33
|
+
CHANNEL_MESSAGE_REACTION_USER: (chanId, msgId, reaction, userId) => `${Endpoints.CHANNEL_MESSAGE_REACTION(chanId, msgId, reaction)}/${userId}`,
|
|
34
|
+
CHANNEL_MESSAGE_REACTIONS: (chanId, msgId) => `${Endpoints.CHANNEL_MESSAGE(chanId, msgId)}/reactions`,
|
|
35
|
+
CHANNEL_MESSAGE_THREADS: (chanId, msgId) => `${Endpoints.CHANNEL_MESSAGE(chanId, msgId)}/threads`,
|
|
36
|
+
CHANNEL_MESSAGES: (chanId) => `${Endpoints.CHANNEL(chanId)}/messages`,
|
|
37
|
+
CHANNEL_PERMISSION: (chanId, permId) => `${Endpoints.CHANNEL_PERMISSIONS(chanId)}/${permId}`,
|
|
38
|
+
CHANNEL_PERMISSIONS: (chanId) => `${Endpoints.CHANNEL(chanId)}/permissions`,
|
|
39
|
+
CHANNEL_PIN: (chanId, msgId) => `${Endpoints.CHANNEL_PINS(chanId)}/${msgId}`,
|
|
40
|
+
CHANNEL_PINS: (chanId) => `${Endpoints.CHANNEL(chanId)}/messages/pins`,
|
|
41
|
+
CHANNEL_RECIPIENT: (chanId, userId) => `${Endpoints.CHANNEL(chanId)}/recipients/${userId}`,
|
|
42
|
+
CHANNEL_THREADS: (chanId) => `${Endpoints.CHANNEL(chanId)}/threads`,
|
|
43
|
+
CHANNEL_THREAD_MEMBER: (chanId, memberId) => `${Endpoints.CHANNEL_THREAD_MEMBERS(chanId)}/${memberId}`,
|
|
44
|
+
CHANNEL_THREAD_MEMBERS: (chanId) => `${Endpoints.CHANNEL(chanId)}/thread-members`,
|
|
45
|
+
CHANNEL_THREADS_ARCHIVED_PRIVATE: (chanId) => `${Endpoints.CHANNEL_THREADS(chanId)}/archived/private`,
|
|
46
|
+
CHANNEL_THREADS_ARCHIVED_PRIVATE_USER: (chanId) => `${Endpoints.CHANNEL(chanId)}/users/@me/threads/archived/private`,
|
|
47
|
+
CHANNEL_THREADS_ARCHIVED_PUBLIC: (chanId) => `${Endpoints.CHANNEL_THREADS(chanId)}/archived/public`,
|
|
48
|
+
CHANNEL_TYPING: (chanId) => `${Endpoints.CHANNEL(chanId)}/typing`,
|
|
49
|
+
CHANNEL_VOICE_STATUS: (chanId) => `${Endpoints.CHANNEL(chanId)}/voice-status`,
|
|
50
|
+
CHANNEL_VOICE_HANGOUT: (chanId) => `${Endpoints.CHANNEL(chanId)}/voice-hangout`,
|
|
51
|
+
CHANNEL_WEBHOOKS: (chanId) => `${Endpoints.CHANNEL(chanId)}/webhooks`,
|
|
52
|
+
CHANNELS: "/channels",
|
|
53
|
+
GATEWAY: "/gateway",
|
|
54
|
+
GATEWAY_BOT: "/gateway/bot",
|
|
55
|
+
GUILD: (guildId) => `${Endpoints.GUILDS}/${guildId}`,
|
|
56
|
+
GUILD_AUDIT_LOGS: (guildId) => `${Endpoints.GUILD(guildId)}/audit-logs`,
|
|
57
|
+
GUILD_AUTO_MOD_RULE: (guildId, ruleId) => `${Endpoints.GUILD_AUTO_MOD_RULES(guildId)}/${ruleId}`,
|
|
58
|
+
GUILD_AUTO_MOD_RULES: (guildId) => `${Endpoints.GUILD(guildId)}/auto-moderation/rules`,
|
|
59
|
+
GUILD_BAN: (guildId, memberId) => `${Endpoints.GUILD_BANS(guildId)}/${memberId}`,
|
|
60
|
+
GUILD_BANS: (guildId) => `${Endpoints.GUILD(guildId)}/bans`,
|
|
61
|
+
GUILD_CHANNELS: (guildId) => `${Endpoints.GUILD(guildId)}/channels`,
|
|
62
|
+
GUILD_EMOJI: (guildId, emojiId) => `${Endpoints.GUILD_EMOJIS(guildId)}/${emojiId}`,
|
|
63
|
+
GUILD_EMOJIS: (guildId) => `${Endpoints.GUILD(guildId)}/emojis`,
|
|
64
|
+
GUILD_INVITES: (guildId) => `${Endpoints.GUILD(guildId)}/invites`,
|
|
65
|
+
GUILD_INTEGRATION: (guildId, integrationId) => `${Endpoints.GUILD_INTEGRATIONS(guildId)}/${integrationId}`,
|
|
66
|
+
GUILD_INTEGRATIONS: (guildId) => `${Endpoints.GUILD(guildId)}/integrations`,
|
|
67
|
+
GUILD_MEMBER: (guildId, memberId) => `${Endpoints.GUILD_MEMBERS(guildId)}/${memberId}`,
|
|
68
|
+
GUILD_MEMBER_ROLE: (guildId, memberId, roleId) => `${Endpoints.GUILD_MEMBER(guildId, memberId)}/roles/${roleId}`,
|
|
69
|
+
GUILD_MEMBERS: (guildId) => `${Endpoints.GUILD(guildId)}/members`,
|
|
70
|
+
GUILD_MEMBERS_SEARCH: (guildId) => `${Endpoints.GUILD_MEMBERS(guildId)}/search`,
|
|
71
|
+
GUILD_MESSAGES_SEARCH: (guildId) => `${Endpoints.GUILD(guildId)}/messages/search`,
|
|
72
|
+
GUILD_PREVIEW: (guildId) => `${Endpoints.GUILD(guildId)}/preview`,
|
|
73
|
+
GUILD_PRUNE: (guildId) => `${Endpoints.GUILD(guildId)}/prune`,
|
|
74
|
+
GUILD_ROLE: (guildId, roleId) => `${Endpoints.GUILD_ROLES(guildId)}/${roleId}`,
|
|
75
|
+
GUILD_ROLES: (guildId) => `${Endpoints.GUILD(guildId)}/roles`,
|
|
76
|
+
GUILD_SCHEDULED_EVENTS: (guildId) => `${Endpoints.GUILD(guildId)}/scheduled-events`,
|
|
77
|
+
GUILD_SCHEDULED_EVENT: (guildId, eventId) => `${Endpoints.GUILD_SCHEDULED_EVENTS(guildId)}/${eventId}`,
|
|
78
|
+
GUILD_SCHEDULED_EVENT_USERS: (guildId, eventId) => `${Endpoints.GUILD_SCHEDULED_EVENT(guildId, eventId)}/users`,
|
|
79
|
+
GUILD_STICKER: (guildId, stickerId) => `${Endpoints.GUILD_STICKERS(guildId)}/${stickerId}`,
|
|
80
|
+
GUILD_STICKERS: (guildId) => `${Endpoints.GUILD(guildId)}/stickers`,
|
|
81
|
+
GUILD_TEMPLATE: (guildId, code) => `${Endpoints.GUILD_TEMPLATES(guildId)}/${code}`,
|
|
82
|
+
GUILD_THREADS_ACTIVE: (guildId) => `${Endpoints.GUILD(guildId)}/threads/active`,
|
|
83
|
+
GUILD_TEMPLATES: (guildId) => `${Endpoints.GUILD(guildId)}/templates`,
|
|
84
|
+
GUILD_VANITY: (guildId) => `${Endpoints.GUILD(guildId)}/vanity-url`,
|
|
85
|
+
GUILD_VOICE_REGIONS: (guildId) => `${Endpoints.GUILD(guildId)}/regions`,
|
|
86
|
+
GUILD_VOICE_STATE_USER: (guildId, memberId) => `${Endpoints.GUILD(guildId)}/voice-states/${memberId}`,
|
|
87
|
+
GUILD_WEBHOOKS: (guildId) => `${Endpoints.GUILD(guildId)}/webhooks`,
|
|
88
|
+
GUILD_WELCOME_SCREEN: (guildId) => `${Endpoints.GUILD(guildId)}/welcome-screen`,
|
|
89
|
+
GUILD_WIDGET: (guildId) => `${Endpoints.GUILD(guildId)}/widget.json`,
|
|
90
|
+
GUILD_WIDGET_SETTINGS: (guildId) => `${Endpoints.GUILD(guildId)}/widget`,
|
|
91
|
+
GUILDS: "/guilds",
|
|
92
|
+
INTERACTION_CALLBACK: (interactionId, token) => `/interactions/${interactionId}/${token}/callback`,
|
|
93
|
+
INVITES: (inviteId) => `/invites/${inviteId}`,
|
|
94
|
+
INVITE_TARGET_USERS: (inviteId) => `${Endpoints.INVITES(inviteId)}/target-users`,
|
|
95
|
+
INVITE_TARGET_USERS_JOB_STATUS: (inviteId) => `${Endpoints.INVITE_TARGET_USERS(inviteId)}/job-status`,
|
|
96
|
+
OAUTH2_APPLICATION: (appId) => `/oauth2/applications/${appId}`,
|
|
97
|
+
OAUTH2_TOKEN: "/api/oauth2/token",
|
|
98
|
+
POLL_ANSWER: (chanId, msgId, answerId) => `${Endpoints.CHANNEL(chanId)}/polls/${msgId}/answers/${answerId}`,
|
|
99
|
+
POLL_EXPIRE: (chanId, msgId) => `${Endpoints.CHANNEL(chanId)}/polls/${msgId}/expire`,
|
|
100
|
+
SKU_SUBSCRIPTIONS: (skuId) => `/skus/${skuId}/subscriptions`,
|
|
101
|
+
SKU_SUBSCRIPTION: (skuId, subscriptionId) => `${Endpoints.SKU_SUBSCRIPTIONS(skuId)}/${subscriptionId}`,
|
|
102
|
+
STAGE_INSTANCE_CHANNEL: (chanId) => `${Endpoints.STAGE_INSTANCES}/${chanId}`,
|
|
103
|
+
STAGE_INSTANCES: "/stage-instances",
|
|
104
|
+
STICKER: (stickerId) => `/stickers/${stickerId}`,
|
|
105
|
+
TEMPLATE: (code) => `/guilds/templates/${code}`,
|
|
106
|
+
USER: (userId) => `${Endpoints.USERS}/${userId}`,
|
|
107
|
+
USER_APPLICATION_ROLE_CONNECTION: (userId, appId) => `${Endpoints.USER(userId)}/applications/${appId}/role-connection`,
|
|
108
|
+
USER_CHANNELS: (userId) => `${Endpoints.USER(userId)}/channels`,
|
|
109
|
+
USER_CONNECTIONS: (userId) => `${Endpoints.USER(userId)}/connections`,
|
|
110
|
+
USER_GUILD: (userId, guildId) => `${Endpoints.USER_GUILDS(userId)}/${guildId}`,
|
|
111
|
+
USER_GUILDS: (userId) => `${Endpoints.USER(userId)}/guilds`,
|
|
112
|
+
USER_GUILD_VOICE_STATE: (guildId, userId) => `${Endpoints.GUILD(guildId)}/voice-states/${userId}`,
|
|
113
|
+
USERS: "/users",
|
|
114
|
+
VOICE_REGIONS: "/voice/regions",
|
|
115
|
+
WEBHOOK: (hookId) => `/webhooks/${hookId}`,
|
|
116
|
+
WEBHOOK_TOKEN: (hookId, token) => `${Endpoints.WEBHOOK(hookId)}/${token}`,
|
|
117
|
+
WEBHOOK_TOKEN_GITHUB: (hookId, token) => `${Endpoints.WEBHOOK_TOKEN(hookId, token)}/github`,
|
|
118
|
+
WEBHOOK_TOKEN_MESSAGE: (hookId, token, msgId) => `/webhooks/${hookId}/${token}/messages/${msgId}`,
|
|
119
|
+
WEBHOOK_TOKEN_SLACK: (hookId, token) => `${Endpoints.WEBHOOK_TOKEN(hookId, token)}/slack`,
|
|
120
|
+
};
|
|
121
|
+
module.exports = Endpoints;
|