disgroove 2.2.2-dev.bd3875c → 2.2.2
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 +2 -6
- package/dist/lib/Client.d.ts +47 -49
- package/dist/lib/Client.js +170 -182
- package/dist/lib/constants.d.ts +19 -4
- package/dist/lib/constants.js +22 -5
- package/dist/lib/gateway/Shard.js +59 -58
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/rest/Endpoints.d.ts +6 -6
- package/dist/lib/rest/Endpoints.js +13 -13
- package/dist/lib/rest/RequestManager.d.ts +1 -1
- package/dist/lib/rest/index.d.ts +0 -1
- package/dist/lib/rest/index.js +1 -2
- package/dist/lib/transformers/Applications.d.ts +8 -0
- package/dist/lib/transformers/Applications.js +211 -0
- package/dist/lib/transformers/AuditLogs.d.ts +7 -0
- package/dist/lib/transformers/AuditLogs.js +97 -0
- package/dist/lib/transformers/AutoModeration.d.ts +5 -0
- package/dist/lib/transformers/AutoModeration.js +64 -0
- package/dist/lib/transformers/Channels.d.ts +16 -0
- package/dist/lib/transformers/Channels.js +676 -0
- package/dist/lib/transformers/Emojis.d.ts +5 -0
- package/dist/lib/transformers/Emojis.js +31 -0
- package/dist/lib/transformers/Entitlements.d.ts +7 -0
- package/dist/lib/transformers/Entitlements.js +58 -0
- package/dist/lib/transformers/GuildScheduledEvents.d.ts +5 -0
- package/dist/lib/transformers/GuildScheduledEvents.js +51 -0
- package/dist/lib/transformers/GuildTemplates.d.ts +5 -0
- package/dist/lib/transformers/GuildTemplates.js +38 -0
- package/dist/lib/transformers/Guilds.d.ts +12 -0
- package/dist/lib/transformers/Guilds.js +248 -0
- package/dist/lib/transformers/Interactions.d.ts +10 -0
- package/dist/lib/transformers/Interactions.js +273 -0
- package/dist/lib/transformers/Invites.d.ts +5 -0
- package/dist/lib/transformers/Invites.js +79 -0
- package/dist/lib/transformers/Polls.d.ts +5 -0
- package/dist/lib/transformers/Polls.js +50 -0
- package/dist/lib/transformers/Presences.d.ts +8 -0
- package/dist/lib/transformers/Presences.js +108 -0
- package/dist/lib/transformers/Roles.d.ts +5 -0
- package/dist/lib/transformers/Roles.js +56 -0
- package/dist/lib/transformers/SKUs.d.ts +5 -0
- package/dist/lib/transformers/SKUs.js +26 -0
- package/dist/lib/transformers/StageInstances.d.ts +5 -0
- package/dist/lib/transformers/StageInstances.js +28 -0
- package/dist/lib/transformers/Stickers.d.ts +5 -0
- package/dist/lib/transformers/Stickers.js +41 -0
- package/dist/lib/transformers/Teams.d.ts +5 -0
- package/dist/lib/transformers/Teams.js +35 -0
- package/dist/lib/transformers/Users.d.ts +5 -0
- package/dist/lib/transformers/Users.js +48 -0
- package/dist/lib/transformers/Voice.d.ts +5 -0
- package/dist/lib/transformers/Voice.js +45 -0
- package/dist/lib/transformers/Webhooks.d.ts +5 -0
- package/dist/lib/transformers/Webhooks.js +51 -0
- package/dist/lib/transformers/index.d.ts +21 -0
- package/dist/lib/transformers/index.js +37 -0
- package/dist/lib/types/entitlements.d.ts +0 -6
- package/dist/lib/types/interaction.d.ts +2 -2
- package/dist/lib/types/sku.d.ts +0 -12
- package/dist/lib/utils/CDN.d.ts +24 -0
- package/dist/lib/utils/CDN.js +49 -0
- package/dist/lib/utils/Util.d.ts +1 -93
- package/dist/lib/utils/Util.js +2 -2211
- package/dist/lib/utils/formatters.d.ts +9 -0
- package/dist/lib/utils/formatters.js +38 -0
- package/dist/lib/utils/index.d.ts +2 -0
- package/dist/lib/utils/index.js +15 -0
- package/dist/package.json +3 -3
- package/package.json +3 -3
- package/dist/lib/rest/CDN.d.ts +0 -22
- package/dist/lib/rest/CDN.js +0 -45
- package/dist/lib/types/voice-connections.d.ts +0 -64
- package/dist/lib/types/voice-connections.js +0 -2
- package/dist/lib/voice/VoiceConnection.d.ts +0 -57
- package/dist/lib/voice/VoiceConnection.js +0 -150
- package/dist/lib/voice/VoiceConnectionManager.d.ts +0 -19
- package/dist/lib/voice/VoiceConnectionManager.js +0 -66
- package/dist/lib/voice/index.d.ts +0 -2
- package/dist/lib/voice/index.js +0 -18
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { GuildNavigationTypes, TimestampStyles } from "../constants";
|
2
|
+
import type { snowflake } from "../types/common";
|
3
|
+
export declare function userMention(userID: snowflake): string;
|
4
|
+
export declare function channelMention(channelID: snowflake): string;
|
5
|
+
export declare function roleMention(roleID: snowflake): string;
|
6
|
+
export declare function slashCommandMention(commandName: string, commandID: snowflake, subCommandName?: string, subCommandGroupName?: string): string;
|
7
|
+
export declare function customEmoji(emojiName: string, emojiID: snowflake, animated?: boolean): string;
|
8
|
+
export declare function unixTimestamp(time: number, style?: TimestampStyles): string;
|
9
|
+
export declare function guildNavigation(guildID: snowflake, type: GuildNavigationTypes): string;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* https://discord.com/developers/docs/reference#message-formatting */
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.guildNavigation = exports.unixTimestamp = exports.customEmoji = exports.slashCommandMention = exports.roleMention = exports.channelMention = exports.userMention = void 0;
|
5
|
+
function userMention(userID) {
|
6
|
+
return `<@${userID}>`;
|
7
|
+
}
|
8
|
+
exports.userMention = userMention;
|
9
|
+
function channelMention(channelID) {
|
10
|
+
return `<#${channelID}>`;
|
11
|
+
}
|
12
|
+
exports.channelMention = channelMention;
|
13
|
+
function roleMention(roleID) {
|
14
|
+
return `<@&${roleID}>`;
|
15
|
+
}
|
16
|
+
exports.roleMention = roleMention;
|
17
|
+
function slashCommandMention(commandName, commandID, subCommandName, subCommandGroupName) {
|
18
|
+
return subCommandName
|
19
|
+
? subCommandGroupName
|
20
|
+
? `</${commandName} ${subCommandGroupName} ${subCommandName}:${commandID}>`
|
21
|
+
: `</${commandName} ${subCommandName}:${commandID}>`
|
22
|
+
: `</${commandName}:${commandID}>`;
|
23
|
+
}
|
24
|
+
exports.slashCommandMention = slashCommandMention;
|
25
|
+
function customEmoji(emojiName, emojiID, animated) {
|
26
|
+
return animated
|
27
|
+
? `<a:${emojiName}:${emojiID}>`
|
28
|
+
: `<:${emojiName}:${emojiID}>`;
|
29
|
+
}
|
30
|
+
exports.customEmoji = customEmoji;
|
31
|
+
function unixTimestamp(time, style) {
|
32
|
+
return style ? `<t:${time}:${style}>` : `<t:${time}>`;
|
33
|
+
}
|
34
|
+
exports.unixTimestamp = unixTimestamp;
|
35
|
+
function guildNavigation(guildID, type) {
|
36
|
+
return `<${guildID}:${type}>`;
|
37
|
+
}
|
38
|
+
exports.guildNavigation = guildNavigation;
|
package/dist/lib/utils/index.js
CHANGED
@@ -10,9 +10,24 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
11
11
|
o[k2] = m[k];
|
12
12
|
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
27
|
};
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.CDN = void 0;
|
30
|
+
exports.CDN = __importStar(require("./CDN"));
|
17
31
|
__exportStar(require("./errors"), exports);
|
32
|
+
__exportStar(require("./formatters"), exports);
|
18
33
|
__exportStar(require("./Util"), exports);
|
package/dist/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "disgroove",
|
3
|
-
"version": "2.2.2
|
3
|
+
"version": "2.2.2",
|
4
4
|
"description": "A module to interface with Discord",
|
5
5
|
"main": "./dist/lib/index.js",
|
6
6
|
"types": "./dist/lib/index.d.ts",
|
@@ -25,11 +25,11 @@
|
|
25
25
|
},
|
26
26
|
"homepage": "https://github.com/XenKys/disgroove#readme",
|
27
27
|
"devDependencies": {
|
28
|
-
"@types/node": "^20.14.
|
28
|
+
"@types/node": "^20.14.10",
|
29
29
|
"@types/ws": "^8.5.10",
|
30
30
|
"typescript": "^5.5.3"
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
|
-
"ws": "^8.
|
33
|
+
"ws": "^8.18.0"
|
34
34
|
}
|
35
35
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "disgroove",
|
3
|
-
"version": "2.2.2
|
3
|
+
"version": "2.2.2",
|
4
4
|
"description": "A module to interface with Discord",
|
5
5
|
"main": "./dist/lib/index.js",
|
6
6
|
"types": "./dist/lib/index.d.ts",
|
@@ -25,11 +25,11 @@
|
|
25
25
|
},
|
26
26
|
"homepage": "https://github.com/XenKys/disgroove#readme",
|
27
27
|
"devDependencies": {
|
28
|
-
"@types/node": "^20.14.
|
28
|
+
"@types/node": "^20.14.10",
|
29
29
|
"@types/ws": "^8.5.10",
|
30
30
|
"typescript": "^5.5.3"
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
|
-
"ws": "^8.
|
33
|
+
"ws": "^8.18.0"
|
34
34
|
}
|
35
35
|
}
|
package/dist/lib/rest/CDN.d.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import type { snowflake } from "../types/common";
|
2
|
-
export declare const achievementIcon: (applicationID: snowflake, achievementID: snowflake, iconHash: string) => `https://cdn.discordapp.com/app-assets/${string}/achievements/${string}/icons/${string}.png`;
|
3
|
-
export declare const applicationAsset: (applicationID: snowflake, assetID: snowflake) => `https://cdn.discordapp.com/app-assets/${string}/${string}.png`;
|
4
|
-
export declare const applicationCover: (applicationID: snowflake, coverImage: string) => `https://cdn.discordapp.com/app-icons/${string}/${string}.png`;
|
5
|
-
export declare const applicationIcon: (applicationID: snowflake, icon: string) => `https://cdn.discordapp.com/app-icons/${string}/${string}.png`;
|
6
|
-
export declare const customEmoji: (emojiID: snowflake) => `https://cdn.discordapp.com/emojis/${string}.png`;
|
7
|
-
export declare const defaultUserAvatar: (index: string) => `https://cdn.discordapp.com/embed/avatars/${string}.png`;
|
8
|
-
export declare const guildBanner: (guildID: snowflake, banner: string) => `https://cdn.discordapp.com/banners/${string}/${string}.png`;
|
9
|
-
export declare const guildDiscoverySplash: (guildID: snowflake, splash: string) => `https://cdn.discordapp.com/discovery-splashes/${string}/${string}.png`;
|
10
|
-
export declare const guildIcon: (guildID: snowflake, icon: string) => `https://cdn.discordapp.com/icons/${string}/${string}.png`;
|
11
|
-
export declare const guildMemberAvatar: (guildID: snowflake, userID: snowflake, avatar: string) => `https://cdn.discordapp.com/guilds/${string}/users/${string}/avatars/${string}.png`;
|
12
|
-
export declare const guildMemberBanner: (guildID: snowflake, userID: snowflake, banner: string) => `https://cdn.discordapp.com/guilds/${string}/users/${string}/banners/${string}.png`;
|
13
|
-
export declare const guildScheduledEventCover: (scheduledEventID: snowflake, coverImage: string) => `https://cdn.discordapp.com/guild-events/${string}/${string}.png`;
|
14
|
-
export declare const guildSplash: (guildID: snowflake, splash: string) => `https://cdn.discordapp.com/splashes/${string}/${string}.png`;
|
15
|
-
export declare const roleIcon: (roleID: snowflake, icon: string) => `https://cdn.discordapp.com/role-icons/${string}/${string}.png`;
|
16
|
-
export declare const stickerPackBanner: (assetID: snowflake) => `https://cdn.discordapp.com/app-assets/710982414301790216/store/${string}.png`;
|
17
|
-
export declare const sticker: (stickerID: snowflake) => `https://cdn.discordapp.com/stickers/${string}.png`;
|
18
|
-
export declare const storePageAsset: (applicationID: snowflake, assetID: snowflake) => `https://cdn.discordapp.com/app-assets/${string}/store/${string}`;
|
19
|
-
export declare const teamIcon: (teamID: snowflake, icon: string) => `https://cdn.discordapp.com/team-icons/${string}/${string}.png`;
|
20
|
-
export declare const userAvatar: (userID: snowflake, avatar: string) => `https://cdn.discordapp.com/avatars/${string}/${string}.png`;
|
21
|
-
export declare const userAvatarDecoration: (userID: snowflake, avatarDecoration: string) => `https://cdn.discordapp.com/avatar-decorations/${string}/${string}.png`;
|
22
|
-
export declare const userBanner: (userID: snowflake, banner: string) => `https://cdn.discordapp.com/banners/${string}/${string}.png`;
|
package/dist/lib/rest/CDN.js
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.userBanner = exports.userAvatarDecoration = exports.userAvatar = exports.teamIcon = exports.storePageAsset = exports.sticker = exports.stickerPackBanner = exports.roleIcon = exports.guildSplash = exports.guildScheduledEventCover = exports.guildMemberBanner = exports.guildMemberAvatar = exports.guildIcon = exports.guildDiscoverySplash = exports.guildBanner = exports.defaultUserAvatar = exports.customEmoji = exports.applicationIcon = exports.applicationCover = exports.applicationAsset = exports.achievementIcon = void 0;
|
4
|
-
const achievementIcon = (applicationID, achievementID, iconHash) => `https://cdn.discordapp.com/app-assets/${applicationID}/achievements/${achievementID}/icons/${iconHash}.png`;
|
5
|
-
exports.achievementIcon = achievementIcon;
|
6
|
-
const applicationAsset = (applicationID, assetID) => `https://cdn.discordapp.com/app-assets/${applicationID}/${assetID}.png`;
|
7
|
-
exports.applicationAsset = applicationAsset;
|
8
|
-
const applicationCover = (applicationID, coverImage) => `https://cdn.discordapp.com/app-icons/${applicationID}/${coverImage}.png`;
|
9
|
-
exports.applicationCover = applicationCover;
|
10
|
-
const applicationIcon = (applicationID, icon) => `https://cdn.discordapp.com/app-icons/${applicationID}/${icon}.png`;
|
11
|
-
exports.applicationIcon = applicationIcon;
|
12
|
-
const customEmoji = (emojiID) => `https://cdn.discordapp.com/emojis/${emojiID}.png`;
|
13
|
-
exports.customEmoji = customEmoji;
|
14
|
-
const defaultUserAvatar = (index) => `https://cdn.discordapp.com/embed/avatars/${index}.png`;
|
15
|
-
exports.defaultUserAvatar = defaultUserAvatar;
|
16
|
-
const guildBanner = (guildID, banner) => `https://cdn.discordapp.com/banners/${guildID}/${banner}.png`;
|
17
|
-
exports.guildBanner = guildBanner;
|
18
|
-
const guildDiscoverySplash = (guildID, splash) => `https://cdn.discordapp.com/discovery-splashes/${guildID}/${splash}.png`;
|
19
|
-
exports.guildDiscoverySplash = guildDiscoverySplash;
|
20
|
-
const guildIcon = (guildID, icon) => `https://cdn.discordapp.com/icons/${guildID}/${icon}.png`;
|
21
|
-
exports.guildIcon = guildIcon;
|
22
|
-
const guildMemberAvatar = (guildID, userID, avatar) => `https://cdn.discordapp.com/guilds/${guildID}/users/${userID}/avatars/${avatar}.png`;
|
23
|
-
exports.guildMemberAvatar = guildMemberAvatar;
|
24
|
-
const guildMemberBanner = (guildID, userID, banner) => `https://cdn.discordapp.com/guilds/${guildID}/users/${userID}/banners/${banner}.png`;
|
25
|
-
exports.guildMemberBanner = guildMemberBanner;
|
26
|
-
const guildScheduledEventCover = (scheduledEventID, coverImage) => `https://cdn.discordapp.com/guild-events/${scheduledEventID}/${coverImage}.png`;
|
27
|
-
exports.guildScheduledEventCover = guildScheduledEventCover;
|
28
|
-
const guildSplash = (guildID, splash) => `https://cdn.discordapp.com/splashes/${guildID}/${splash}.png`;
|
29
|
-
exports.guildSplash = guildSplash;
|
30
|
-
const roleIcon = (roleID, icon) => `https://cdn.discordapp.com/role-icons/${roleID}/${icon}.png`;
|
31
|
-
exports.roleIcon = roleIcon;
|
32
|
-
const stickerPackBanner = (assetID) => `https://cdn.discordapp.com/app-assets/710982414301790216/store/${assetID}.png`;
|
33
|
-
exports.stickerPackBanner = stickerPackBanner;
|
34
|
-
const sticker = (stickerID) => `https://cdn.discordapp.com/stickers/${stickerID}.png`;
|
35
|
-
exports.sticker = sticker;
|
36
|
-
const storePageAsset = (applicationID, assetID) => `https://cdn.discordapp.com/app-assets/${applicationID}/store/${assetID}`;
|
37
|
-
exports.storePageAsset = storePageAsset;
|
38
|
-
const teamIcon = (teamID, icon) => `https://cdn.discordapp.com/team-icons/${teamID}/${icon}.png`;
|
39
|
-
exports.teamIcon = teamIcon;
|
40
|
-
const userAvatar = (userID, avatar) => `https://cdn.discordapp.com/avatars/${userID}/${avatar}.png`;
|
41
|
-
exports.userAvatar = userAvatar;
|
42
|
-
const userAvatarDecoration = (userID, avatarDecoration) => `https://cdn.discordapp.com/avatar-decorations/${userID}/${avatarDecoration}.png`;
|
43
|
-
exports.userAvatarDecoration = userAvatarDecoration;
|
44
|
-
const userBanner = (userID, banner) => `https://cdn.discordapp.com/banners/${userID}/${banner}.png`;
|
45
|
-
exports.userBanner = userBanner;
|
@@ -1,64 +0,0 @@
|
|
1
|
-
import type { snowflake } from "./common";
|
2
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
3
|
-
export interface RawVoiceIdentifyPayload {
|
4
|
-
server_id: snowflake;
|
5
|
-
user_id: snowflake;
|
6
|
-
session_id: string;
|
7
|
-
token: string;
|
8
|
-
}
|
9
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload */
|
10
|
-
export interface RawVoiceReadyPayload {
|
11
|
-
ssrc: number;
|
12
|
-
ip: string;
|
13
|
-
port: number;
|
14
|
-
modes: Array<string>;
|
15
|
-
}
|
16
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection-example-resume-connection-payload */
|
17
|
-
export interface RawResumeConnectionPayload {
|
18
|
-
server_id: snowflake;
|
19
|
-
session_id: string;
|
20
|
-
token: string;
|
21
|
-
}
|
22
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload */
|
23
|
-
export interface RawSelectProtocolPayload {
|
24
|
-
protocol: string;
|
25
|
-
data: {
|
26
|
-
address: string;
|
27
|
-
port: number;
|
28
|
-
mode: string;
|
29
|
-
};
|
30
|
-
}
|
31
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-session-description-payload */
|
32
|
-
export interface RawSessionDescriptionPayload {
|
33
|
-
mode: string;
|
34
|
-
secret_key: Array<number>;
|
35
|
-
}
|
36
|
-
export interface VoiceIdentifyPayload {
|
37
|
-
serverID: snowflake;
|
38
|
-
userID: snowflake;
|
39
|
-
sessionID: string;
|
40
|
-
token: string;
|
41
|
-
}
|
42
|
-
export interface VoiceReadyPayload {
|
43
|
-
ssrc: number;
|
44
|
-
ip: string;
|
45
|
-
port: number;
|
46
|
-
modes: Array<string>;
|
47
|
-
}
|
48
|
-
export interface ResumeConnectionPayload {
|
49
|
-
serverID: snowflake;
|
50
|
-
sessionID: string;
|
51
|
-
token: string;
|
52
|
-
}
|
53
|
-
export interface SelectProtocolPayload {
|
54
|
-
protocol: string;
|
55
|
-
data: {
|
56
|
-
address: string;
|
57
|
-
port: number;
|
58
|
-
mode: string;
|
59
|
-
};
|
60
|
-
}
|
61
|
-
export interface SessionDescriptionPayload {
|
62
|
-
mode: string;
|
63
|
-
secretKey: Array<number>;
|
64
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import WebSocket from "ws";
|
3
|
-
import type { snowflake } from "../types/common";
|
4
|
-
import EventEmitter from "node:events";
|
5
|
-
import type { ResumeConnectionPayload, SelectProtocolPayload, SessionDescriptionPayload, VoiceIdentifyPayload, VoiceReadyPayload } from "../types/voice-connections";
|
6
|
-
export declare class VoiceConnection extends EventEmitter {
|
7
|
-
ws: WebSocket;
|
8
|
-
endpoint: string;
|
9
|
-
serverID: snowflake;
|
10
|
-
userID: snowflake;
|
11
|
-
sessionID: string;
|
12
|
-
token: string;
|
13
|
-
private heartbeatInterval;
|
14
|
-
ssrc: number;
|
15
|
-
constructor(endpoint: string, options: VoiceIdentifyPayload);
|
16
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
17
|
-
connect(): void;
|
18
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
19
|
-
disconnect(): void;
|
20
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
21
|
-
heartbeat(): void;
|
22
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
23
|
-
identify(options: VoiceIdentifyPayload): void;
|
24
|
-
private onWebSocketOpen;
|
25
|
-
private onWebSocketMessage;
|
26
|
-
private onWebSocketError;
|
27
|
-
private onWebSocketClose;
|
28
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
29
|
-
resume(options: ResumeConnectionPayload): void;
|
30
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
31
|
-
selectProtocol(options: SelectProtocolPayload): void;
|
32
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
33
|
-
speaking(speaking: number): void;
|
34
|
-
}
|
35
|
-
export declare interface VoiceConnection extends EventEmitter {
|
36
|
-
addListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
37
|
-
emit<K extends keyof VoiceConnectionEvents>(eventName: K, ...args: VoiceConnectionEvents[K]): boolean;
|
38
|
-
listenerCount(eventName: keyof VoiceConnectionEvents): number;
|
39
|
-
listeners(eventName: keyof VoiceConnectionEvents): Array<Function>;
|
40
|
-
off<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
41
|
-
on<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
42
|
-
once<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
43
|
-
prependListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
44
|
-
prependOnceListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
45
|
-
rawListeners(eventName: keyof VoiceConnectionEvents): Array<Function>;
|
46
|
-
removeAllListeners(event?: keyof VoiceConnectionEvents): this;
|
47
|
-
removeListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
48
|
-
}
|
49
|
-
export interface VoiceConnectionEvents {
|
50
|
-
ready: [voiceServer: VoiceReadyPayload];
|
51
|
-
sessionDescription: [session: SessionDescriptionPayload];
|
52
|
-
speaking: [speaking: number];
|
53
|
-
heartbeatACK: [heartbeat: number];
|
54
|
-
hello: [];
|
55
|
-
resumed: [];
|
56
|
-
clientDisconnect: [];
|
57
|
-
}
|
@@ -1,150 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.VoiceConnection = void 0;
|
7
|
-
const ws_1 = __importDefault(require("ws"));
|
8
|
-
const constants_1 = require("../constants");
|
9
|
-
const utils_1 = require("../utils");
|
10
|
-
const node_events_1 = __importDefault(require("node:events"));
|
11
|
-
class VoiceConnection extends node_events_1.default {
|
12
|
-
ws;
|
13
|
-
endpoint;
|
14
|
-
serverID;
|
15
|
-
userID;
|
16
|
-
sessionID;
|
17
|
-
token;
|
18
|
-
heartbeatInterval;
|
19
|
-
ssrc;
|
20
|
-
constructor(endpoint, options) {
|
21
|
-
super();
|
22
|
-
this.ws = new ws_1.default(`wss://${endpoint}?v=4`);
|
23
|
-
this.endpoint = endpoint;
|
24
|
-
this.serverID = options.serverID;
|
25
|
-
this.userID = options.userID;
|
26
|
-
this.sessionID = options.sessionID;
|
27
|
-
this.token = options.token;
|
28
|
-
}
|
29
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
30
|
-
connect() {
|
31
|
-
this.ws.on("open", () => this.onWebSocketOpen());
|
32
|
-
this.ws.on("message", (data) => this.onWebSocketMessage(data));
|
33
|
-
this.ws.on("error", (err) => this.onWebSocketError(err));
|
34
|
-
this.ws.on("close", (code, reason) => this.onWebSocketClose(code, reason));
|
35
|
-
}
|
36
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
37
|
-
disconnect() {
|
38
|
-
if (this.heartbeatInterval) {
|
39
|
-
clearInterval(this.heartbeatInterval);
|
40
|
-
this.heartbeatInterval = null;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
44
|
-
heartbeat() {
|
45
|
-
this.ws.send(JSON.stringify({
|
46
|
-
op: constants_1.VoiceOPCodes.Heartbeat,
|
47
|
-
d: Date.now(),
|
48
|
-
}));
|
49
|
-
}
|
50
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
51
|
-
identify(options) {
|
52
|
-
this.ws.send(JSON.stringify({
|
53
|
-
op: constants_1.VoiceOPCodes.Identify,
|
54
|
-
d: {
|
55
|
-
server_id: options.serverID,
|
56
|
-
user_id: options.userID,
|
57
|
-
session_id: options.sessionID,
|
58
|
-
token: options.token,
|
59
|
-
},
|
60
|
-
}));
|
61
|
-
}
|
62
|
-
onWebSocketOpen() {
|
63
|
-
this.identify({
|
64
|
-
serverID: this.serverID,
|
65
|
-
userID: this.userID,
|
66
|
-
sessionID: this.sessionID,
|
67
|
-
token: this.token,
|
68
|
-
});
|
69
|
-
}
|
70
|
-
onWebSocketMessage(data) {
|
71
|
-
const packet = JSON.parse(data.toString());
|
72
|
-
switch (packet.op) {
|
73
|
-
case constants_1.VoiceOPCodes.Ready:
|
74
|
-
{
|
75
|
-
this.ssrc = packet.d.ssrc;
|
76
|
-
this.emit("ready", {
|
77
|
-
ssrc: packet.d.ssrc,
|
78
|
-
ip: packet.d.ip,
|
79
|
-
port: packet.d.port,
|
80
|
-
modes: packet.d.modes,
|
81
|
-
});
|
82
|
-
}
|
83
|
-
break;
|
84
|
-
case constants_1.VoiceOPCodes.SessionDescription:
|
85
|
-
this.emit("sessionDescription", {
|
86
|
-
mode: packet.d.mode,
|
87
|
-
secretKey: packet.d.secret_key,
|
88
|
-
});
|
89
|
-
break;
|
90
|
-
case constants_1.VoiceOPCodes.Speaking:
|
91
|
-
this.emit("speaking", packet.d.speaking);
|
92
|
-
break;
|
93
|
-
case constants_1.VoiceOPCodes.HeartbeatACK:
|
94
|
-
this.emit("heartbeatACK", packet.d);
|
95
|
-
break;
|
96
|
-
case constants_1.VoiceOPCodes.Hello:
|
97
|
-
{
|
98
|
-
this.heartbeatInterval = setInterval(() => this.heartbeat(), packet.d.heartbeat_interval);
|
99
|
-
this.emit("hello");
|
100
|
-
}
|
101
|
-
break;
|
102
|
-
case constants_1.VoiceOPCodes.Resumed:
|
103
|
-
this.emit("resumed");
|
104
|
-
break;
|
105
|
-
case constants_1.VoiceOPCodes.ClientDisconnect:
|
106
|
-
this.emit("clientDisconnect");
|
107
|
-
break;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
onWebSocketError(err) {
|
111
|
-
throw err;
|
112
|
-
}
|
113
|
-
onWebSocketClose(code, reason) {
|
114
|
-
if (code === 1000)
|
115
|
-
return;
|
116
|
-
if (code === constants_1.VoiceCloseEventCodes.Disconnect)
|
117
|
-
return this.disconnect();
|
118
|
-
throw new utils_1.GatewayError(`[${code}] ${reason}`);
|
119
|
-
}
|
120
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
121
|
-
resume(options) {
|
122
|
-
this.ws.send(JSON.stringify({
|
123
|
-
op: constants_1.VoiceOPCodes.Resume,
|
124
|
-
d: {
|
125
|
-
server_id: options.serverID,
|
126
|
-
session_id: options.sessionID,
|
127
|
-
token: options.token,
|
128
|
-
},
|
129
|
-
}));
|
130
|
-
}
|
131
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
132
|
-
selectProtocol(options) {
|
133
|
-
this.ws.send(JSON.stringify({
|
134
|
-
op: constants_1.VoiceOPCodes.SelectProtocol,
|
135
|
-
d: options,
|
136
|
-
}));
|
137
|
-
}
|
138
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
139
|
-
speaking(speaking) {
|
140
|
-
this.ws.send(JSON.stringify({
|
141
|
-
op: constants_1.VoiceOPCodes.Speaking,
|
142
|
-
d: {
|
143
|
-
speaking,
|
144
|
-
delay: 0,
|
145
|
-
ssrc: this.ssrc,
|
146
|
-
},
|
147
|
-
}));
|
148
|
-
}
|
149
|
-
}
|
150
|
-
exports.VoiceConnection = VoiceConnection;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { snowflake } from "../types/common";
|
2
|
-
import type { ResumeConnectionPayload, SelectProtocolPayload, VoiceIdentifyPayload } from "../types/voice-connections";
|
3
|
-
import { VoiceConnection } from ".";
|
4
|
-
export declare class VoiceConnectionManager extends Map<snowflake, VoiceConnection> {
|
5
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
6
|
-
connect(endpoint: string, options: VoiceIdentifyPayload): VoiceConnection;
|
7
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
8
|
-
disconnect(guildID: snowflake): void;
|
9
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
10
|
-
heartbeat(guildID: snowflake): void;
|
11
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
12
|
-
identify(guildID: snowflake, options: VoiceIdentifyPayload): void;
|
13
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
14
|
-
resume(guildID: snowflake, options: ResumeConnectionPayload): void;
|
15
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
16
|
-
selectProtocol(guildID: snowflake, options: SelectProtocolPayload): void;
|
17
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
18
|
-
speaking(guildID: snowflake, speaking: number): void;
|
19
|
-
}
|
@@ -1,66 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.VoiceConnectionManager = void 0;
|
4
|
-
const _1 = require(".");
|
5
|
-
class VoiceConnectionManager extends Map {
|
6
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
7
|
-
connect(endpoint, options) {
|
8
|
-
let voiceConnection = new _1.VoiceConnection(endpoint, options);
|
9
|
-
if (!this.has(options.serverID)) {
|
10
|
-
this.set(options.serverID, voiceConnection);
|
11
|
-
voiceConnection.connect();
|
12
|
-
}
|
13
|
-
else {
|
14
|
-
this.disconnect(options.serverID);
|
15
|
-
this.set(options.serverID, voiceConnection);
|
16
|
-
}
|
17
|
-
return voiceConnection;
|
18
|
-
}
|
19
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
20
|
-
disconnect(guildID) {
|
21
|
-
if (this.has(guildID)) {
|
22
|
-
this.get(guildID).disconnect();
|
23
|
-
this.delete(guildID);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
27
|
-
heartbeat(guildID) {
|
28
|
-
if (this.has(guildID)) {
|
29
|
-
this.get(guildID).heartbeat();
|
30
|
-
}
|
31
|
-
}
|
32
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
33
|
-
identify(guildID, options) {
|
34
|
-
if (this.has(guildID)) {
|
35
|
-
this.get(guildID).identify({
|
36
|
-
serverID: options.serverID,
|
37
|
-
userID: options.userID,
|
38
|
-
sessionID: options.sessionID,
|
39
|
-
token: options.token,
|
40
|
-
});
|
41
|
-
}
|
42
|
-
}
|
43
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
44
|
-
resume(guildID, options) {
|
45
|
-
if (this.has(guildID)) {
|
46
|
-
this.get(guildID).resume({
|
47
|
-
serverID: options.serverID,
|
48
|
-
sessionID: options.sessionID,
|
49
|
-
token: options.token,
|
50
|
-
});
|
51
|
-
}
|
52
|
-
}
|
53
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
54
|
-
selectProtocol(guildID, options) {
|
55
|
-
if (this.has(guildID)) {
|
56
|
-
this.get(guildID).selectProtocol(options);
|
57
|
-
}
|
58
|
-
}
|
59
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
60
|
-
speaking(guildID, speaking) {
|
61
|
-
if (this.has(guildID)) {
|
62
|
-
this.get(guildID).speaking(speaking);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
exports.VoiceConnectionManager = VoiceConnectionManager;
|
package/dist/lib/voice/index.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./VoiceConnection"), exports);
|
18
|
-
__exportStar(require("./VoiceConnectionManager"), exports);
|