magmastream 2.10.2-alpha.2 → 2.10.2-alpha.4
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/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/wrappers/cloudstorm.d.ts +27 -0
- package/dist/wrappers/cloudstorm.js +69 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export * from "./statestorage/MemoryQueue";
|
|
|
7
7
|
export * from "./structures/Rest";
|
|
8
8
|
export * from "./structures/Utils";
|
|
9
9
|
export * from "./structures/MagmastreamError";
|
|
10
|
-
export * from "./wrappers/
|
|
10
|
+
export * from "./wrappers/cloudstorm";
|
|
11
11
|
export * from "./wrappers/discord.js";
|
|
12
|
+
export * from "./wrappers/discordeno";
|
|
12
13
|
export * from "./wrappers/eris";
|
|
13
14
|
export * from "./wrappers/oceanic";
|
|
14
15
|
export * from "./wrappers/seyfert";
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,9 @@ tslib_1.__exportStar(require("./structures/Rest"), exports);
|
|
|
11
11
|
tslib_1.__exportStar(require("./structures/Utils"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./structures/MagmastreamError"), exports);
|
|
13
13
|
// wrappers
|
|
14
|
-
tslib_1.__exportStar(require("./wrappers/
|
|
14
|
+
tslib_1.__exportStar(require("./wrappers/cloudstorm"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./wrappers/discord.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./wrappers/discordeno"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./wrappers/eris"), exports);
|
|
17
18
|
tslib_1.__exportStar(require("./wrappers/oceanic"), exports);
|
|
18
19
|
tslib_1.__exportStar(require("./wrappers/seyfert"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
2
|
+
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
|
+
import { Client } from "cloudstorm";
|
|
4
|
+
import { AnyGuild, AnyUser, ManagerOptions, PortableUser } from "../structures/Types";
|
|
5
|
+
/**
|
|
6
|
+
* Cloudstorm wrapper for Magmastream.
|
|
7
|
+
*
|
|
8
|
+
* @note Unlike other wrappers, CloudStorm is a gateway-only library with no cache.
|
|
9
|
+
* You must manually call `manager.init({ clientId: "your-bot-id" })` inside your `ready` event.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const client = new Client("token", { intents: ["GUILDS", "GUILD_VOICE_STATES"] });
|
|
14
|
+
* const manager = new CloudstormManager(client, options);
|
|
15
|
+
*
|
|
16
|
+
* client.once("ready", async () => {
|
|
17
|
+
* await manager.init({ clientId: "your-bot-id" });
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class CloudstormManager extends BaseManager {
|
|
22
|
+
readonly client: Client;
|
|
23
|
+
constructor(client: Client, options?: ManagerOptions);
|
|
24
|
+
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
25
|
+
resolveUser(user: AnyUser | string): Promise<PortableUser>;
|
|
26
|
+
resolveGuild(guildId: string): AnyGuild;
|
|
27
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudstormManager = void 0;
|
|
4
|
+
const Manager_1 = require("../structures/Manager");
|
|
5
|
+
const cloudstorm_1 = require("cloudstorm");
|
|
6
|
+
const Enums_1 = require("../structures/Enums");
|
|
7
|
+
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
8
|
+
/**
|
|
9
|
+
* Cloudstorm wrapper for Magmastream.
|
|
10
|
+
*
|
|
11
|
+
* @note Unlike other wrappers, CloudStorm is a gateway-only library with no cache.
|
|
12
|
+
* You must manually call `manager.init({ clientId: "your-bot-id" })` inside your `ready` event.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const client = new Client("token", { intents: ["GUILDS", "GUILD_VOICE_STATES"] });
|
|
17
|
+
* const manager = new CloudstormManager(client, options);
|
|
18
|
+
*
|
|
19
|
+
* client.once("ready", async () => {
|
|
20
|
+
* await manager.init({ clientId: "your-bot-id" });
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class CloudstormManager extends Manager_1.Manager {
|
|
25
|
+
client;
|
|
26
|
+
constructor(client, options) {
|
|
27
|
+
super(options);
|
|
28
|
+
this.client = client;
|
|
29
|
+
// Ensure GUILD_VOICE_STATES intent is enabled
|
|
30
|
+
const resolvedIntents = cloudstorm_1.Intents.resolve(client.options.intents ?? 0);
|
|
31
|
+
if (!(resolvedIntents & cloudstorm_1.Intents.flags.GUILD_VOICE_STATES)) {
|
|
32
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
33
|
+
code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
|
|
34
|
+
message: "[CloudstormManager] Your Cloudstorm client must have the GUILD_VOICE_STATES intent enabled.",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// Chain incoming gateway events into updateVoiceState
|
|
38
|
+
client.on("event", async (data) => {
|
|
39
|
+
if (data.t === "VOICE_STATE_UPDATE" || data.t === "VOICE_SERVER_UPDATE") {
|
|
40
|
+
await this.updateVoiceState(data);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
send(packet) {
|
|
45
|
+
const totalShards = this.client.options.totalShards;
|
|
46
|
+
if (!totalShards)
|
|
47
|
+
return;
|
|
48
|
+
const shardId = Number((BigInt(packet.d.guild_id) >> BigInt(22)) % BigInt(totalShards));
|
|
49
|
+
const shard = this.client.shardManager.shards[shardId];
|
|
50
|
+
if (shard)
|
|
51
|
+
shard.connector.sendMessage(packet);
|
|
52
|
+
}
|
|
53
|
+
// CloudStorm has no user/guild cache — return minimal portable info only.
|
|
54
|
+
async resolveUser(user) {
|
|
55
|
+
const id = typeof user === "string" ? user : String(user.id);
|
|
56
|
+
const cached = this.getUserFromCache(id);
|
|
57
|
+
if (cached)
|
|
58
|
+
return cached;
|
|
59
|
+
return {
|
|
60
|
+
id,
|
|
61
|
+
username: typeof user === "string" ? undefined : user.username,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
resolveGuild(guildId) {
|
|
65
|
+
// Try user-provided cache getter
|
|
66
|
+
return this.getGuildFromCache(guildId);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.CloudstormManager = CloudstormManager;
|
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.4",
|
|
4
4
|
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,10 +46,11 @@
|
|
|
46
46
|
"ws": "^8.19.0"
|
|
47
47
|
},
|
|
48
48
|
"optionalDependencies": {
|
|
49
|
+
"cloudstorm": "0.17.x",
|
|
49
50
|
"discord.js": "14.x",
|
|
50
51
|
"discordeno": "21.x",
|
|
51
52
|
"eris": "0.18.x",
|
|
52
|
-
"oceanic.js": "1.
|
|
53
|
+
"oceanic.js": "1.14.x",
|
|
53
54
|
"seyfert": "4.x"
|
|
54
55
|
},
|
|
55
56
|
"overrides": {
|