for-modules 1.1.5 → 1.1.6

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/package.json CHANGED
@@ -1,24 +1,53 @@
1
- {
2
- "name": "for-modules",
3
- "main": "dist/index.js",
4
- "types": "dist/index.d.ts",
5
- "version": "1.1.5",
6
- "description": "For lavalink",
7
- "publishConfig": {
8
- "registry": "https://registry.npmjs.org/",
9
- "access": "public"
10
- },
11
- "bugs": {
12
- "url": "https://github.com/kungkmg/For-modules/issues"
13
- },
14
- "homepage": "https://github.com/kungkmg/For-modules#readme",
15
- "peerDependencies": {
16
- "typescript": "^5.5.4"
17
- },
18
- "keywords": [
19
- "lavalink",
20
- "discord",
21
- "TikTok",
22
- "api"
23
- ]
1
+ {
2
+ "name": "for-modules",
3
+ "main": "dist/index.js",
4
+ "types": "dist/index.d.ts",
5
+ "version": "1.1.6",
6
+ "description": "For lavalink",
7
+ "license": "MIT",
8
+ "author": "v",
9
+ "scripts": {
10
+ "start": "tsc -p . && bun dist/index.js",
11
+ "build:js": "npx babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline",
12
+ "lint": "npx eslint src/**/*.ts",
13
+ "test:manager": "bun test/manager.ts",
14
+ "test:player": "bun test/player.ts"
15
+ },
16
+ "devDependencies": {
17
+ "@eslint/js": "^9.10.0",
18
+ "@types/bun": "latest",
19
+ "eslint": "^9.10.0",
20
+ "globals": "^15.9.0",
21
+ "typescript-eslint": "^8.4.0",
22
+ "@babel/cli": "^7.25.6",
23
+ "@babel/core": "^7.25.2",
24
+ "@babel/preset-env": "^7.25.4",
25
+ "@babel/preset-typescript": "^7.24.7"
26
+ },
27
+ "publishConfig": {
28
+ "registry": "https://registry.npmjs.org/",
29
+ "access": "public"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/kungkmg/For-modules/issues"
33
+ },
34
+ "homepage": "https://github.com/kungkmg/For-modules#readme",
35
+ "peerDependencies": {
36
+ "typescript": "^5.5.4"
37
+ },
38
+ "dependencies": {
39
+ "@discordjs/collection": "^2.1.1",
40
+ "axios": "^1.7.7",
41
+ "discord.js": "^14.16.1",
42
+ "events": "^3.3.0",
43
+ "tiny-typed-emitter": "^2.1.0",
44
+ "ws": "^8.18.0",
45
+ "yt-dlp-wrap": "^2.3.12"
46
+ },
47
+ "keywords": [
48
+ "lavalink",
49
+ "discord",
50
+ "wrapper",
51
+ "api"
52
+ ]
24
53
  }
package/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:recommended"
5
+ ]
6
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext", "DOM"],
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "moduleDetection": "force",
7
+ "jsx": "react-jsx",
8
+ "allowJs": true,
9
+ "moduleResolution": "bundler",
10
+ "allowImportingTsExtensions": true,
11
+ "skipLibCheck": true,
12
+ "noFallthroughCasesInSwitch": true,
13
+ "noUnusedLocals": false,
14
+ "noUnusedParameters": false,
15
+ "noPropertyAccessFromIndexSignature": false,
16
+ "rootDir": "./src",
17
+ "outDir": "./dist",
18
+ "declaration": true,
19
+ "emitDeclarationOnly": true,
20
+ "isolatedModules": true
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["node_modules"]
24
+ }
@@ -1,109 +0,0 @@
1
- import { Band } from "../Utils/FiltersEqualizers";
2
- import { Player } from "./Player";
3
- export declare class Filters {
4
- distortion: DistortionOptions | null;
5
- equalizer: Band[];
6
- karaoke: KaraokeOptions | null;
7
- player: Player;
8
- rotation: RotationOptions | null;
9
- timescale: TimescaleOptions | null;
10
- vibrato: VibratoOptions | null;
11
- volume: number;
12
- private filterStatus;
13
- constructor(player: Player);
14
- private updateFilters;
15
- private applyFilter;
16
- private setFilterStatus;
17
- /**
18
- * Sets the equalizer bands and updates the filters.
19
- * @param bands - The equalizer bands.
20
- */
21
- setEqualizer(bands?: Band[]): this;
22
- /** Applies the eight dimension audio effect. */
23
- eightD(): this;
24
- /** Applies the bass boost effect. */
25
- bassBoost(): this;
26
- /** Applies the nightcore effect. */
27
- nightcore(): this;
28
- /** Applies the slow motion audio effect. */
29
- slowmo(): this;
30
- /** Applies the soft audio effect. */
31
- soft(): this;
32
- /** Applies the television audio effect. */
33
- tv(): this;
34
- /** Applies the treble bass effect. */
35
- trebleBass(): this;
36
- /** Applies the vaporwave effect. */
37
- vaporwave(): this;
38
- /** Applies the distortion audio effect. */
39
- distort(): this;
40
- /** Applies the karaoke options specified by the filter. */
41
- setKaraoke(karaoke?: KaraokeOptions): this;
42
- /** Applies the timescale options specified by the filter. */
43
- setTimescale(timescale?: TimescaleOptions): this;
44
- /** Applies the vibrato options specified by the filter. */
45
- setVibrato(vibrato?: VibratoOptions): this;
46
- /** Applies the rotation options specified by the filter. */
47
- setRotation(rotation?: RotationOptions): this;
48
- /** Applies the distortion options specified by the filter. */
49
- setDistortion(distortion?: DistortionOptions): this;
50
- /** Removes the audio effects and resets the filter status. */
51
- clearFilters(): Promise<this>;
52
- /** Returns the status of the specified filter . */
53
- getFilterStatus(filter: keyof AvailableFilters): boolean;
54
- }
55
- /** Options for adjusting the timescale of audio. */
56
- interface TimescaleOptions {
57
- /** The speed factor for the timescale. */
58
- speed?: number;
59
- /** The pitch factor for the timescale. */
60
- pitch?: number;
61
- /** The rate factor for the timescale. */
62
- rate?: number;
63
- }
64
- /** Options for applying vibrato effect to audio. */
65
- interface VibratoOptions {
66
- /** The frequency of the vibrato effect. */
67
- frequency: number;
68
- /** * The depth of the vibrato effect.*/
69
- depth: number;
70
- }
71
- /** Options for applying rotation effect to audio. */
72
- interface RotationOptions {
73
- /** The rotation speed in Hertz (Hz). */
74
- rotationHz: number;
75
- }
76
- /** Options for applying karaoke effect to audio. */
77
- interface KaraokeOptions {
78
- /** The level of karaoke effect. */
79
- level?: number;
80
- /** The mono level of karaoke effect. */
81
- monoLevel?: number;
82
- /** The filter band of karaoke effect. */
83
- filterBand?: number;
84
- /** The filter width of karaoke effect. */
85
- filterWidth?: number;
86
- }
87
- interface DistortionOptions {
88
- sinOffset?: number;
89
- sinScale?: number;
90
- cosOffset?: number;
91
- cosScale?: number;
92
- tanOffset?: number;
93
- tanScale?: number;
94
- offset?: number;
95
- scale?: number;
96
- }
97
- interface AvailableFilters {
98
- bassboost: boolean;
99
- distort: boolean;
100
- eightD: boolean;
101
- karaoke: boolean;
102
- nightcore: boolean;
103
- slowmo: boolean;
104
- soft: boolean;
105
- trebleBass: boolean;
106
- tv: boolean;
107
- vaporwave: boolean;
108
- }
109
- export {};
@@ -1,192 +0,0 @@
1
- import { EventEmitter } from "events";
2
- import { LoadType, Plugin, TrackData, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, WebSocketClosedEvent } from "./Utils";
3
- import { Collection } from "@discordjs/collection";
4
- import { Node, NodeOptions } from "./Node";
5
- import { Player, PlayerOptions, Track, UnresolvedTrack } from "./Player";
6
- import { VoiceState } from "..";
7
- import { ClientUser, User } from "discord.js";
8
- /**
9
- * The main hub for interacting with Lavalink and using Magmastream,
10
- */
11
- export declare class Manager extends EventEmitter {
12
- static readonly DEFAULT_SOURCES: Record<SearchPlatform, string>;
13
- /** The map of players. */
14
- readonly players: Collection<string, Player>;
15
- /** The map of nodes. */
16
- readonly nodes: Collection<string, Node>;
17
- /** The options that were set. */
18
- readonly options: ManagerOptions;
19
- private initiated;
20
- caches: Collection<string, SearchResult>;
21
- /** Returns the nodes that has the least load. */
22
- get leastLoadNode(): Collection<string, Node>;
23
- /** Returns the nodes that has the least amount of players. */
24
- private get leastPlayersNode();
25
- /** Returns a node based on priority. */
26
- private get priorityNode();
27
- /** Returns the node to use. */
28
- get useableNodes(): Node;
29
- /**
30
- * Initiates the Manager class.
31
- * @param options
32
- */
33
- constructor(options: ManagerOptions);
34
- /**
35
- * Initiates the Manager.
36
- * @param clientId
37
- */
38
- init(clientId?: string): this;
39
- /**
40
- * Searches the enabled sources based off the URL or the `source` property.
41
- * @param query
42
- * @param requester
43
- * @returns The search result.
44
- */
45
- search(query: string | SearchQuery, requester?: User | ClientUser): Promise<SearchResult>;
46
- /**
47
- * Decodes the base64 encoded tracks and returns a TrackData array.
48
- * @param tracks
49
- */
50
- decodeTracks(tracks: string[]): Promise<TrackData[]>;
51
- /**
52
- * Decodes the base64 encoded track and returns a TrackData.
53
- * @param track
54
- */
55
- decodeTrack(track: string): Promise<TrackData>;
56
- /**
57
- * Creates a player or returns one if it already exists.
58
- * @param options
59
- */
60
- create(options: PlayerOptions): Player;
61
- /**
62
- * Returns a player or undefined if it does not exist.
63
- * @param guild
64
- */
65
- get(guild: string): Player | undefined;
66
- /**
67
- * Destroys a player if it exists.
68
- * @param guild
69
- */
70
- destroy(guild: string): void;
71
- /**
72
- * Creates a node or returns one if it already exists.
73
- * @param options
74
- */
75
- createNode(options: NodeOptions): Node;
76
- /**
77
- * Destroys a node if it exists.
78
- * @param identifier
79
- */
80
- destroyNode(identifier: string): void;
81
- /**
82
- * Sends voice data to the Lavalink server.
83
- * @param data
84
- */
85
- updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>;
86
- }
87
- export interface Payload {
88
- /** The OP code */
89
- op: number;
90
- d: {
91
- guild_id: string;
92
- channel_id: string | null;
93
- self_mute: boolean;
94
- self_deaf: boolean;
95
- };
96
- }
97
- export interface ManagerOptions {
98
- /** Use priority mode over least amount of player or load? */
99
- usePriority?: boolean;
100
- /** Use the least amount of players or least load? */
101
- useNode?: "leastLoad" | "leastPlayers";
102
- /** The array of nodes to connect to. */
103
- nodes?: NodeOptions[];
104
- /** The client ID to use. */
105
- clientId?: string;
106
- /** Value to use for the `Client-Name` header. */
107
- clientName?: string;
108
- /** The shard count. */
109
- shards?: number;
110
- /** A array of plugins to use. */
111
- plugins?: Plugin[];
112
- /** Whether players should automatically play the next song. */
113
- autoPlay?: boolean;
114
- /** An array of track properties to keep. `track` will always be present. */
115
- trackPartial?: string[];
116
- /** The default search platform to use, can be "youtube", "youtube music", "soundcloud" or deezer. */
117
- defaultSearchPlatform?: SearchPlatform;
118
- /** Whether the YouTube video titles should be replaced if the Author does not exactly match. */
119
- replaceYouTubeCredentials?: boolean;
120
- caches: {
121
- /** Whether to cache the search results. */
122
- enabled: boolean;
123
- /** The time to cache the search results. */
124
- time: number;
125
- };
126
- /**
127
- * Function to send data to the websocket.
128
- * @param id
129
- * @param payload
130
- */
131
- send(id: string, payload: Payload): void;
132
- }
133
- export type SearchPlatform = "deezer" | "soundcloud" | "youtube music" | "youtube" | "spotify" | "jiosaavn" | "tidal" | "applemusic" | "bandcamp" | "tiktok";
134
- export interface SearchQuery {
135
- /** The source to search from. */
136
- source?: SearchPlatform | string;
137
- /** The query to search for. */
138
- query: string;
139
- }
140
- export interface LavalinkResponse {
141
- loadType: LoadType;
142
- data: TrackData[] | PlaylistRawData;
143
- }
144
- export interface SearchResult {
145
- /** The load type of the result. */
146
- loadType: LoadType;
147
- /** The array of tracks from the result. */
148
- tracks: Track[];
149
- /** The playlist info if the load type is 'playlist'. */
150
- playlist?: PlaylistData;
151
- }
152
- export interface PlaylistRawData {
153
- info: {
154
- /** The playlist name. */
155
- name: string;
156
- };
157
- /** Addition info provided by plugins. */
158
- pluginInfo: object;
159
- /** The tracks of the playlist */
160
- tracks: TrackData[];
161
- }
162
- export interface PlaylistData {
163
- /** The playlist name. */
164
- name: string;
165
- /** The length of the playlist. */
166
- duration: number;
167
- /** The songs of the playlist. */
168
- tracks: Track[];
169
- }
170
- export interface ManagerEvents {
171
- NodeCreate: (node: Node) => void;
172
- NodeDestroy: (node: Node) => void;
173
- NodeConnect: (node: Node) => void;
174
- NodeReconnect: (node: Node) => void;
175
- NodeDisconnect: (node: Node, reason: {
176
- code?: number;
177
- reason?: string;
178
- }) => void;
179
- NodeError: (node: Node, error: Error) => void;
180
- NodeRaw: (payload: unknown) => void;
181
- PlayerCreate: (player: Player) => void;
182
- PlayerDestroy: (player: Player) => void;
183
- PlayerStateUpdate: (oldPlayer: Player, newPlayer: Player) => void;
184
- PlayerMove: (player: Player, initChannel: string, newChannel: string) => void;
185
- PlayerDisconnect: (player: Player, oldChannel: string) => void;
186
- QueueEnd: (player: Player, track: Track | UnresolvedTrack, payload: TrackEndEvent) => void;
187
- SocketClosed: (player: Player, payload: WebSocketClosedEvent) => void;
188
- TrackStart: (player: Player, track: Track, payload: TrackStartEvent) => void;
189
- TrackEnd: (player: Player, track: Track, payload: TrackEndEvent) => void;
190
- TrackStuck: (player: Player, track: Track, payload: TrackStuckEvent) => void;
191
- TrackError: (player: Player, track: Track | UnresolvedTrack, payload: TrackExceptionEvent) => void;
192
- }
@@ -1,140 +0,0 @@
1
- import { PlayerEvent, PlayerEvents, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, WebSocketClosedEvent } from "./Utils";
2
- import { Manager } from "./Manager";
3
- import { Player, Track, UnresolvedTrack } from "./Player";
4
- import { Rest } from "./Rest";
5
- import WebSocket from "ws";
6
- export declare class Node {
7
- options: NodeOptions;
8
- /** The socket for the node. */
9
- socket: WebSocket | null;
10
- /** The stats for the node. */
11
- stats: NodeStats;
12
- manager: Manager;
13
- /** The node's session ID. */
14
- sessionId: string | null;
15
- /** The REST instance. */
16
- readonly rest: Rest;
17
- private static _manager;
18
- private reconnectTimeout?;
19
- private reconnectAttempts;
20
- /** Returns if connected to the Node. */
21
- get connected(): boolean;
22
- /** Returns the address for this node. */
23
- get address(): string;
24
- /** @hidden */
25
- static init(manager: Manager): void;
26
- /**
27
- * Creates an instance of Node.
28
- * @param options
29
- */
30
- constructor(options: NodeOptions);
31
- /** Connects to the Node. */
32
- connect(): void;
33
- /** Destroys the Node and all players connected with it. */
34
- destroy(): void;
35
- private reconnect;
36
- protected open(): void;
37
- protected close(code: number, reason: string): void;
38
- protected error(error: Error): void;
39
- protected message(d: Buffer | string): void;
40
- protected handleEvent(payload: PlayerEvent & PlayerEvents): Promise<void>;
41
- protected trackStart(player: Player, track: Track, payload: TrackStartEvent): void;
42
- protected trackEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
43
- extractSpotifyTrackID(url: string): string | null;
44
- extractSpotifyArtistID(url: string): string | null;
45
- private handleAutoplay;
46
- private handleFailedTrack;
47
- private handleRepeatedTrack;
48
- private playNextTrack;
49
- protected queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
50
- protected trackStuck(player: Player, track: Track, payload: TrackStuckEvent): void;
51
- protected trackError(player: Player, track: Track | UnresolvedTrack, payload: TrackExceptionEvent): void;
52
- protected socketClosed(player: Player, payload: WebSocketClosedEvent): void;
53
- }
54
- export interface NodeOptions {
55
- /** The host for the node. */
56
- host: string;
57
- /** The port for the node. */
58
- port?: number;
59
- /** The password for the node. */
60
- password?: string;
61
- /** Whether the host uses SSL. */
62
- secure?: boolean;
63
- /** The identifier for the node. */
64
- identifier?: string;
65
- /** The retryAmount for the node. */
66
- retryAmount?: number;
67
- /** The retryDelay for the node. */
68
- retryDelay?: number;
69
- /** Whether to resume the previous session. */
70
- resumeStatus?: boolean;
71
- /** The time the manager will wait before trying to resume the previous session. */
72
- resumeTimeout?: number;
73
- /** The timeout used for api calls. */
74
- requestTimeout?: number;
75
- /** Priority of the node. */
76
- priority?: number;
77
- }
78
- export interface NodeStats {
79
- /** The amount of players on the node. */
80
- players: number;
81
- /** The amount of playing players on the node. */
82
- playingPlayers: number;
83
- /** The uptime for the node. */
84
- uptime: number;
85
- /** The memory stats for the node. */
86
- memory: MemoryStats;
87
- /** The cpu stats for the node. */
88
- cpu: CPUStats;
89
- /** The frame stats for the node. */
90
- frameStats: FrameStats;
91
- }
92
- export interface MemoryStats {
93
- /** The free memory of the allocated amount. */
94
- free: number;
95
- /** The used memory of the allocated amount. */
96
- used: number;
97
- /** The total allocated memory. */
98
- allocated: number;
99
- /** The reservable memory. */
100
- reservable: number;
101
- }
102
- export interface CPUStats {
103
- /** The core amount the host machine has. */
104
- cores: number;
105
- /** The system load. */
106
- systemLoad: number;
107
- /** The lavalink load. */
108
- lavalinkLoad: number;
109
- }
110
- export interface FrameStats {
111
- /** The amount of sent frames. */
112
- sent?: number;
113
- /** The amount of nulled frames. */
114
- nulled?: number;
115
- /** The amount of deficit frames. */
116
- deficit?: number;
117
- }
118
- export interface LavalinkInfo {
119
- version: {
120
- semver: string;
121
- major: number;
122
- minor: number;
123
- patch: number;
124
- preRelease: string;
125
- };
126
- buildTime: number;
127
- git: {
128
- branch: string;
129
- commit: string;
130
- commitTime: number;
131
- };
132
- jvm: string;
133
- lavaplayer: string;
134
- sourceManagers: string[];
135
- filters: string[];
136
- plugins: {
137
- name: string;
138
- version: string;
139
- }[];
140
- }