magmastream 2.9.3-dev.2 → 2.9.3-dev.21

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.
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DiscordenoManager = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Manager_1 = require("../structures/Manager");
6
+ const bot_1 = require("@discordeno/bot");
7
+ const Enums_1 = require("../structures/Enums");
8
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
9
+ tslib_1.__exportStar(require("../index"), exports);
10
+ /**
11
+ * Discordeno wrapper for Magmastream.
12
+ */
13
+ class DiscordenoManager extends Manager_1.Manager {
14
+ client;
15
+ constructor(client, options) {
16
+ super(options);
17
+ this.client = client;
18
+ // Ensure GuildVoiceStates intent is enabled
19
+ const intents = this.client.gateway.intents;
20
+ if (!(intents & bot_1.GatewayIntents.GuildVoiceStates)) {
21
+ throw new MagmastreamError_1.MagmaStreamError({
22
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
23
+ message: "[Custom Wrapper] Your Discordeno client must have the GuildVoiceStates intent enabled.",
24
+ });
25
+ }
26
+ // Chain READY event
27
+ const oldReady = this.client.handlers.READY;
28
+ this.client.handlers.READY = (bot, payload, shardId) => {
29
+ if (oldReady)
30
+ oldReady(bot, payload, shardId);
31
+ if (!this.options?.clientId)
32
+ this.options.clientId = this.client.applicationId.toString();
33
+ };
34
+ // Chain VOICE_STATE_UPDATE event
35
+ const oldVoiceState = this.client.handlers.VOICE_STATE_UPDATE;
36
+ this.client.handlers.VOICE_STATE_UPDATE = (bot, payload, shardId) => {
37
+ if (oldVoiceState)
38
+ oldVoiceState(bot, payload, shardId);
39
+ this.updateVoiceState(payload);
40
+ };
41
+ // Chain VOICE_SERVER_UPDATE event
42
+ const oldVoiceServer = this.client.handlers.VOICE_SERVER_UPDATE;
43
+ this.client.handlers.VOICE_SERVER_UPDATE = (bot, payload, shardId) => {
44
+ if (oldVoiceServer)
45
+ oldVoiceServer(bot, payload, shardId);
46
+ this.updateVoiceState(payload);
47
+ };
48
+ }
49
+ // Send voice state updates to the guild shard
50
+ send(packet) {
51
+ this.client.gateway.sendPayload(this.client.gateway.calculateShardId(packet.d.guild_id), {
52
+ op: bot_1.GatewayOpcodes.VoiceStateUpdate,
53
+ d: packet.d,
54
+ });
55
+ }
56
+ /**
57
+ * Resolve a user by ID or partial info.
58
+ * Uses user-provided cache getter if available, otherwise falls back to minimal info.
59
+ */
60
+ async resolveUser(user) {
61
+ const id = typeof user === "string" ? user : String(user.id);
62
+ // Try user-provided cache getter
63
+ const cached = this.getUserFromCache(id);
64
+ if (cached)
65
+ return cached;
66
+ // Fallback: return minimal info
67
+ return {
68
+ id,
69
+ username: typeof user === "string" ? undefined : user.username,
70
+ };
71
+ }
72
+ }
73
+ exports.DiscordenoManager = DiscordenoManager;
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ErisManager = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const v10_1 = require("discord-api-types/v10");
5
6
  const Manager_1 = require("../structures/Manager");
7
+ const Enums_1 = require("../structures/Enums");
8
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
6
9
  tslib_1.__exportStar(require("../index"), exports);
7
10
  /**
8
11
  * Eris wrapper for Magmastream.
@@ -12,11 +15,19 @@ class ErisManager extends Manager_1.Manager {
12
15
  constructor(client, options) {
13
16
  super(options);
14
17
  this.client = client;
15
- client.once("ready", () => {
18
+ const intents = this.client.options.intents;
19
+ const hasGuildVoiceStates = typeof intents === "number" ? (intents & v10_1.GatewayIntentBits.GuildVoiceStates) === v10_1.GatewayIntentBits.GuildVoiceStates : intents.includes("guildVoiceStates");
20
+ if (!hasGuildVoiceStates) {
21
+ throw new MagmastreamError_1.MagmaStreamError({
22
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
23
+ message: "[Custom Wrapper] Your Eris client must have the guildVoiceStates intent enabled.",
24
+ });
25
+ }
26
+ this.client.once("ready", () => {
16
27
  if (!this.options.clientId)
17
28
  this.options.clientId = client.user.id;
18
29
  });
19
- client.on("rawWS", async (packet) => {
30
+ this.client.on("rawWS", async (packet) => {
20
31
  await this.updateVoiceState(packet);
21
32
  });
22
33
  }
@@ -26,7 +37,7 @@ class ErisManager extends Manager_1.Manager {
26
37
  guild.shard.sendWS(packet.op, packet.d);
27
38
  }
28
39
  async resolveUser(user) {
29
- const id = typeof user === "string" ? user : user.id;
40
+ const id = typeof user === "string" ? user : String(user.id);
30
41
  const cached = this.client.users.get(id);
31
42
  if (cached)
32
43
  return cached;
@@ -35,5 +46,11 @@ class ErisManager extends Manager_1.Manager {
35
46
  username: typeof user === "string" ? undefined : user.username,
36
47
  };
37
48
  }
49
+ resolveGuild(guildId) {
50
+ const cached = this.client.guilds.get(guildId);
51
+ if (cached)
52
+ return cached;
53
+ return null;
54
+ }
38
55
  }
39
56
  exports.ErisManager = ErisManager;
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OceanicManager = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Manager_1 = require("../structures/Manager");
6
+ const oceanic_js_1 = require("oceanic.js");
7
+ const Enums_1 = require("../structures/Enums");
8
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
6
9
  tslib_1.__exportStar(require("../index"), exports);
7
10
  /**
8
11
  * Oceanic wrapper for Magmastream.
@@ -12,11 +15,20 @@ class OceanicManager extends Manager_1.Manager {
12
15
  constructor(client, options) {
13
16
  super(options);
14
17
  this.client = client;
15
- client.once("ready", () => {
18
+ const intents = this.client.shards.options.intents;
19
+ const { Intents } = oceanic_js_1.Constants;
20
+ const hasGuildVoiceStates = typeof intents === "number" ? (intents & Intents.GUILD_VOICE_STATES) === Intents.GUILD_VOICE_STATES : intents.includes("GUILD_VOICE_STATES");
21
+ if (!hasGuildVoiceStates) {
22
+ throw new MagmastreamError_1.MagmaStreamError({
23
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
24
+ message: "[Custom Wrapper] Your Oceanic client must have the GUILD_VOICE_STATES intent enabled.",
25
+ });
26
+ }
27
+ this.client.once("ready", () => {
16
28
  if (!this.options.clientId)
17
- this.options.clientId = client.user.id;
29
+ this.options.clientId = this.client.user.id;
18
30
  });
19
- client.on("packet", async (packet) => {
31
+ this.client.on("packet", async (packet) => {
20
32
  await this.updateVoiceState(packet);
21
33
  });
22
34
  }
@@ -26,7 +38,7 @@ class OceanicManager extends Manager_1.Manager {
26
38
  guild.shard.send(packet.op, packet.d);
27
39
  }
28
40
  async resolveUser(user) {
29
- const id = typeof user === "string" ? user : user.id;
41
+ const id = typeof user === "string" ? user : String(user.id);
30
42
  const cached = this.client.users.get(id);
31
43
  if (cached)
32
44
  return cached;
@@ -35,5 +47,11 @@ class OceanicManager extends Manager_1.Manager {
35
47
  username: typeof user === "string" ? undefined : user.username,
36
48
  };
37
49
  }
50
+ resolveGuild(guildId) {
51
+ const cached = this.client.guilds.get(guildId);
52
+ if (cached)
53
+ return cached;
54
+ return null;
55
+ }
38
56
  }
39
57
  exports.OceanicManager = OceanicManager;
@@ -4,7 +4,10 @@ exports.SeyfertManager = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Manager_1 = require("../structures/Manager");
6
6
  const seyfert_1 = require("seyfert");
7
+ const types_1 = require("seyfert/lib/types");
7
8
  const common_1 = require("seyfert/lib/common");
9
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
10
+ const Enums_1 = require("../structures/Enums");
8
11
  tslib_1.__exportStar(require("../index"), exports);
9
12
  /**
10
13
  * Seyfert wrapper for Magmastream.
@@ -36,6 +39,21 @@ class SeyfertManager extends Manager_1.Manager {
36
39
  constructor(client, options) {
37
40
  super(options);
38
41
  this.client = client;
42
+ this.client
43
+ .getRC()
44
+ .then((rc) => {
45
+ if (!(rc.intents & types_1.GatewayIntentBits.GuildVoiceStates)) {
46
+ throw new MagmastreamError_1.MagmaStreamError({
47
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
48
+ message: "[Custom Wrapper] Your Seyfert client must have the GuildVoiceStates intent enabled.",
49
+ });
50
+ }
51
+ })
52
+ .catch((error) => {
53
+ queueMicrotask(() => {
54
+ throw error;
55
+ });
56
+ });
39
57
  }
40
58
  send(packet) {
41
59
  if (this.client instanceof seyfert_1.Client) {
@@ -46,7 +64,7 @@ class SeyfertManager extends Manager_1.Manager {
46
64
  }
47
65
  }
48
66
  async resolveUser(user) {
49
- const id = typeof user === "string" ? user : user.id;
67
+ const id = typeof user === "string" ? user : String(user.id);
50
68
  const cached = this.client.cache.users?.get(id);
51
69
  if (cached)
52
70
  return cached;
@@ -57,5 +75,11 @@ class SeyfertManager extends Manager_1.Manager {
57
75
  return { id, username: typeof user === "string" ? undefined : user.username };
58
76
  }
59
77
  }
78
+ resolveGuild(guildId) {
79
+ const cached = this.client.cache.guilds?.get(guildId);
80
+ if (cached)
81
+ return cached;
82
+ return null;
83
+ }
60
84
  }
61
85
  exports.SeyfertManager = SeyfertManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.3-dev.2",
3
+ "version": "2.9.3-dev.21",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,45 +10,51 @@
10
10
  "scripts": {
11
11
  "build": "tsc",
12
12
  "types": "rtb --dist dist",
13
- "lint": "eslint src",
14
- "lint:fix": "eslint --fix src",
15
- "ci": "run-s lint:fix lint build types",
16
- "release:dev": "npm run ci && npm version prerelease --preid=dev && npm run ci && npm publish --tag dev"
13
+ "format": "prettier --write .",
14
+ "format:check": "prettier --check .",
15
+ "lint": "eslint \"src/**/*.{ts,js}\"",
16
+ "lint:fix": "eslint --fix \"src/**/*.{ts,js}\"",
17
+ "ci": "run-s format:check lint build types",
18
+ "release:dev": "npm run format && npm run lint:fix && npm run ci && npm version prerelease --preid=dev && git push && npm publish --tag dev"
17
19
  },
18
20
  "devDependencies": {
19
21
  "@favware/rollup-type-bundler": "^4.0.0",
20
- "@types/jsdom": "^21.1.7",
21
- "@types/lodash": "^4.17.20",
22
- "@types/node": "^22.16.5",
22
+ "@types/jsdom": "^27.0.0",
23
+ "@types/lodash": "^4.17.24",
24
+ "@types/node": "^25.3.0",
23
25
  "@types/ws": "^8.18.1",
24
- "@typescript-eslint/eslint-plugin": "^8.37.0",
25
- "@typescript-eslint/parser": "^8.37.0",
26
- "eslint": "^9.31.0",
26
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
27
+ "@typescript-eslint/parser": "^8.56.0",
28
+ "eslint": "^10.0.1",
27
29
  "npm-run-all": "^4.1.5",
28
- "typedoc": "^0.27.9",
30
+ "prettier": "^3.8.1",
31
+ "typedoc": "^0.28.17",
29
32
  "typedoc-plugin-no-inherit": "^1.6.1",
30
- "typescript": "^5.8.3"
33
+ "typescript": "^5.9.3"
31
34
  },
32
35
  "dependencies": {
33
36
  "@discordjs/collection": "^2.1.1",
34
- "axios": "^1.10.0",
37
+ "axios": "^1.13.5",
35
38
  "events": "^3.3.0",
36
- "ioredis": "^5.6.1",
37
- "jsdom": "^26.1.0",
38
- "lodash": "^4.17.21",
39
+ "ioredis": "^5.9.3",
40
+ "jsdom": "^28.1.0",
41
+ "lodash": "^4.17.23",
39
42
  "safe-stable-stringify": "^2.5.0",
40
43
  "tslib": "^2.8.1",
41
- "ws": "^8.18.3"
44
+ "ws": "^8.19.0"
42
45
  },
43
46
  "optionalDependencies": {
44
- "detritus-client": "0.16.x",
45
47
  "discord.js": "14.x",
48
+ "discordeno": "21.x",
46
49
  "eris": "0.18.x",
47
- "oceanic.js": "1.12.0",
48
- "seyfert": "3.2.x"
50
+ "oceanic.js": "^1.13.0",
51
+ "seyfert": "4.x"
52
+ },
53
+ "overrides": {
54
+ "undici": "^6.23.0"
49
55
  },
50
56
  "engines": {
51
- "node": ">=16.0.0"
57
+ "node": ">=20.19.0"
52
58
  },
53
59
  "eslintConfig": {
54
60
  "root": true,
@@ -92,7 +98,8 @@
92
98
  "magmastream"
93
99
  ],
94
100
  "repository": {
95
- "url": "git+https://github.com/Blackfort-Hosting/magmastream.git#main"
101
+ "type": "git",
102
+ "url": "git+https://gitryx.com/MagmaStream/magmastream.git#main"
96
103
  },
97
104
  "homepage": "https://docs.magmastream.com",
98
105
  "author": "Abel Purnwasy",
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DetritusManager = void 0;
4
- const tslib_1 = require("tslib");
5
- const Manager_1 = require("../structures/Manager");
6
- const detritus_client_1 = require("detritus-client");
7
- tslib_1.__exportStar(require("../index"), exports);
8
- /**
9
- * Detritus wrapper for Magmastream.
10
- */
11
- class DetritusManager extends Manager_1.Manager {
12
- client;
13
- constructor(client, options) {
14
- super(options);
15
- this.client = client;
16
- client.once("ready", () => {
17
- if (!this.options.clientId)
18
- this.options.clientId = client instanceof detritus_client_1.ClusterClient ? client.applicationId : client.clientId;
19
- });
20
- client.on("raw", async (packet) => {
21
- await this.updateVoiceState(packet);
22
- });
23
- }
24
- send(packet) {
25
- const asCluster = this.client;
26
- const asShard = this.client;
27
- if (asShard.guilds)
28
- return asShard.gateway.send(packet.op, packet.d);
29
- if (asCluster.shards) {
30
- const shard = asCluster.shards.find((c) => c.guilds.has(packet.d.guild_id));
31
- if (shard)
32
- shard.gateway.send(packet.op, packet.d);
33
- }
34
- }
35
- async resolveUser(user) {
36
- const id = typeof user === "string" ? user : user.id;
37
- if (this.client instanceof detritus_client_1.ShardClient) {
38
- const cached = this.client.users.get(id);
39
- if (cached)
40
- return { id: cached.id, username: cached.username };
41
- }
42
- else if (this.client instanceof detritus_client_1.ClusterClient) {
43
- for (const [, shard] of this.client.shards) {
44
- const cached = shard.users.get(id);
45
- if (cached)
46
- return { id: cached.id, username: cached.username };
47
- }
48
- }
49
- return typeof user === "string" ? { id: user } : user;
50
- }
51
- }
52
- exports.DetritusManager = DetritusManager;