magmastream 2.10.2-alpha.12 → 2.10.2-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/structures/Rest.js +18 -19
- package/dist/structures/Types.d.ts +26 -0
- package/dist/structures/Utils.js +29 -19
- package/dist/wrappers/cloudstorm.d.ts +1 -1
- package/dist/wrappers/cloudstorm.js +14 -3
- package/dist/wrappers/discord.js.d.ts +1 -2
- package/dist/wrappers/discord.js.js +11 -9
- package/dist/wrappers/discordeno.d.ts +1 -2
- package/dist/wrappers/discordeno.js +4 -5
- package/dist/wrappers/eris.d.ts +0 -1
- package/dist/wrappers/eris.js +0 -2
- package/dist/wrappers/oceanic.d.ts +1 -2
- package/dist/wrappers/oceanic.js +2 -5
- package/dist/wrappers/seyfert.d.ts +1 -2
- package/dist/wrappers/seyfert.js +8 -9
- package/package.json +6 -7
package/dist/structures/Rest.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Rest = void 0;
|
|
4
|
-
const
|
|
5
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
4
|
+
const undici_1 = require("undici");
|
|
6
5
|
const Enums_1 = require("./Enums");
|
|
7
6
|
const Utils_1 = require("./Utils");
|
|
8
7
|
const MagmastreamError_1 = require("./MagmastreamError");
|
|
@@ -105,43 +104,43 @@ class Rest {
|
|
|
105
104
|
*/
|
|
106
105
|
async request(method, endpoint, body) {
|
|
107
106
|
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[REST] ${method} request to ${endpoint} with body: ${Utils_1.JSONUtils.safe(body, 2)}`);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
url: this.url + endpoint,
|
|
111
|
-
headers: {
|
|
112
|
-
"Content-Type": "application/json",
|
|
113
|
-
Authorization: this.password,
|
|
114
|
-
},
|
|
115
|
-
data: body,
|
|
116
|
-
timeout: this.node.options.apiRequestTimeoutMs,
|
|
117
|
-
validateStatus: () => true,
|
|
118
|
-
};
|
|
107
|
+
const controller = new AbortController();
|
|
108
|
+
const timeoutHandle = setTimeout(() => controller.abort(), this.node.options.apiRequestTimeoutMs);
|
|
119
109
|
let response = null;
|
|
120
110
|
try {
|
|
121
|
-
response = await (0,
|
|
111
|
+
response = await (0, undici_1.fetch)(this.url + endpoint, {
|
|
112
|
+
method,
|
|
113
|
+
headers: {
|
|
114
|
+
"Content-Type": "application/json",
|
|
115
|
+
Authorization: this.password,
|
|
116
|
+
},
|
|
117
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
118
|
+
signal: controller.signal,
|
|
119
|
+
});
|
|
122
120
|
}
|
|
123
121
|
catch (e) {
|
|
124
|
-
const isTimeout =
|
|
122
|
+
const isTimeout = e instanceof Error && e.name === "AbortError";
|
|
125
123
|
const message = e instanceof Error ? e.message : "Unknown error";
|
|
126
124
|
const error = new MagmastreamError_1.MagmaStreamError({
|
|
127
125
|
code: Enums_1.MagmaStreamErrorCode.REST_REQUEST_FAILED,
|
|
128
126
|
message: `${isTimeout ? "Timeout" : "Network error"} on ${method} ${endpoint}: ${message}`,
|
|
129
127
|
});
|
|
130
|
-
// Emit so the node manager can react (e.g. trigger reconnection logic)
|
|
131
128
|
this.manager.emit(Enums_1.ManagerEventTypes.NodeError, this.node, error);
|
|
132
129
|
return null;
|
|
133
130
|
}
|
|
134
|
-
|
|
131
|
+
finally {
|
|
132
|
+
clearTimeout(timeoutHandle);
|
|
133
|
+
}
|
|
134
|
+
const { status } = response;
|
|
135
|
+
const data = status !== 204 ? await response.json() : null;
|
|
135
136
|
if (status >= 200 && status < 300) {
|
|
136
137
|
return data;
|
|
137
138
|
}
|
|
138
139
|
if (status === 404) {
|
|
139
140
|
if (data?.message === "Guild not found") {
|
|
140
|
-
// Lavalink sometimes returns "Guild not found" for inactive players
|
|
141
141
|
return [];
|
|
142
142
|
}
|
|
143
143
|
if (data?.message === "Session not found") {
|
|
144
|
-
// Session expired — trigger reconnection instead of crashing
|
|
145
144
|
this.manager.emit(Enums_1.ManagerEventTypes.NodeError, this.node, new MagmastreamError_1.MagmaStreamError({ code: Enums_1.MagmaStreamErrorCode.REST_REQUEST_FAILED, message: "Session not found" }));
|
|
146
145
|
return [];
|
|
147
146
|
}
|
|
@@ -1237,6 +1237,32 @@ export interface ReverbOptions {
|
|
|
1237
1237
|
roomSize?: number;
|
|
1238
1238
|
damping?: number;
|
|
1239
1239
|
}
|
|
1240
|
+
export interface LastFmResponse {
|
|
1241
|
+
error?: number;
|
|
1242
|
+
toptracks?: {
|
|
1243
|
+
track: Array<{
|
|
1244
|
+
name: string;
|
|
1245
|
+
artist: {
|
|
1246
|
+
name: string;
|
|
1247
|
+
};
|
|
1248
|
+
}>;
|
|
1249
|
+
};
|
|
1250
|
+
similartracks?: {
|
|
1251
|
+
track: Array<{
|
|
1252
|
+
name: string;
|
|
1253
|
+
artist: {
|
|
1254
|
+
name: string;
|
|
1255
|
+
};
|
|
1256
|
+
}>;
|
|
1257
|
+
};
|
|
1258
|
+
results?: {
|
|
1259
|
+
trackmatches?: {
|
|
1260
|
+
track: Array<{
|
|
1261
|
+
artist: string;
|
|
1262
|
+
}>;
|
|
1263
|
+
};
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1240
1266
|
/**
|
|
1241
1267
|
* Queue interface
|
|
1242
1268
|
*/
|
package/dist/structures/Utils.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JSONUtils = exports.Structure = exports.PlayerUtils = exports.AutoPlayUtils = exports.TrackUtils = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
6
|
-
const
|
|
6
|
+
const undici_1 = require("undici");
|
|
7
7
|
const jsdom_1 = require("jsdom");
|
|
8
8
|
const Enums_1 = require("./Enums");
|
|
9
9
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -250,11 +250,12 @@ class AutoPlayUtils {
|
|
|
250
250
|
if (!title) {
|
|
251
251
|
// No title provided, search for the artist's top tracks
|
|
252
252
|
const noTitleUrl = `https://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=${artist}&autocorrect=1&api_key=${apiKey}&format=json`;
|
|
253
|
-
const response = await (0,
|
|
254
|
-
|
|
253
|
+
const response = await (0, undici_1.fetch)(noTitleUrl);
|
|
254
|
+
const data = (await response.json());
|
|
255
|
+
if (data.error || !data.toptracks?.track?.length) {
|
|
255
256
|
return [];
|
|
256
257
|
}
|
|
257
|
-
const randomTrack =
|
|
258
|
+
const randomTrack = data.toptracks.track[Math.floor(Math.random() * data.toptracks.track.length)];
|
|
258
259
|
const resolvedTracks = await this.resolveTracksFromQuery(`${randomTrack.artist.name} - ${randomTrack.name}`, this.manager.options.defaultSearchPlatform, track.requester);
|
|
259
260
|
if (!resolvedTracks.length)
|
|
260
261
|
return [];
|
|
@@ -263,8 +264,9 @@ class AutoPlayUtils {
|
|
|
263
264
|
if (!artist) {
|
|
264
265
|
// No artist provided, search for the track title
|
|
265
266
|
const noArtistUrl = `https://ws.audioscrobbler.com/2.0/?method=track.search&track=${title}&api_key=${apiKey}&format=json`;
|
|
266
|
-
const response = await (0,
|
|
267
|
-
|
|
267
|
+
const response = await (0, undici_1.fetch)(noArtistUrl);
|
|
268
|
+
const noArtistData = (await response.json());
|
|
269
|
+
artist = noArtistData.results?.trackmatches?.track?.[0]?.artist;
|
|
268
270
|
if (!artist) {
|
|
269
271
|
return [];
|
|
270
272
|
}
|
|
@@ -272,22 +274,24 @@ class AutoPlayUtils {
|
|
|
272
274
|
}
|
|
273
275
|
// Search for similar tracks to the current track
|
|
274
276
|
const url = `https://ws.audioscrobbler.com/2.0/?method=track.getSimilar&artist=${artist}&track=${title}&limit=10&autocorrect=1&api_key=${apiKey}&format=json`;
|
|
275
|
-
let
|
|
277
|
+
let similarData;
|
|
276
278
|
try {
|
|
277
|
-
response = await (0,
|
|
279
|
+
const response = await (0, undici_1.fetch)(url);
|
|
280
|
+
similarData = (await response.json());
|
|
278
281
|
}
|
|
279
282
|
catch (error) {
|
|
280
283
|
console.error("[AutoPlay] Error fetching similar tracks from Last.fm:", error);
|
|
281
284
|
return [];
|
|
282
285
|
}
|
|
283
|
-
if (
|
|
286
|
+
if (similarData.error || !similarData.similartracks?.track?.length) {
|
|
284
287
|
// Retry the request if the first attempt fails
|
|
285
288
|
const retryUrl = `https://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=${artist}&autocorrect=1&api_key=${apiKey}&format=json`;
|
|
286
|
-
const retryResponse = await (0,
|
|
287
|
-
|
|
289
|
+
const retryResponse = await (0, undici_1.fetch)(retryUrl);
|
|
290
|
+
const retryData = (await retryResponse.json());
|
|
291
|
+
if (retryData.error || !retryData.toptracks?.track?.length) {
|
|
288
292
|
return [];
|
|
289
293
|
}
|
|
290
|
-
const randomTrack =
|
|
294
|
+
const randomTrack = retryData.toptracks.track[Math.floor(Math.random() * retryData.toptracks.track.length)];
|
|
291
295
|
const resolvedTracks = await this.resolveTracksFromQuery(`${randomTrack.artist.name} - ${randomTrack.name}`, this.manager.options.defaultSearchPlatform, track.requester);
|
|
292
296
|
if (!resolvedTracks.length)
|
|
293
297
|
return [];
|
|
@@ -297,7 +301,7 @@ class AutoPlayUtils {
|
|
|
297
301
|
}
|
|
298
302
|
return filteredTracks;
|
|
299
303
|
}
|
|
300
|
-
const randomTrack =
|
|
304
|
+
const randomTrack = similarData.similartracks.track.sort(() => Math.random() - 0.5).shift();
|
|
301
305
|
if (!randomTrack) {
|
|
302
306
|
return [];
|
|
303
307
|
}
|
|
@@ -356,15 +360,21 @@ class AutoPlayUtils {
|
|
|
356
360
|
return [];
|
|
357
361
|
track = resolvedTrack;
|
|
358
362
|
}
|
|
363
|
+
let html;
|
|
359
364
|
try {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
+
let recommendedRes = null;
|
|
366
|
+
try {
|
|
367
|
+
recommendedRes = await (0, undici_1.fetch)(`${track.uri}/recommended`);
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
console.error(`[AutoPlay] Failed to fetch SoundCloud recommendations.`, err);
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
if (!recommendedRes.ok) {
|
|
374
|
+
console.error(`[AutoPlay] Failed to fetch SoundCloud recommendations. Status: ${recommendedRes.status}`);
|
|
365
375
|
return [];
|
|
366
376
|
}
|
|
367
|
-
|
|
377
|
+
html = await recommendedRes.text();
|
|
368
378
|
const dom = new jsdom_1.JSDOM(html);
|
|
369
379
|
const window = dom.window;
|
|
370
380
|
// Narrow the element types using instanceof
|
|
@@ -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
|
*
|
|
@@ -27,8 +39,7 @@ class CloudstormManager extends Manager_1.Manager {
|
|
|
27
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,14 +1,12 @@
|
|
|
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
|
|
7
|
-
const discord_js_2 = require("discord.js");
|
|
5
|
+
const module_1 = require("module");
|
|
8
6
|
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
9
7
|
const Enums_1 = require("../structures/Enums");
|
|
10
|
-
const
|
|
11
|
-
|
|
8
|
+
const GUILD_VOICE_STATES_INTENT = 128;
|
|
9
|
+
const moduleRequire = (0, module_1.createRequire)(__filename);
|
|
12
10
|
/**
|
|
13
11
|
* Discord.js wrapper for Magmastream.
|
|
14
12
|
*/
|
|
@@ -17,23 +15,27 @@ class DiscordJSManager extends Manager_1.Manager {
|
|
|
17
15
|
constructor(client, options) {
|
|
18
16
|
super(options, true);
|
|
19
17
|
this.client = client;
|
|
20
|
-
|
|
18
|
+
const { version: djsVersion } = moduleRequire("discord.js");
|
|
19
|
+
const [major, minor] = djsVersion.split(".").map(Number);
|
|
20
|
+
if (!this.client.options.intents.has(GUILD_VOICE_STATES_INTENT)) {
|
|
21
21
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
22
22
|
code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
|
|
23
23
|
message: "[Custom Wrapper] Your Discord.js client must have the GuildVoiceStates intent enabled.",
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
const attachReadyHandler = () => {
|
|
27
|
+
let handled = false;
|
|
27
28
|
const handler = () => {
|
|
29
|
+
if (handled)
|
|
30
|
+
return;
|
|
31
|
+
handled = true;
|
|
28
32
|
if (!this.options.clientId)
|
|
29
33
|
this.options.clientId = this.client.user.id;
|
|
30
34
|
};
|
|
31
|
-
// Only attach clientReady if Discord.js >= 14.22.0
|
|
32
35
|
if (major > 14 || (major === 14 && minor >= 22)) {
|
|
33
36
|
this.client.once("clientReady", handler);
|
|
34
37
|
}
|
|
35
|
-
|
|
36
|
-
if (major < 14 || (major === 14 && minor < 22)) {
|
|
38
|
+
else {
|
|
37
39
|
this.client.once("ready", handler);
|
|
38
40
|
}
|
|
39
41
|
};
|
|
@@ -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,12 +1,11 @@
|
|
|
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
|
*/
|
|
@@ -17,7 +16,7 @@ class DiscordenoManager extends Manager_1.Manager {
|
|
|
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,12 +1,10 @@
|
|
|
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
|
*/
|
|
@@ -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,12 +1,10 @@
|
|
|
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
|
*/
|
|
@@ -16,8 +14,7 @@ class OceanicManager extends Manager_1.Manager {
|
|
|
16
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
|
*
|
|
@@ -42,7 +41,7 @@ class SeyfertManager extends Manager_1.Manager {
|
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magmastream",
|
|
3
|
-
"version": "2.10.2-alpha.
|
|
3
|
+
"version": "2.10.2-alpha.13",
|
|
4
4
|
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
"lint": "eslint \"src/**/*.{ts,js}\"",
|
|
17
17
|
"lint:fix": "eslint --fix \"src/**/*.{ts,js}\"",
|
|
18
18
|
"ci": "run-s format:check lint build types",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"version:alpha": "node scripts/prerelease-version.cjs alpha",
|
|
20
|
+
"version:dev": "node scripts/prerelease-version.cjs dev",
|
|
21
|
+
"release:alpha": "npm run format && npm run lint:fix && npm run ci && npm run version:alpha && npm publish --tag alpha && git push && git push --follow-tags",
|
|
22
|
+
"release:dev": "npm run format && npm run lint:fix && npm run ci && npm run version:dev && npm publish --tag dev && git push && git push --follow-tags"
|
|
21
23
|
},
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@favware/rollup-type-bundler": "^4.0.0",
|
|
@@ -36,13 +38,13 @@
|
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
40
|
"@discordjs/collection": "^2.1.1",
|
|
39
|
-
"axios": "^1.13.6",
|
|
40
41
|
"events": "^3.3.0",
|
|
41
42
|
"ioredis": "^5.10.0",
|
|
42
43
|
"jsdom": "^28.1.0",
|
|
43
44
|
"lodash": "^4.17.23",
|
|
44
45
|
"safe-stable-stringify": "^2.5.0",
|
|
45
46
|
"tslib": "^2.8.1",
|
|
47
|
+
"undici": "7.24.6",
|
|
46
48
|
"ws": "^8.19.0"
|
|
47
49
|
},
|
|
48
50
|
"optionalDependencies": {
|
|
@@ -53,9 +55,6 @@
|
|
|
53
55
|
"oceanic.js": "1.14.x",
|
|
54
56
|
"seyfert": "4.x"
|
|
55
57
|
},
|
|
56
|
-
"overrides": {
|
|
57
|
-
"undici": "^7.0.0"
|
|
58
|
-
},
|
|
59
58
|
"engines": {
|
|
60
59
|
"node": ">=20.19.0"
|
|
61
60
|
},
|