disgroove 3.0.0-dev.51640ff → 3.0.0-dev.681c806
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/LICENSE +9 -9
- package/README.md +48 -48
- package/dist/lib/Client.d.ts +0 -3
- package/dist/lib/constants.d.ts +2 -1
- package/dist/lib/constants.js +1 -0
- package/dist/lib/gateway/Shard.d.ts +3 -2
- package/dist/lib/gateway/Shard.js +128 -95
- package/dist/lib/rest/RequestManager.js +17 -7
- package/dist/lib/rest/index.js +17 -7
- package/dist/lib/transformers/Components.d.ts +3 -1
- package/dist/lib/transformers/Components.js +26 -0
- package/dist/lib/transformers/Interactions.js +30 -0
- package/dist/lib/types/components.d.ts +36 -4
- package/dist/lib/types/interaction.d.ts +3 -3
- package/dist/lib/utils/formatters.js +9 -10
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.js +18 -7
- package/dist/lib/utils/permissions.d.ts +2 -0
- package/dist/lib/utils/permissions.js +7 -0
- package/dist/package.json +1 -1
- package/package.json +2 -2
- package/dist/lib/types/message-components.d.ts +0 -450
- package/dist/lib/types/message-components.js +0 -2
package/LICENSE
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright © 2024 XenKys
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2024 XenKys
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
# disgroove
|
|
2
|
-
|
|
3
|
-
A module to interface with Discord
|
|
4
|
-
|
|
5
|
-
- Fast
|
|
6
|
-
- Lightweight
|
|
7
|
-
- Flexible
|
|
8
|
-
- 100% coverage of the [Official Discord API Documentation](https://discord.com/developers/docs/intro)
|
|
9
|
-
|
|
10
|
-
## Example
|
|
11
|
-
|
|
12
|
-
```js
|
|
13
|
-
const {
|
|
14
|
-
Client,
|
|
15
|
-
GatewayIntents,
|
|
16
|
-
InteractionType,
|
|
17
|
-
InteractionCallbackType,
|
|
18
|
-
MessageFlags,
|
|
19
|
-
} = require("disgroove");
|
|
20
|
-
const client = new Client("B0t.T0k3N");
|
|
21
|
-
|
|
22
|
-
client.once("ready", () => {
|
|
23
|
-
console.log("Logged in as", client.user.username);
|
|
24
|
-
|
|
25
|
-
client.createGlobalApplicationCommand(client.application.id, {
|
|
26
|
-
name: "ping",
|
|
27
|
-
description: "Pong!",
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
client.on("interactionCreate", async (interaction) => {
|
|
32
|
-
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
|
33
|
-
|
|
34
|
-
if (interaction.data.name === "ping") {
|
|
35
|
-
client.createInteractionResponse(interaction.id, interaction.token, {
|
|
36
|
-
type: InteractionCallbackType.ChannelMessageWithSource,
|
|
37
|
-
data: {
|
|
38
|
-
content: "Pong! 🏓",
|
|
39
|
-
flags: MessageFlags.Ephemeral,
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
client.connect();
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
More examples on the [GitHub repository](https://github.com/sergiogotuzzo/disgroove/tree/main/examples)
|
|
1
|
+
# disgroove
|
|
2
|
+
|
|
3
|
+
A module to interface with Discord
|
|
4
|
+
|
|
5
|
+
- Fast
|
|
6
|
+
- Lightweight
|
|
7
|
+
- Flexible
|
|
8
|
+
- 100% coverage of the [Official Discord API Documentation](https://discord.com/developers/docs/intro)
|
|
9
|
+
|
|
10
|
+
## Example
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
const {
|
|
14
|
+
Client,
|
|
15
|
+
GatewayIntents,
|
|
16
|
+
InteractionType,
|
|
17
|
+
InteractionCallbackType,
|
|
18
|
+
MessageFlags,
|
|
19
|
+
} = require("disgroove");
|
|
20
|
+
const client = new Client("B0t.T0k3N");
|
|
21
|
+
|
|
22
|
+
client.once("ready", () => {
|
|
23
|
+
console.log("Logged in as", client.user.username);
|
|
24
|
+
|
|
25
|
+
client.createGlobalApplicationCommand(client.application.id, {
|
|
26
|
+
name: "ping",
|
|
27
|
+
description: "Pong!",
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
client.on("interactionCreate", async (interaction) => {
|
|
32
|
+
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
|
33
|
+
|
|
34
|
+
if (interaction.data.name === "ping") {
|
|
35
|
+
client.createInteractionResponse(interaction.id, interaction.token, {
|
|
36
|
+
type: InteractionCallbackType.ChannelMessageWithSource,
|
|
37
|
+
data: {
|
|
38
|
+
content: "Pong! 🏓",
|
|
39
|
+
flags: MessageFlags.Ephemeral,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
client.connect();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
More examples on the [GitHub repository](https://github.com/sergiogotuzzo/disgroove/tree/main/examples)
|
package/dist/lib/Client.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { GatewayIntents, type OAuth2Scopes, type ActionTypes, type ImageWidgetStyleOptions, type ReactionTypes, type ApplicationCommandTypes, type EventTypes, type TriggerTypes, type ChannelTypes, type VideoQualityModes, type SortOrderTypes, type ForumLayoutTypes, type InviteTargetTypes, type VerificationLevel, type DefaultMessageNotificationLevel, type ExplicitContentFilterLevel, type SystemChannelFlags, type ApplicationFlags, type ApplicationIntegrationTypes, type ChannelFlags, type GuildFeatures, type GuildScheduledEventEntityTypes, type GuildScheduledEventPrivacyLevel, type GuildScheduledEventStatus, type MessageFlags, type OnboardingMode, type PrivacyLevel, type GuildMemberFlags, type InteractionContextTypes, type LobbyMemberFlags } from "./constants";
|
|
5
2
|
import { RequestManager, type FileData } from "./rest";
|
|
6
3
|
import EventEmitter from "node:events";
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -135,7 +135,8 @@ export declare enum ComponentTypes {
|
|
|
135
135
|
File = 13,
|
|
136
136
|
Separator = 14,
|
|
137
137
|
Container = 17,
|
|
138
|
-
Label = 18
|
|
138
|
+
Label = 18,
|
|
139
|
+
FileUpload = 19
|
|
139
140
|
}
|
|
140
141
|
/** https://discord.com/developers/docs/components/reference#button-button-styles */
|
|
141
142
|
export declare enum ButtonStyles {
|
package/dist/lib/constants.js
CHANGED
|
@@ -152,6 +152,7 @@ var ComponentTypes;
|
|
|
152
152
|
ComponentTypes[ComponentTypes["Separator"] = 14] = "Separator";
|
|
153
153
|
ComponentTypes[ComponentTypes["Container"] = 17] = "Container";
|
|
154
154
|
ComponentTypes[ComponentTypes["Label"] = 18] = "Label";
|
|
155
|
+
ComponentTypes[ComponentTypes["FileUpload"] = 19] = "FileUpload";
|
|
155
156
|
})(ComponentTypes || (exports.ComponentTypes = ComponentTypes = {}));
|
|
156
157
|
/** https://discord.com/developers/docs/components/reference#button-button-styles */
|
|
157
158
|
var ButtonStyles;
|
|
@@ -5,7 +5,7 @@ export declare class Shard {
|
|
|
5
5
|
id: number;
|
|
6
6
|
private heartbeatInterval;
|
|
7
7
|
client: Client;
|
|
8
|
-
ws: WebSocket;
|
|
8
|
+
ws: WebSocket | null;
|
|
9
9
|
sessionId: string | null;
|
|
10
10
|
resumeGatewayURL: string | null;
|
|
11
11
|
sequence: number | null;
|
|
@@ -14,7 +14,6 @@ export declare class Shard {
|
|
|
14
14
|
connect(reconnect: boolean): void;
|
|
15
15
|
/** https://discord.com/developers/docs/events/gateway#initiating-a-disconnect */
|
|
16
16
|
disconnect(): void;
|
|
17
|
-
reconnect(): void;
|
|
18
17
|
/** https://discord.com/developers/docs/topics/gateway-events#heartbeat */
|
|
19
18
|
heartbeat(lastSequence: number | null): void;
|
|
20
19
|
/** https://discord.com/developers/docs/topics/gateway-events#identify */
|
|
@@ -24,6 +23,8 @@ export declare class Shard {
|
|
|
24
23
|
private onWebSocketMessage;
|
|
25
24
|
private onWebSocketError;
|
|
26
25
|
private onWebSocketClose;
|
|
26
|
+
/** https://discord.com/developers/docs/events/gateway#resuming */
|
|
27
|
+
reconnect(): void;
|
|
27
28
|
/** https://discord.com/developers/docs/topics/gateway-events#request-guild-members */
|
|
28
29
|
requestGuildMembers(options: RequestGuildMembers): void;
|
|
29
30
|
/** https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds */
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -44,60 +54,63 @@ class Shard {
|
|
|
44
54
|
this.id = id;
|
|
45
55
|
this.heartbeatInterval = null;
|
|
46
56
|
this.client = client;
|
|
47
|
-
this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json", client.ws);
|
|
57
|
+
this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json", this.client.ws);
|
|
48
58
|
this.sessionId = null;
|
|
49
59
|
this.resumeGatewayURL = null;
|
|
50
60
|
this.sequence = null;
|
|
51
61
|
}
|
|
52
62
|
/** https://discord.com/developers/docs/topics/gateway#connections */
|
|
53
63
|
connect(reconnect) {
|
|
54
|
-
this.ws
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
if (this.ws) {
|
|
65
|
+
this.ws.on("open", () => this.onWebSocketOpen(reconnect));
|
|
66
|
+
this.ws.on("message", (data) => this.onWebSocketMessage(data));
|
|
67
|
+
this.ws.on("error", (err) => this.onWebSocketError(err));
|
|
68
|
+
this.ws.on("close", (code, reason) => this.onWebSocketClose(code, reason));
|
|
69
|
+
}
|
|
58
70
|
}
|
|
59
71
|
/** https://discord.com/developers/docs/events/gateway#initiating-a-disconnect */
|
|
60
72
|
disconnect() {
|
|
61
|
-
if (this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.ws.close(1000, "Resume Attempt - Reconnect");
|
|
72
|
-
this.ws = new ws_1.default(this.resumeGatewayURL, this.client.ws);
|
|
73
|
-
this.connect(true);
|
|
73
|
+
if (this.ws) {
|
|
74
|
+
if (this.heartbeatInterval) {
|
|
75
|
+
clearInterval(this.heartbeatInterval);
|
|
76
|
+
this.heartbeatInterval = null;
|
|
77
|
+
}
|
|
78
|
+
if (this.ws.readyState !== ws_1.default.CLOSED) {
|
|
79
|
+
this.ws.removeAllListeners();
|
|
80
|
+
this.ws.close(1000, "Session Invalidated - Disconnect");
|
|
81
|
+
this.ws = null;
|
|
82
|
+
}
|
|
74
83
|
}
|
|
75
84
|
}
|
|
76
85
|
/** https://discord.com/developers/docs/topics/gateway-events#heartbeat */
|
|
77
86
|
heartbeat(lastSequence) {
|
|
78
|
-
this.ws.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
88
|
+
this.ws.send(JSON.stringify({
|
|
89
|
+
op: constants_1.GatewayOPCodes.Heartbeat,
|
|
90
|
+
d: lastSequence,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
82
93
|
}
|
|
83
94
|
/** https://discord.com/developers/docs/topics/gateway-events#identify */
|
|
84
95
|
identify(options) {
|
|
85
|
-
this.ws.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
97
|
+
this.ws.send(JSON.stringify({
|
|
98
|
+
op: constants_1.GatewayOPCodes.Identify,
|
|
99
|
+
d: {
|
|
100
|
+
token: options.token,
|
|
101
|
+
properties: {
|
|
102
|
+
os: options.properties.os,
|
|
103
|
+
browser: options.properties.browser,
|
|
104
|
+
device: options.properties.device,
|
|
105
|
+
},
|
|
106
|
+
compress: options.compress,
|
|
107
|
+
large_threshold: options.largeThreshold,
|
|
108
|
+
shard: options.shard,
|
|
109
|
+
presence: options.presence,
|
|
110
|
+
intents: options.intents,
|
|
93
111
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
shard: options.shard,
|
|
97
|
-
presence: options.presence,
|
|
98
|
-
intents: options.intents,
|
|
99
|
-
},
|
|
100
|
-
}));
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
101
114
|
}
|
|
102
115
|
onDispatch(packet) {
|
|
103
116
|
this.sequence = packet.s;
|
|
@@ -627,7 +640,7 @@ class Shard {
|
|
|
627
640
|
if (packet.d) {
|
|
628
641
|
this.reconnect();
|
|
629
642
|
}
|
|
630
|
-
else {
|
|
643
|
+
else if (this.ws) {
|
|
631
644
|
this.ws.close(1000, "Invalid Session - Identify required");
|
|
632
645
|
this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json", this.client.ws);
|
|
633
646
|
this.connect(false);
|
|
@@ -651,6 +664,7 @@ class Shard {
|
|
|
651
664
|
onWebSocketClose(code, reason) {
|
|
652
665
|
switch (code) {
|
|
653
666
|
case 1000:
|
|
667
|
+
this.disconnect();
|
|
654
668
|
break;
|
|
655
669
|
case constants_1.GatewayCloseEventCodes.UnknownError:
|
|
656
670
|
case constants_1.GatewayCloseEventCodes.UnknownOPCode:
|
|
@@ -663,73 +677,92 @@ class Shard {
|
|
|
663
677
|
this.reconnect();
|
|
664
678
|
break;
|
|
665
679
|
default:
|
|
680
|
+
this.disconnect();
|
|
666
681
|
throw new utils_1.GatewayError(code, reason.toString());
|
|
667
682
|
}
|
|
668
683
|
}
|
|
684
|
+
/** https://discord.com/developers/docs/events/gateway#resuming */
|
|
685
|
+
reconnect() {
|
|
686
|
+
if (this.ws && this.resumeGatewayURL && this.sessionId && this.sequence) {
|
|
687
|
+
this.ws.close(1000, "Resume Attempt - Reconnect");
|
|
688
|
+
this.ws = new ws_1.default(this.resumeGatewayURL, this.client.ws);
|
|
689
|
+
this.connect(true);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
669
692
|
/** https://discord.com/developers/docs/topics/gateway-events#request-guild-members */
|
|
670
693
|
requestGuildMembers(options) {
|
|
671
|
-
this.ws.
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
694
|
+
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
695
|
+
this.ws.send(JSON.stringify({
|
|
696
|
+
op: constants_1.GatewayOPCodes.RequestGuildMembers,
|
|
697
|
+
d: {
|
|
698
|
+
guild_id: options.guildId,
|
|
699
|
+
query: options.query,
|
|
700
|
+
limit: options.limit,
|
|
701
|
+
presences: options.presences,
|
|
702
|
+
user_ids: options.userIds,
|
|
703
|
+
nonce: options.nonce,
|
|
704
|
+
},
|
|
705
|
+
}));
|
|
706
|
+
}
|
|
682
707
|
}
|
|
683
708
|
/** https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds */
|
|
684
709
|
requestSoundboardSounds(options) {
|
|
685
|
-
this.ws.
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
710
|
+
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
711
|
+
this.ws.send(JSON.stringify({
|
|
712
|
+
op: constants_1.GatewayOPCodes.RequestSoundboardSounds,
|
|
713
|
+
d: {
|
|
714
|
+
guild_ids: options.guildIds,
|
|
715
|
+
},
|
|
716
|
+
}));
|
|
717
|
+
}
|
|
691
718
|
}
|
|
692
719
|
/** https://discord.com/developers/docs/topics/gateway-events#resume */
|
|
693
720
|
resume(options) {
|
|
694
|
-
this.ws.
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
721
|
+
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
722
|
+
this.ws.send(JSON.stringify({
|
|
723
|
+
op: constants_1.GatewayOPCodes.Resume,
|
|
724
|
+
d: {
|
|
725
|
+
token: options.token,
|
|
726
|
+
session_id: options.sessionId,
|
|
727
|
+
seq: options.seq,
|
|
728
|
+
},
|
|
729
|
+
}));
|
|
730
|
+
}
|
|
702
731
|
}
|
|
703
732
|
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
|
704
733
|
updatePresence(options) {
|
|
705
|
-
this.ws.
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
734
|
+
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
735
|
+
this.ws.send(JSON.stringify({
|
|
736
|
+
op: constants_1.GatewayOPCodes.PresenceUpdate,
|
|
737
|
+
d: {
|
|
738
|
+
since: options.status === constants_1.StatusTypes.Idle ? Date.now() : null,
|
|
739
|
+
activities: options.activities?.map((activity) => ({
|
|
740
|
+
name: activity.type === constants_1.ActivityType.Custom
|
|
741
|
+
? "Custom Status"
|
|
742
|
+
: activity.name,
|
|
743
|
+
type: activity.type,
|
|
744
|
+
url: activity.url,
|
|
745
|
+
state: activity.state,
|
|
746
|
+
})),
|
|
747
|
+
status: options.status ?? constants_1.StatusTypes.Online,
|
|
748
|
+
afk: !!options.afk,
|
|
749
|
+
},
|
|
750
|
+
}));
|
|
751
|
+
}
|
|
721
752
|
}
|
|
722
753
|
/** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
|
|
723
754
|
updateVoiceState(options) {
|
|
724
|
-
this.ws.
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
755
|
+
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
756
|
+
this.ws.send(JSON.stringify({
|
|
757
|
+
op: constants_1.GatewayOPCodes.VoiceStateUpdate,
|
|
758
|
+
d: {
|
|
759
|
+
guild_id: options.guildId,
|
|
760
|
+
channel_id: options.channelId,
|
|
761
|
+
self_mute: options.selfMute,
|
|
762
|
+
self_deaf: options.selfDeaf,
|
|
763
|
+
},
|
|
764
|
+
}));
|
|
765
|
+
}
|
|
733
766
|
}
|
|
734
767
|
}
|
|
735
768
|
exports.Shard = Shard;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.RequestManager = exports.RESTMethods = void 0;
|
|
27
37
|
const constants_1 = require("../constants");
|
package/dist/lib/rest/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
37
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionRow, Button, Container, RawActionRow, RawButton, RawContainer, RawFile, File, RawUnfurledMediaItem, UnfurledMediaItem, RawTextDisplay, TextDisplay, RawSeparator, Separator, RawSection, Section, Thumbnail, RawThumbnail, TextInput, RawTextInput, MediaGallery, RawMediaGallery, RawStringSelect, StringSelect, RawUserSelect, UserSelect, RawRoleSelect, RoleSelect, RawMentionableSelect, MentionableSelect, RawChannelSelect, ChannelSelect, RawLabel, Label } from "../types/components";
|
|
1
|
+
import { ActionRow, Button, Container, RawActionRow, RawButton, RawContainer, RawFile, File, RawUnfurledMediaItem, UnfurledMediaItem, RawTextDisplay, TextDisplay, RawSeparator, Separator, RawSection, Section, Thumbnail, RawThumbnail, TextInput, RawTextInput, MediaGallery, RawMediaGallery, RawStringSelect, StringSelect, RawUserSelect, UserSelect, RawRoleSelect, RoleSelect, RawMentionableSelect, MentionableSelect, RawChannelSelect, ChannelSelect, RawLabel, Label, RawFileUpload, FileUpload } from "../types/components";
|
|
2
2
|
export declare class Components {
|
|
3
3
|
static actionRowFromRaw(actionRow: RawActionRow): ActionRow;
|
|
4
4
|
static actionRowToRaw(actionRow: ActionRow): RawActionRow;
|
|
@@ -10,6 +10,8 @@ export declare class Components {
|
|
|
10
10
|
static containerToRaw(container: Container): RawContainer;
|
|
11
11
|
static fileFromRaw(file: RawFile): File;
|
|
12
12
|
static fileToRaw(file: File): RawFile;
|
|
13
|
+
static fileUploadFromRaw(fileUpload: RawFileUpload): FileUpload;
|
|
14
|
+
static fileUploadToRaw(fileUpload: FileUpload): RawFileUpload;
|
|
13
15
|
static labelFromRaw(label: RawLabel): Label;
|
|
14
16
|
static labelToRaw(label: Label): RawLabel;
|
|
15
17
|
static mediaGalleryFromRaw(mediaGallery: RawMediaGallery): MediaGallery;
|
|
@@ -183,6 +183,26 @@ class Components {
|
|
|
183
183
|
size: file.size,
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
+
static fileUploadFromRaw(fileUpload) {
|
|
187
|
+
return {
|
|
188
|
+
type: fileUpload.type,
|
|
189
|
+
id: fileUpload.id,
|
|
190
|
+
customId: fileUpload.custom_id,
|
|
191
|
+
minValues: fileUpload.min_values,
|
|
192
|
+
maxValues: fileUpload.max_values,
|
|
193
|
+
required: fileUpload.required,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
static fileUploadToRaw(fileUpload) {
|
|
197
|
+
return {
|
|
198
|
+
type: fileUpload.type,
|
|
199
|
+
id: fileUpload.id,
|
|
200
|
+
custom_id: fileUpload.customId,
|
|
201
|
+
min_values: fileUpload.minValues,
|
|
202
|
+
max_values: fileUpload.maxValues,
|
|
203
|
+
required: fileUpload.required,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
186
206
|
static labelFromRaw(label) {
|
|
187
207
|
let component;
|
|
188
208
|
switch (label.component.type) {
|
|
@@ -204,6 +224,9 @@ class Components {
|
|
|
204
224
|
case constants_1.ComponentTypes.ChannelSelect:
|
|
205
225
|
component = Components.channelSelectFromRaw(label.component);
|
|
206
226
|
break;
|
|
227
|
+
case constants_1.ComponentTypes.FileUpload:
|
|
228
|
+
component = Components.fileUploadFromRaw(label.component);
|
|
229
|
+
break;
|
|
207
230
|
}
|
|
208
231
|
return {
|
|
209
232
|
type: label.type,
|
|
@@ -234,6 +257,9 @@ class Components {
|
|
|
234
257
|
case constants_1.ComponentTypes.ChannelSelect:
|
|
235
258
|
component = Components.channelSelectToRaw(label.component);
|
|
236
259
|
break;
|
|
260
|
+
case constants_1.ComponentTypes.FileUpload:
|
|
261
|
+
component = Components.fileUploadToRaw(label.component);
|
|
262
|
+
break;
|
|
237
263
|
}
|
|
238
264
|
return {
|
|
239
265
|
type: label.type,
|
|
@@ -128,6 +128,13 @@ class Interactions {
|
|
|
128
128
|
resolved: this.resolvedDataFromRaw(c.resolved),
|
|
129
129
|
values: c.values,
|
|
130
130
|
};
|
|
131
|
+
case constants_1.ComponentTypes.FileUpload:
|
|
132
|
+
return {
|
|
133
|
+
type: c.type,
|
|
134
|
+
id: c.id,
|
|
135
|
+
customId: c.custom_id,
|
|
136
|
+
values: c.values,
|
|
137
|
+
};
|
|
131
138
|
}
|
|
132
139
|
}),
|
|
133
140
|
};
|
|
@@ -196,6 +203,14 @@ class Interactions {
|
|
|
196
203
|
values: component.component.values,
|
|
197
204
|
};
|
|
198
205
|
break;
|
|
206
|
+
case constants_1.ComponentTypes.FileUpload:
|
|
207
|
+
c = {
|
|
208
|
+
type: component.component.type,
|
|
209
|
+
id: component.component.id,
|
|
210
|
+
customId: component.component.custom_id,
|
|
211
|
+
values: component.component.values,
|
|
212
|
+
};
|
|
213
|
+
break;
|
|
199
214
|
}
|
|
200
215
|
return {
|
|
201
216
|
type: component.type,
|
|
@@ -351,6 +366,13 @@ class Interactions {
|
|
|
351
366
|
resolved: this.resolvedDataToRaw(c.resolved),
|
|
352
367
|
values: c.values,
|
|
353
368
|
};
|
|
369
|
+
case constants_1.ComponentTypes.FileUpload:
|
|
370
|
+
return {
|
|
371
|
+
type: c.type,
|
|
372
|
+
id: c.id,
|
|
373
|
+
custom_id: c.customId,
|
|
374
|
+
values: c.values,
|
|
375
|
+
};
|
|
354
376
|
}
|
|
355
377
|
}),
|
|
356
378
|
};
|
|
@@ -419,6 +441,14 @@ class Interactions {
|
|
|
419
441
|
values: component.component.values,
|
|
420
442
|
};
|
|
421
443
|
break;
|
|
444
|
+
case constants_1.ComponentTypes.FileUpload:
|
|
445
|
+
c = {
|
|
446
|
+
type: component.component.type,
|
|
447
|
+
id: component.component.id,
|
|
448
|
+
custom_id: component.component.customId,
|
|
449
|
+
values: component.component.values,
|
|
450
|
+
};
|
|
451
|
+
break;
|
|
422
452
|
}
|
|
423
453
|
return {
|
|
424
454
|
type: component.type,
|