magmastream 2.9.2-dev.1 → 2.9.2-dev.10
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 +103 -23
- package/dist/index.js +1 -0
- package/dist/statestorage/JsonQueue.js +332 -176
- package/dist/statestorage/MemoryQueue.js +288 -203
- package/dist/statestorage/RedisQueue.js +482 -204
- package/dist/structures/Enums.js +110 -1
- package/dist/structures/Filters.js +27 -13
- package/dist/structures/MagmastreamError.js +19 -0
- package/dist/structures/Manager.js +351 -219
- package/dist/structures/Node.js +227 -66
- package/dist/structures/Player.js +199 -58
- package/dist/structures/Rest.js +23 -12
- package/dist/structures/Utils.js +83 -67
- package/dist/utils/managerCheck.js +99 -21
- package/dist/utils/nodeCheck.js +59 -34
- package/dist/utils/playerCheck.js +47 -28
- package/package.json +3 -2
|
@@ -1,56 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = playerCheck;
|
|
4
|
+
const Enums_1 = require("../structures/Enums");
|
|
5
|
+
const MagmastreamError_1 = require("../structures/MagmastreamError");
|
|
4
6
|
/**
|
|
5
7
|
* Validates the provided PlayerOptions object.
|
|
6
8
|
* @param options - The options to validate.
|
|
7
|
-
* @throws {
|
|
9
|
+
* @throws {MagmaStreamError} Throws if any required option is missing or invalid.
|
|
8
10
|
*/
|
|
9
11
|
function playerCheck(options) {
|
|
10
|
-
// If the options are empty, throw an error.
|
|
11
12
|
if (!options) {
|
|
12
|
-
throw new
|
|
13
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
14
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
15
|
+
message: "PlayerOptions must not be empty.",
|
|
16
|
+
});
|
|
13
17
|
}
|
|
14
|
-
// Get the guild ID, node, selfDeafen, selfMute, textChannelId, voiceChannelId, volume, and applyVolumeAsFilter from the options.
|
|
15
18
|
const { guildId, nodeIdentifier, selfDeafen, selfMute, textChannelId, voiceChannelId, volume, applyVolumeAsFilter } = options;
|
|
16
|
-
// Validate the guild ID option
|
|
17
|
-
// The guild ID option must be a non-empty string.
|
|
18
19
|
if (!/^\d+$/.test(guildId)) {
|
|
19
|
-
throw new
|
|
20
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
21
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
22
|
+
message: 'Player option "guildId" must be present and a non-empty string.',
|
|
23
|
+
context: { guildId },
|
|
24
|
+
});
|
|
20
25
|
}
|
|
21
|
-
// Validate the node option
|
|
22
|
-
// The node option must be a string.
|
|
23
26
|
if (nodeIdentifier && typeof nodeIdentifier !== "string") {
|
|
24
|
-
throw new
|
|
27
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
28
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
29
|
+
message: 'Player option "nodeIdentifier" must be a non-empty string.',
|
|
30
|
+
context: { nodeIdentifier },
|
|
31
|
+
});
|
|
25
32
|
}
|
|
26
|
-
// Validate the selfDeafen option
|
|
27
|
-
// The selfDeafen option must be a boolean.
|
|
28
33
|
if (typeof selfDeafen !== "undefined" && typeof selfDeafen !== "boolean") {
|
|
29
|
-
throw new
|
|
34
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
35
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
36
|
+
message: 'Player option "selfDeafen" must be a boolean.',
|
|
37
|
+
context: { selfDeafen },
|
|
38
|
+
});
|
|
30
39
|
}
|
|
31
|
-
// Validate the selfMute option
|
|
32
|
-
// The selfMute option must be a boolean.
|
|
33
40
|
if (typeof selfMute !== "undefined" && typeof selfMute !== "boolean") {
|
|
34
|
-
throw new
|
|
41
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
42
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
43
|
+
message: 'Player option "selfMute" must be a boolean.',
|
|
44
|
+
context: { selfMute },
|
|
45
|
+
});
|
|
35
46
|
}
|
|
36
|
-
// Validate the textChannelId option
|
|
37
|
-
// The textChannelId option must be a non-empty string.
|
|
38
47
|
if (textChannelId && !/^\d+$/.test(textChannelId)) {
|
|
39
|
-
throw new
|
|
48
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
49
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
50
|
+
message: 'Player option "textChannelId" must be a non-empty string.',
|
|
51
|
+
context: { textChannelId },
|
|
52
|
+
});
|
|
40
53
|
}
|
|
41
|
-
// Validate the voiceChannelId option
|
|
42
|
-
// The voiceChannelId option must be a non-empty string.
|
|
43
54
|
if (voiceChannelId && !/^\d+$/.test(voiceChannelId)) {
|
|
44
|
-
throw new
|
|
55
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
56
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
57
|
+
message: 'Player option "voiceChannelId" must be a non-empty string.',
|
|
58
|
+
context: { voiceChannelId },
|
|
59
|
+
});
|
|
45
60
|
}
|
|
46
|
-
// Validate the volume option
|
|
47
|
-
// The volume option must be a number.
|
|
48
61
|
if (typeof volume !== "undefined" && typeof volume !== "number") {
|
|
49
|
-
throw new
|
|
62
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
63
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
64
|
+
message: 'Player option "volume" must be a number.',
|
|
65
|
+
context: { volume },
|
|
66
|
+
});
|
|
50
67
|
}
|
|
51
|
-
// Validate the applyVolumeAsFilter option
|
|
52
|
-
// The applyVolumeAsFilter option must be a boolean.
|
|
53
68
|
if (typeof applyVolumeAsFilter !== "undefined" && typeof applyVolumeAsFilter !== "boolean") {
|
|
54
|
-
throw new
|
|
69
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
70
|
+
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
71
|
+
message: 'Player option "applyVolumeAsFilter" must be a boolean.',
|
|
72
|
+
context: { applyVolumeAsFilter },
|
|
73
|
+
});
|
|
55
74
|
}
|
|
56
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magmastream",
|
|
3
|
-
"version": "2.9.2-dev.
|
|
3
|
+
"version": "2.9.2-dev.10",
|
|
4
4
|
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"types": "rtb --dist dist",
|
|
13
13
|
"lint": "eslint src",
|
|
14
14
|
"lint:fix": "eslint --fix src",
|
|
15
|
-
"ci": "run-s lint:fix lint build types"
|
|
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"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@favware/rollup-type-bundler": "^4.0.0",
|