magmastream 2.10.2-alpha.9 → 2.10.2-dev.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/dist/structures/Manager.d.ts +3 -2
- package/dist/structures/Manager.js +2 -17
- package/dist/structures/Node.js +2 -2
- package/dist/structures/Types.d.ts +10 -2
- package/dist/utils/managerCheck.d.ts +1 -1
- package/dist/utils/managerCheck.js +32 -2
- package/dist/wrappers/cloudstorm.d.ts +1 -1
- package/dist/wrappers/cloudstorm.js +15 -4
- package/dist/wrappers/discord.js.d.ts +1 -2
- package/dist/wrappers/discord.js.js +9 -15
- package/dist/wrappers/discordeno.d.ts +1 -2
- package/dist/wrappers/discordeno.js +5 -6
- package/dist/wrappers/eris.d.ts +0 -1
- package/dist/wrappers/eris.js +1 -3
- package/dist/wrappers/oceanic.d.ts +1 -2
- package/dist/wrappers/oceanic.js +3 -6
- package/dist/wrappers/seyfert.d.ts +1 -2
- package/dist/wrappers/seyfert.js +9 -10
- package/package.json +110 -110
|
@@ -4,7 +4,7 @@ import { EventEmitter } from "events";
|
|
|
4
4
|
import { Node } from "./Node";
|
|
5
5
|
import { Player } from "./Player";
|
|
6
6
|
import { Redis as RedisClient } from "ioredis";
|
|
7
|
-
import { AnyGuild, AnyUser, DiscordVoiceState, ManagerEvents, ManagerInitOptions, ManagerOptions, NodeOptions, PlayerOptions, SearchQuery, SearchResult, TrackData, VoicePacket, VoiceServer } from "./Types";
|
|
7
|
+
import { AnyGuild, AnyUser, DiscordVoiceState, ManagerEvents, ManagerInitOptions, ManagerOptions, NodeOptions, PlayerOptions, SearchQuery, SearchResult, StandaloneManagerOptions, TrackData, VoicePacket, VoiceServer } from "./Types";
|
|
8
8
|
/**
|
|
9
9
|
* The main hub for interacting with Lavalink and using Magmastream.
|
|
10
10
|
*/
|
|
@@ -36,7 +36,8 @@ export declare class Manager extends EventEmitter {
|
|
|
36
36
|
* @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
|
|
37
37
|
* @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
|
|
38
38
|
*/
|
|
39
|
-
constructor(options:
|
|
39
|
+
constructor(options: StandaloneManagerOptions);
|
|
40
|
+
constructor(options: ManagerOptions, isWrapper: true);
|
|
40
41
|
/**
|
|
41
42
|
* Initiates the Manager.
|
|
42
43
|
* @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers).
|
|
@@ -32,24 +32,9 @@ class Manager extends events_1.EventEmitter {
|
|
|
32
32
|
_getUser;
|
|
33
33
|
_getGuild;
|
|
34
34
|
loadedPlugins = new Set();
|
|
35
|
-
|
|
36
|
-
* Initiates the Manager class.
|
|
37
|
-
* @param options
|
|
38
|
-
* @param options.enabledPlugins - An array of enabledPlugins to load.
|
|
39
|
-
* @param options.nodes - An array of node options to create nodes from.
|
|
40
|
-
* @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
|
|
41
|
-
* @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
|
|
42
|
-
* @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
|
|
43
|
-
* @param options.clientName - The name of the client to send to Lavalink.
|
|
44
|
-
* @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
|
|
45
|
-
* @param options.useNode - The strategy to use when selecting a node to play on.
|
|
46
|
-
* @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track.
|
|
47
|
-
* @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
|
|
48
|
-
* @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
|
|
49
|
-
*/
|
|
50
|
-
constructor(options) {
|
|
35
|
+
constructor(options, isWrapper = false) {
|
|
51
36
|
super();
|
|
52
|
-
(0, managerCheck_1.default)(options);
|
|
37
|
+
(0, managerCheck_1.default)(options, isWrapper);
|
|
53
38
|
// Initialize structures
|
|
54
39
|
Utils_1.Structure.get("Player").init(this);
|
|
55
40
|
Utils_1.TrackUtils.init(this);
|
package/dist/structures/Node.js
CHANGED
|
@@ -759,7 +759,7 @@ class Node {
|
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
if (playNextOnEnd)
|
|
762
|
-
await player.play(
|
|
762
|
+
await player.play();
|
|
763
763
|
}
|
|
764
764
|
/**
|
|
765
765
|
* Plays the next track in the queue.
|
|
@@ -777,7 +777,7 @@ class Node {
|
|
|
777
777
|
await player.queue.setCurrent(await player.queue.dequeue());
|
|
778
778
|
this.manager.emit(Enums_1.ManagerEventTypes.TrackEnd, player, track, payload);
|
|
779
779
|
if (this.manager.options.playNextOnEnd)
|
|
780
|
-
await player.play(
|
|
780
|
+
await player.play();
|
|
781
781
|
}
|
|
782
782
|
/**
|
|
783
783
|
* Handles the event when a queue ends.
|
|
@@ -84,7 +84,7 @@ export interface ManagerOptions {
|
|
|
84
84
|
*/
|
|
85
85
|
send?: (packet: DiscordPacket) => unknown;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* User cache getter. Required when using `new Manager(...)` directly, optional for built-in wrappers.
|
|
88
88
|
* When resolving a user from a partial ID, this function will be called first.
|
|
89
89
|
* Should return the full user object if cached, or undefined if not.
|
|
90
90
|
* @param id The ID of the user to get.
|
|
@@ -92,7 +92,7 @@ export interface ManagerOptions {
|
|
|
92
92
|
*/
|
|
93
93
|
getUser?: (id: string) => AnyUser | undefined;
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
95
|
+
* Guild cache getter. Required when using `new Manager(...)` directly, optional for built-in wrappers.
|
|
96
96
|
* When resolving a guild from a partial ID, this function will be called first.
|
|
97
97
|
* Should return the full guild object if cached, or undefined if not.
|
|
98
98
|
* @param id The ID of the guild to get.
|
|
@@ -100,6 +100,14 @@ export interface ManagerOptions {
|
|
|
100
100
|
*/
|
|
101
101
|
getGuild?: (id: string) => AnyGuild | undefined;
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Manager options for direct `new Manager(...)` usage.
|
|
105
|
+
* Built-in wrappers provide these cache hooks automatically, so they only require {@link ManagerOptions}.
|
|
106
|
+
*/
|
|
107
|
+
export interface StandaloneManagerOptions extends ManagerOptions {
|
|
108
|
+
getUser: (id: string) => AnyUser | undefined;
|
|
109
|
+
getGuild: (id: string) => AnyGuild | undefined;
|
|
110
|
+
}
|
|
103
111
|
/**
|
|
104
112
|
* State Storage Options
|
|
105
113
|
*/
|
|
@@ -4,4 +4,4 @@ import { ManagerOptions } from "../structures/Types";
|
|
|
4
4
|
* @param options - The options to validate.
|
|
5
5
|
* @throws {MagmaStreamError} Throws if any required option is missing or invalid.
|
|
6
6
|
*/
|
|
7
|
-
export default function managerCheck(options: ManagerOptions): void;
|
|
7
|
+
export default function managerCheck(options: ManagerOptions, isWrapper?: boolean): void;
|
|
@@ -8,7 +8,7 @@ const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
|
8
8
|
* @param options - The options to validate.
|
|
9
9
|
* @throws {MagmaStreamError} Throws if any required option is missing or invalid.
|
|
10
10
|
*/
|
|
11
|
-
function managerCheck(options) {
|
|
11
|
+
function managerCheck(options, isWrapper = false) {
|
|
12
12
|
if (!options) {
|
|
13
13
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
14
14
|
code: Enums_1.MagmaStreamErrorCode.MANAGER_INVALID_CONFIG,
|
|
@@ -16,7 +16,7 @@ function managerCheck(options) {
|
|
|
16
16
|
context: { option: "options" },
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
const { playNextOnEnd, clientName, defaultSearchPlatform, autoPlaySearchPlatforms, nodes, enabledPlugins, send, trackPartial, enablePriorityMode, useNode, normalizeYouTubeTitles, lastFmApiKey, maxPreviousTracks, } = options;
|
|
19
|
+
const { playNextOnEnd, clientName, defaultSearchPlatform, autoPlaySearchPlatforms, nodes, enabledPlugins, send, trackPartial, enablePriorityMode, useNode, normalizeYouTubeTitles, lastFmApiKey, maxPreviousTracks, getUser, getGuild, } = options;
|
|
20
20
|
// Validate playNextOnEnd option
|
|
21
21
|
if (typeof playNextOnEnd !== "boolean") {
|
|
22
22
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
@@ -173,4 +173,34 @@ function managerCheck(options) {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
+
if (!isWrapper) {
|
|
177
|
+
if (typeof getUser === "undefined") {
|
|
178
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
179
|
+
code: Enums_1.MagmaStreamErrorCode.MANAGER_INVALID_CONFIG,
|
|
180
|
+
message: 'Manager option "getUser" is required when not using a built-in wrapper.',
|
|
181
|
+
context: { option: "getUser" },
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (typeof getGuild === "undefined") {
|
|
185
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
186
|
+
code: Enums_1.MagmaStreamErrorCode.MANAGER_INVALID_CONFIG,
|
|
187
|
+
message: 'Manager option "getGuild" is required when not using a built-in wrapper.',
|
|
188
|
+
context: { option: "getGuild" },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (typeof getUser !== "undefined" && typeof getUser !== "function") {
|
|
193
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
194
|
+
code: Enums_1.MagmaStreamErrorCode.MANAGER_INVALID_CONFIG,
|
|
195
|
+
message: 'Manager option "getUser" must be a function.',
|
|
196
|
+
context: { option: "getUser", value: getUser },
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (typeof getGuild !== "undefined" && typeof getGuild !== "function") {
|
|
200
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
201
|
+
code: Enums_1.MagmaStreamErrorCode.MANAGER_INVALID_CONFIG,
|
|
202
|
+
message: 'Manager option "getGuild" must be a function.',
|
|
203
|
+
context: { option: "getGuild", value: getGuild },
|
|
204
|
+
});
|
|
205
|
+
}
|
|
176
206
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
2
2
|
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
|
-
import { Client } from "cloudstorm";
|
|
3
|
+
import type { Client } from "cloudstorm";
|
|
4
4
|
import { AnyGuild, AnyUser, ManagerOptions, PortableUser } from "../structures/Types";
|
|
5
5
|
/**
|
|
6
6
|
* Cloudstorm wrapper for Magmastream.
|
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CloudstormManager = void 0;
|
|
4
4
|
const Manager_1 = require("../structures/Manager");
|
|
5
|
-
const cloudstorm_1 = require("cloudstorm");
|
|
6
5
|
const Enums_1 = require("../structures/Enums");
|
|
7
6
|
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
7
|
+
const GUILD_VOICE_STATES_INTENT = 128;
|
|
8
|
+
function hasCloudstormGuildVoiceStates(intents) {
|
|
9
|
+
if (typeof intents === "number") {
|
|
10
|
+
return (intents & GUILD_VOICE_STATES_INTENT) === GUILD_VOICE_STATES_INTENT;
|
|
11
|
+
}
|
|
12
|
+
if (typeof intents === "string") {
|
|
13
|
+
return intents === "GUILD_VOICE_STATES";
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(intents)) {
|
|
16
|
+
return intents.some((intent) => (typeof intent === "number" ? (intent & GUILD_VOICE_STATES_INTENT) === GUILD_VOICE_STATES_INTENT : intent === "GUILD_VOICE_STATES"));
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
8
20
|
/**
|
|
9
21
|
* Cloudstorm wrapper for Magmastream.
|
|
10
22
|
*
|
|
@@ -24,11 +36,10 @@ const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
|
24
36
|
class CloudstormManager extends Manager_1.Manager {
|
|
25
37
|
client;
|
|
26
38
|
constructor(client, options) {
|
|
27
|
-
super(options);
|
|
39
|
+
super(options, true);
|
|
28
40
|
this.client = client;
|
|
29
41
|
// Ensure GUILD_VOICE_STATES intent is enabled
|
|
30
|
-
|
|
31
|
-
if (!(resolvedIntents & cloudstorm_1.Intents.flags.GUILD_VOICE_STATES)) {
|
|
42
|
+
if (!hasCloudstormGuildVoiceStates(client.options.intents)) {
|
|
32
43
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
33
44
|
code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
|
|
34
45
|
message: "[CloudstormManager] Your Cloudstorm client must have the GUILD_VOICE_STATES intent enabled.",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Manager as BaseManager } from "../structures/Manager";
|
|
2
2
|
import type { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
3
|
-
import { Client, Guild, User } from "discord.js";
|
|
3
|
+
import type { Client, Guild, User } from "discord.js";
|
|
4
4
|
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
-
export * from "../index";
|
|
6
5
|
/**
|
|
7
6
|
* Discord.js wrapper for Magmastream.
|
|
8
7
|
*/
|
|
@@ -1,41 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DiscordJSManager = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const Manager_1 = require("../structures/Manager");
|
|
6
|
-
const discord_js_1 = require("discord.js");
|
|
7
|
-
const discord_js_2 = require("discord.js");
|
|
8
5
|
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
9
6
|
const Enums_1 = require("../structures/Enums");
|
|
10
|
-
const
|
|
11
|
-
tslib_1.__exportStar(require("../index"), exports);
|
|
7
|
+
const GUILD_VOICE_STATES_INTENT = 128;
|
|
12
8
|
/**
|
|
13
9
|
* Discord.js wrapper for Magmastream.
|
|
14
10
|
*/
|
|
15
11
|
class DiscordJSManager extends Manager_1.Manager {
|
|
16
12
|
client;
|
|
17
13
|
constructor(client, options) {
|
|
18
|
-
super(options);
|
|
14
|
+
super(options, true);
|
|
19
15
|
this.client = client;
|
|
20
|
-
if (!this.client.options.intents.has(
|
|
16
|
+
if (!this.client.options.intents.has(GUILD_VOICE_STATES_INTENT)) {
|
|
21
17
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
22
18
|
code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
|
|
23
19
|
message: "[Custom Wrapper] Your Discord.js client must have the GuildVoiceStates intent enabled.",
|
|
24
20
|
});
|
|
25
21
|
}
|
|
26
22
|
const attachReadyHandler = () => {
|
|
23
|
+
let handled = false;
|
|
27
24
|
const handler = () => {
|
|
25
|
+
if (handled)
|
|
26
|
+
return;
|
|
27
|
+
handled = true;
|
|
28
28
|
if (!this.options.clientId)
|
|
29
29
|
this.options.clientId = this.client.user.id;
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.client.once("clientReady", handler);
|
|
34
|
-
}
|
|
35
|
-
// Only attach ready if Discord.js < 14.22.0
|
|
36
|
-
if (major < 14 || (major === 14 && minor < 22)) {
|
|
37
|
-
this.client.once("ready", handler);
|
|
38
|
-
}
|
|
31
|
+
this.client.once("clientReady", handler);
|
|
32
|
+
this.client.once("ready", handler);
|
|
39
33
|
};
|
|
40
34
|
attachReadyHandler();
|
|
41
35
|
client.on("raw", async (data) => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
2
2
|
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
|
-
import { Bot, User } from "@discordeno/bot";
|
|
3
|
+
import type { Bot, User } from "@discordeno/bot";
|
|
4
4
|
import { AnyGuild, AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
-
export * from "../index";
|
|
6
5
|
/**
|
|
7
6
|
* Discordeno wrapper for Magmastream.
|
|
8
7
|
*/
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DiscordenoManager = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const Manager_1 = require("../structures/Manager");
|
|
6
|
-
const bot_1 = require("@discordeno/bot");
|
|
7
5
|
const Enums_1 = require("../structures/Enums");
|
|
8
6
|
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
9
|
-
|
|
7
|
+
const GUILD_VOICE_STATES_INTENT = 128;
|
|
8
|
+
const VOICE_STATE_UPDATE_OPCODE = 4;
|
|
10
9
|
/**
|
|
11
10
|
* Discordeno wrapper for Magmastream.
|
|
12
11
|
*/
|
|
13
12
|
class DiscordenoManager extends Manager_1.Manager {
|
|
14
13
|
client;
|
|
15
14
|
constructor(client, options) {
|
|
16
|
-
super(options);
|
|
15
|
+
super(options, true);
|
|
17
16
|
this.client = client;
|
|
18
17
|
// Ensure GuildVoiceStates intent is enabled
|
|
19
18
|
const intents = this.client.gateway.intents;
|
|
20
|
-
if (!(intents &
|
|
19
|
+
if (!(intents & GUILD_VOICE_STATES_INTENT)) {
|
|
21
20
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
22
21
|
code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
|
|
23
22
|
message: "[Custom Wrapper] Your Discordeno client must have the GuildVoiceStates intent enabled.",
|
|
@@ -49,7 +48,7 @@ class DiscordenoManager extends Manager_1.Manager {
|
|
|
49
48
|
// Send voice state updates to the guild shard
|
|
50
49
|
send(packet) {
|
|
51
50
|
this.client.gateway.sendPayload(this.client.gateway.calculateShardId(packet.d.guild_id), {
|
|
52
|
-
op:
|
|
51
|
+
op: VOICE_STATE_UPDATE_OPCODE,
|
|
53
52
|
d: packet.d,
|
|
54
53
|
});
|
|
55
54
|
}
|
package/dist/wrappers/eris.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
|
2
2
|
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
3
|
import type { Client, Guild, User } from "eris";
|
|
4
4
|
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
-
export * from "../index";
|
|
6
5
|
/**
|
|
7
6
|
* Eris wrapper for Magmastream.
|
|
8
7
|
*/
|
package/dist/wrappers/eris.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ErisManager = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const v10_1 = require("discord-api-types/v10");
|
|
6
5
|
const Manager_1 = require("../structures/Manager");
|
|
7
6
|
const Enums_1 = require("../structures/Enums");
|
|
8
7
|
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
9
|
-
tslib_1.__exportStar(require("../index"), exports);
|
|
10
8
|
/**
|
|
11
9
|
* Eris wrapper for Magmastream.
|
|
12
10
|
*/
|
|
13
11
|
class ErisManager extends Manager_1.Manager {
|
|
14
12
|
client;
|
|
15
13
|
constructor(client, options) {
|
|
16
|
-
super(options);
|
|
14
|
+
super(options, true);
|
|
17
15
|
this.client = client;
|
|
18
16
|
const intents = this.client.options.intents;
|
|
19
17
|
const hasGuildVoiceStates = typeof intents === "number" ? (intents & v10_1.GatewayIntentBits.GuildVoiceStates) === v10_1.GatewayIntentBits.GuildVoiceStates : intents.includes("guildVoiceStates");
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
2
2
|
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
3
|
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
4
|
-
import { Client, Guild, User } from "oceanic.js";
|
|
5
|
-
export * from "../index";
|
|
4
|
+
import type { Client, Guild, User } from "oceanic.js";
|
|
6
5
|
/**
|
|
7
6
|
* Oceanic wrapper for Magmastream.
|
|
8
7
|
*/
|
package/dist/wrappers/oceanic.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OceanicManager = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const Manager_1 = require("../structures/Manager");
|
|
6
|
-
const oceanic_js_1 = require("oceanic.js");
|
|
7
5
|
const Enums_1 = require("../structures/Enums");
|
|
8
6
|
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
9
|
-
|
|
7
|
+
const GUILD_VOICE_STATES_INTENT = 128;
|
|
10
8
|
/**
|
|
11
9
|
* Oceanic wrapper for Magmastream.
|
|
12
10
|
*/
|
|
13
11
|
class OceanicManager extends Manager_1.Manager {
|
|
14
12
|
client;
|
|
15
13
|
constructor(client, options) {
|
|
16
|
-
super(options);
|
|
14
|
+
super(options, true);
|
|
17
15
|
this.client = client;
|
|
18
16
|
const intents = this.client.shards.options.intents;
|
|
19
|
-
const
|
|
20
|
-
const hasGuildVoiceStates = typeof intents === "number" ? (intents & Intents.GUILD_VOICE_STATES) === Intents.GUILD_VOICE_STATES : intents.includes("GUILD_VOICE_STATES");
|
|
17
|
+
const hasGuildVoiceStates = typeof intents === "number" ? (intents & GUILD_VOICE_STATES_INTENT) === GUILD_VOICE_STATES_INTENT : intents.includes("GUILD_VOICE_STATES");
|
|
21
18
|
if (!hasGuildVoiceStates) {
|
|
22
19
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
23
20
|
code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Manager as BaseManager } from "../structures/Manager";
|
|
2
2
|
import { type GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
3
|
-
import { Client, Guild, User, WorkerClient } from "seyfert";
|
|
3
|
+
import type { Client, Guild, User, WorkerClient } from "seyfert";
|
|
4
4
|
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
-
export * from "../index";
|
|
6
5
|
/**
|
|
7
6
|
* Seyfert wrapper for Magmastream.
|
|
8
7
|
*
|
package/dist/wrappers/seyfert.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SeyfertManager = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const Manager_1 = require("../structures/Manager");
|
|
6
|
-
const seyfert_1 = require("seyfert");
|
|
7
|
-
const types_1 = require("seyfert/lib/types");
|
|
8
|
-
const common_1 = require("seyfert/lib/common");
|
|
9
5
|
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
10
6
|
const Enums_1 = require("../structures/Enums");
|
|
11
|
-
|
|
7
|
+
const GUILD_VOICE_STATES_INTENT = 128;
|
|
8
|
+
function calculateShardId(guildId, totalShards) {
|
|
9
|
+
return Number((BigInt(guildId) >> BigInt(22)) % BigInt(totalShards));
|
|
10
|
+
}
|
|
12
11
|
/**
|
|
13
12
|
* Seyfert wrapper for Magmastream.
|
|
14
13
|
*
|
|
@@ -37,12 +36,12 @@ tslib_1.__exportStar(require("../index"), exports);
|
|
|
37
36
|
class SeyfertManager extends Manager_1.Manager {
|
|
38
37
|
client;
|
|
39
38
|
constructor(client, options) {
|
|
40
|
-
super(options);
|
|
39
|
+
super(options, true);
|
|
41
40
|
this.client = client;
|
|
42
41
|
this.client
|
|
43
42
|
.getRC()
|
|
44
43
|
.then((rc) => {
|
|
45
|
-
if (!(rc.intents &
|
|
44
|
+
if (!(rc.intents & GUILD_VOICE_STATES_INTENT)) {
|
|
46
45
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
47
46
|
code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
|
|
48
47
|
message: "[Custom Wrapper] Your Seyfert client must have the GuildVoiceStates intent enabled.",
|
|
@@ -56,11 +55,11 @@ class SeyfertManager extends Manager_1.Manager {
|
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
send(packet) {
|
|
59
|
-
if (this.client
|
|
60
|
-
this.client.gateway.send(
|
|
58
|
+
if ("gateway" in this.client) {
|
|
59
|
+
this.client.gateway.send(calculateShardId(packet.d.guild_id, this.client.gateway.totalShards), packet);
|
|
61
60
|
}
|
|
62
61
|
else {
|
|
63
|
-
this.client.shards.get(
|
|
62
|
+
this.client.shards.get(this.client.calculateShardId(packet.d.guild_id))?.send(true, packet);
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
async resolveUser(user) {
|
package/package.json
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "magmastream",
|
|
3
|
-
"version": "2.10.2-
|
|
4
|
-
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"prepare": "npm run build",
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"types": "rtb --dist dist",
|
|
14
|
-
"format": "prettier --write .",
|
|
15
|
-
"format:check": "prettier --check .",
|
|
16
|
-
"lint": "eslint \"src/**/*.{ts,js}\"",
|
|
17
|
-
"lint:fix": "eslint --fix \"src/**/*.{ts,js}\"",
|
|
18
|
-
"ci": "run-s format:check lint build types",
|
|
19
|
-
"release:alpha": "npm run format && npm run lint:fix && npm run ci && npm version prerelease --preid=alpha && npm publish --tag alpha && git push && git push --follow-tags",
|
|
20
|
-
"release:dev": "npm run format && npm run lint:fix && npm run ci && npm version prerelease --preid=dev && npm publish --tag dev && git push && git push --follow-tags"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@favware/rollup-type-bundler": "^4.0.0",
|
|
24
|
-
"@types/jsdom": "^28.0.0",
|
|
25
|
-
"@types/lodash": "^4.17.24",
|
|
26
|
-
"@types/node": "^25.3.5",
|
|
27
|
-
"@types/ws": "^8.18.1",
|
|
28
|
-
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
29
|
-
"@typescript-eslint/parser": "^8.56.1",
|
|
30
|
-
"eslint": "^10.0.3",
|
|
31
|
-
"npm-run-all": "^4.1.5",
|
|
32
|
-
"prettier": "^3.8.1",
|
|
33
|
-
"typedoc": "^0.28.17",
|
|
34
|
-
"typedoc-plugin-no-inherit": "^1.6.1",
|
|
35
|
-
"typescript": "^5.9.3"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@discordjs/collection": "^2.1.1",
|
|
39
|
-
"axios": "^1.13.6",
|
|
40
|
-
"events": "^3.3.0",
|
|
41
|
-
"ioredis": "^5.10.0",
|
|
42
|
-
"jsdom": "^28.1.0",
|
|
43
|
-
"lodash": "^4.17.23",
|
|
44
|
-
"safe-stable-stringify": "^2.5.0",
|
|
45
|
-
"tslib": "^2.8.1",
|
|
46
|
-
"ws": "^8.19.0"
|
|
47
|
-
},
|
|
48
|
-
"optionalDependencies": {
|
|
49
|
-
"cloudstorm": "0.17.x",
|
|
50
|
-
"discord.js": "14.x",
|
|
51
|
-
"discordeno": "21.x",
|
|
52
|
-
"eris": "0.18.x",
|
|
53
|
-
"oceanic.js": "1.14.x",
|
|
54
|
-
"seyfert": "4.x"
|
|
55
|
-
},
|
|
56
|
-
"overrides": {
|
|
57
|
-
"undici": "^7.0.0"
|
|
58
|
-
},
|
|
59
|
-
"engines": {
|
|
60
|
-
"node": ">=20.19.0"
|
|
61
|
-
},
|
|
62
|
-
"eslintConfig": {
|
|
63
|
-
"root": true,
|
|
64
|
-
"parser": "@typescript-eslint/parser",
|
|
65
|
-
"plugins": [
|
|
66
|
-
"@typescript-eslint"
|
|
67
|
-
],
|
|
68
|
-
"rules": {
|
|
69
|
-
"object-curly-spacing": [
|
|
70
|
-
"error",
|
|
71
|
-
"always"
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"extends": [
|
|
75
|
-
"eslint:recommended",
|
|
76
|
-
"plugin:@typescript-eslint/recommended"
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
"keywords": [
|
|
80
|
-
"lavalink client",
|
|
81
|
-
"wrapper",
|
|
82
|
-
"typescript",
|
|
83
|
-
"discord.js",
|
|
84
|
-
"node.js",
|
|
85
|
-
"java",
|
|
86
|
-
"javascript",
|
|
87
|
-
"audio streaming",
|
|
88
|
-
"music bot",
|
|
89
|
-
"voice chat",
|
|
90
|
-
"discord integration",
|
|
91
|
-
"high performance",
|
|
92
|
-
"scalable",
|
|
93
|
-
"easy-to-use",
|
|
94
|
-
"feature-rich",
|
|
95
|
-
"cross-platform",
|
|
96
|
-
"seamless integration",
|
|
97
|
-
"community support",
|
|
98
|
-
"documentation",
|
|
99
|
-
"open-source",
|
|
100
|
-
"lavalink",
|
|
101
|
-
"magmastream"
|
|
102
|
-
],
|
|
103
|
-
"repository": {
|
|
104
|
-
"type": "git",
|
|
105
|
-
"url": "https://gitryx.com/MagmaStream/magmastream.git"
|
|
106
|
-
},
|
|
107
|
-
"homepage": "https://docs.magmastream.com",
|
|
108
|
-
"author": "Abel Purnwasy",
|
|
109
|
-
"license": "Apache-2.0"
|
|
110
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "magmastream",
|
|
3
|
+
"version": "2.10.2-dev.1",
|
|
4
|
+
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prepare": "npm run build",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"types": "rtb --dist dist",
|
|
14
|
+
"format": "prettier --write .",
|
|
15
|
+
"format:check": "prettier --check .",
|
|
16
|
+
"lint": "eslint \"src/**/*.{ts,js}\"",
|
|
17
|
+
"lint:fix": "eslint --fix \"src/**/*.{ts,js}\"",
|
|
18
|
+
"ci": "run-s format:check lint build types",
|
|
19
|
+
"release:alpha": "npm run format && npm run lint:fix && npm run ci && npm version prerelease --preid=alpha && npm publish --tag alpha && git push && git push --follow-tags",
|
|
20
|
+
"release:dev": "npm run format && npm run lint:fix && npm run ci && npm version prerelease --preid=dev && npm publish --tag dev && git push && git push --follow-tags"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@favware/rollup-type-bundler": "^4.0.0",
|
|
24
|
+
"@types/jsdom": "^28.0.0",
|
|
25
|
+
"@types/lodash": "^4.17.24",
|
|
26
|
+
"@types/node": "^25.3.5",
|
|
27
|
+
"@types/ws": "^8.18.1",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
29
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
30
|
+
"eslint": "^10.0.3",
|
|
31
|
+
"npm-run-all": "^4.1.5",
|
|
32
|
+
"prettier": "^3.8.1",
|
|
33
|
+
"typedoc": "^0.28.17",
|
|
34
|
+
"typedoc-plugin-no-inherit": "^1.6.1",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@discordjs/collection": "^2.1.1",
|
|
39
|
+
"axios": "^1.13.6",
|
|
40
|
+
"events": "^3.3.0",
|
|
41
|
+
"ioredis": "^5.10.0",
|
|
42
|
+
"jsdom": "^28.1.0",
|
|
43
|
+
"lodash": "^4.17.23",
|
|
44
|
+
"safe-stable-stringify": "^2.5.0",
|
|
45
|
+
"tslib": "^2.8.1",
|
|
46
|
+
"ws": "^8.19.0"
|
|
47
|
+
},
|
|
48
|
+
"optionalDependencies": {
|
|
49
|
+
"cloudstorm": "0.17.x",
|
|
50
|
+
"discord.js": "14.x",
|
|
51
|
+
"discordeno": "21.x",
|
|
52
|
+
"eris": "0.18.x",
|
|
53
|
+
"oceanic.js": "1.14.x",
|
|
54
|
+
"seyfert": "4.x"
|
|
55
|
+
},
|
|
56
|
+
"overrides": {
|
|
57
|
+
"undici": "^7.0.0"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=20.19.0"
|
|
61
|
+
},
|
|
62
|
+
"eslintConfig": {
|
|
63
|
+
"root": true,
|
|
64
|
+
"parser": "@typescript-eslint/parser",
|
|
65
|
+
"plugins": [
|
|
66
|
+
"@typescript-eslint"
|
|
67
|
+
],
|
|
68
|
+
"rules": {
|
|
69
|
+
"object-curly-spacing": [
|
|
70
|
+
"error",
|
|
71
|
+
"always"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"extends": [
|
|
75
|
+
"eslint:recommended",
|
|
76
|
+
"plugin:@typescript-eslint/recommended"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"keywords": [
|
|
80
|
+
"lavalink client",
|
|
81
|
+
"wrapper",
|
|
82
|
+
"typescript",
|
|
83
|
+
"discord.js",
|
|
84
|
+
"node.js",
|
|
85
|
+
"java",
|
|
86
|
+
"javascript",
|
|
87
|
+
"audio streaming",
|
|
88
|
+
"music bot",
|
|
89
|
+
"voice chat",
|
|
90
|
+
"discord integration",
|
|
91
|
+
"high performance",
|
|
92
|
+
"scalable",
|
|
93
|
+
"easy-to-use",
|
|
94
|
+
"feature-rich",
|
|
95
|
+
"cross-platform",
|
|
96
|
+
"seamless integration",
|
|
97
|
+
"community support",
|
|
98
|
+
"documentation",
|
|
99
|
+
"open-source",
|
|
100
|
+
"lavalink",
|
|
101
|
+
"magmastream"
|
|
102
|
+
],
|
|
103
|
+
"repository": {
|
|
104
|
+
"type": "git",
|
|
105
|
+
"url": "https://gitryx.com/MagmaStream/magmastream.git"
|
|
106
|
+
},
|
|
107
|
+
"homepage": "https://docs.magmastream.com",
|
|
108
|
+
"author": "Abel Purnwasy",
|
|
109
|
+
"license": "Apache-2.0"
|
|
110
|
+
}
|