import { Collection } from '@discordjs/collection'; import { GatewayVoiceStateUpdate } from 'discord-api-types/v10'; import { EventEmitter } from 'events'; import { User, ClientUser, Guild, Message, Client as Client$1 } from 'discord.js'; import { User as User$1, Guild as Guild$1, Message as Message$1, Client as Client$3 } from 'oceanic.js'; import { User as User$2, Guild as Guild$2, Message as Message$2, Bot } from '@discordeno/bot'; import { User as User$3, Guild as Guild$3, Message as Message$3, Client as Client$2 } from 'eris'; import { User as User$4, ClientUser as ClientUser$1, Guild as Guild$4, Message as Message$4, Client as Client$4, WorkerClient } from 'seyfert'; import { RedisOptions, Redis } from 'ioredis'; import WebSocket$1, { WebSocket } from 'ws'; import { Client } from 'cloudstorm'; /** Represents an equalizer band. */ interface Band { /** The index of the equalizer band (0-12). */ band: number; /** The gain value of the equalizer band (in decibels). */ gain: number; } /** * State Storage Enum */ declare enum StateStorageType { Memory = "memory", Redis = "redis", JSON = "json" } /** * AutoPlay Platform Enum */ declare enum AutoPlayPlatform { Spotify = "spotify", Deezer = "deezer", SoundCloud = "soundcloud", Tidal = "tidal", VKMusic = "vkmusic", Qobuz = "qobuz", Yandex = "yandex", YouTube = "youtube" } /** * State Types Enum */ declare enum StateTypes { Connected = "CONNECTED", Connecting = "CONNECTING", Disconnected = "DISCONNECTED", Disconnecting = "DISCONNECTING", Destroying = "DESTROYING" } /** * Load Types Enum */ declare enum LoadTypes { Track = "track", Playlist = "playlist", Search = "search", Empty = "empty", Error = "error", /** Nodelink */ Album = "album", /** Nodelink */ Artist = "artist", /** Nodelink */ Station = "station", /** Nodelink */ Podcast = "podcast", /** Nodelink */ Show = "show", /** Nodelink */ Short = "short" } /** * Search Platform Enum */ declare enum SearchPlatform { AppleMusic = "amsearch", Yandex = "ymsearch", Audius = "audsearch", Bandcamp = "bcsearch", Deezer = "dzsearch", Jiosaavn = "jssearch", Qobuz = "qbsearch", SoundCloud = "scsearch", Spotify = "spsearch", Tidal = "tdsearch", TTS = "speak", VKMusic = "vksearch", YouTube = "ytsearch", YouTubeMusic = "ytmsearch" } /** * Player State Event Types Enum */ declare enum PlayerStateEventTypes { AutoPlayChange = "playerAutoplay", ConnectionChange = "playerConnection", RepeatChange = "playerRepeat", PauseChange = "playerPause", QueueChange = "queueChange", TrackChange = "trackChange", VolumeChange = "volumeChange", ChannelChange = "channelChange", PlayerCreate = "playerCreate", PlayerDestroy = "playerDestroy", FilterChange = "filterChange" } /** * Track Source Types Enum */ declare enum TrackSourceTypes { AppleMusic = "AppleMusic", Audius = "Audius", Bandcamp = "Bandcamp", Deezer = "Deezer", Jiosaavn = "Jiosaavn", Qobuz = "Qobuz", SoundCloud = "SoundCloud", Spotify = "Spotify", Tidal = "Tidal", VKMusic = "VKMusic", YouTube = "YouTube", Pornhub = "Pornub", TikTok = "TikTok", Flowertts = "Flowertts", Ocremix = "Ocremix", Yandex = "Yandex", Mixcloud = "Mixcloud", Soundgasm = "Soundgasm", Reddit = "Reddit", Clypit = "Clypit", Http = "Http", Tts = "Tts" } /** * Use Node Options Enum */ declare enum UseNodeOptions { LeastLoad = "leastLoad", LeastPlayers = "leastPlayers" } /** * Track Partial Enum */ declare enum TrackPartial { /** The base64 encoded string of the track */ Track = "track", /** The title of the track */ Title = "title", /** The track identifier */ Identifier = "identifier", /** The author of the track */ Author = "author", /** The length of the track in milliseconds */ Duration = "duration", /** The ISRC of the track */ Isrc = "isrc", /** Whether the track is seekable */ IsSeekable = "isSeekable", /** Whether the track is a stream */ IsStream = "isStream", /** The URI of the track */ Uri = "uri", /** The artwork URL of the track */ ArtworkUrl = "artworkUrl", /** The source name of the track */ SourceName = "sourceName", /** The thumbnail of the track */ ThumbNail = "thumbnail", /** The requester of the track */ Requester = "requester", /** The plugin info of the track */ PluginInfo = "pluginInfo", /** The custom data of the track */ CustomData = "customData", /** Whether the track got autoplayed */ IsAutoPlay = "isAutoplay" } /** * Manager Event Types Enum */ declare enum ManagerEventTypes { ChapterStarted = "chapterStarted", ChaptersLoaded = "chaptersLoaded", Debug = "debug", LyricsFound = "lyricsFound", LyricsLine = "lyricsLine", LyricsNotFound = "lyricsNotFound", NodeConnect = "nodeConnect", NodeCreate = "nodeCreate", NodeDestroy = "nodeDestroy", NodeDisconnect = "nodeDisconnect", NodeError = "nodeError", NodeRaw = "nodeRaw", NodeReconnect = "nodeReconnect", PlayerCreate = "playerCreate", PlayerDestroy = "playerDestroy", PlayerDisconnect = "playerDisconnect", PlayerMove = "playerMove", PlayerRestored = "playerRestored", PlayerStateUpdate = "playerStateUpdate", QueueEnd = "queueEnd", RestoreComplete = "restoreComplete", SegmentSkipped = "segmentSkipped", SegmentsLoaded = "segmentsLoaded", SocketClosed = "socketClosed", TrackEnd = "trackEnd", TrackError = "trackError", TrackStart = "trackStart", TrackStuck = "trackStuck", /** Nodelink */ VoiceReceiverDisconnect = "voiceReceiverDisconnect", /** Nodelink */ VoiceReceiverConnect = "voiceReceiverConnect", /** Nodelink */ VoiceReceiverError = "voiceReceiverError", /** Nodelink */ VoiceReceiverStartSpeaking = "voiceReceiverStartSpeaking", /** Nodelink */ VoiceReceiverEndSpeaking = "voiceReceiverEndSpeaking" } /** * Track End Reason Enum */ declare enum TrackEndReasonTypes { Finished = "finished", LoadFailed = "loadFailed", Stopped = "stopped", Replaced = "replaced", Cleanup = "cleanup" } /** * Severity Types Enum */ declare enum SeverityTypes { Common = "common", Suspicious = "suspicious", Fault = "fault" } /** * SponsorBlock Segment Enum */ declare enum SponsorBlockSegment { Filler = "filler", Interaction = "interaction", Intro = "intro", MusicOfftopic = "music_offtopic", Outro = "outro", Preview = "preview", SelfPromo = "selfpromo", Sponsor = "sponsor" } /** * Available Filters Enum */ declare enum AvailableFilters { BassBoost = "bassboost", China = "china", Chipmunk = "chipmunk", Darthvader = "darthvader", Daycore = "daycore", Demon = "demon", Distort = "distort", Doubletime = "doubletime", Earrape = "earrape", EightD = "eightD", Electronic = "electronic", Nightcore = "nightcore", Party = "party", Pop = "pop", Radio = "radio", SetDistortion = "setDistortion", SetKaraoke = "setKaraoke", SetRotation = "setRotation", SetTimescale = "setTimescale", Slowmo = "slowmo", Soft = "soft", TrebleBass = "trebleBass", Tremolo = "tremolo", TV = "tv", Vaporwave = "vaporwave", Vibrato = "vibrato" } /** * MagmaStream Error Codes Enum */ declare enum MagmaStreamErrorCode { GENERAL_UNKNOWN = "MS_GENERAL_UNKNOWN", GENERAL_TIMEOUT = "MS_GENERAL_TIMEOUT", GENERAL_INVALID_MANAGER = "MS_GENERAL_INVALID_MANAGER", INTENT_MISSING = "MS_INTENT_MISSING", MANAGER_INIT_FAILED = "MS_MANAGER_INIT_FAILED", MANAGER_INVALID_CONFIG = "MS_MANAGER_INVALID_CONFIG", MANAGER_SHUTDOWN_FAILED = "MS_MANAGER_SHUTDOWN_FAILED", MANAGER_NO_NODES = "MS_MANAGER_NO_NODES", MANAGER_NODE_NOT_FOUND = "MS_MANAGER_NODE_NOT_FOUND", MANAGER_SEARCH_FAILED = "MS_MANAGER_SEARCH_FAILED", MANAGER_CLEANUP_INACTIVE_PLAYERS_FAILED = "MS_MANAGER_CLEANUP_INACTIVE_PLAYERS_FAILED", NODE_INVALID_CONFIG = "MS_NODE_INVALID_CONFIG", NODE_CONNECT_FAILED = "MS_NODE_CONNECT_FAILED", NODE_RECONNECT_FAILED = "MS_NODE_RECONNECT_FAILED", NODE_DISCONNECTED = "MS_NODE_DISCONNECTED", NODE_PROTOCOL_ERROR = "MS_NODE_PROTOCOL_ERROR", NODE_SESSION_IDS_LOAD_FAILED = "MS_NODE_SESSION_IDS_LOAD_FAILED", NODE_SESSION_IDS_UPDATE_FAILED = "MS_NODE_SESSION_IDS_UPDATE_FAILED", NODE_PLUGIN_ERROR = "MS_NODE_PLUGIN_ERROR", PLAYER_INVALID_CONFIG = "MS_PLAYER_INVALID_CONFIG", PLAYER_STATE_INVALID = "MS_PLAYER_STATE_INVALID", PLAYER_QUEUE_EMPTY = "MS_PLAYER_QUEUE_EMPTY", PLAYER_PREVIOUS_EMPTY = "MS_PLAYER_PREVIOUS_EMPTY", PLAYER_INVALID_NOW_PLAYING_MESSAGE = "MS_PLAYER_INVALID_NOW_PLAYING_MESSAGE", PLAYER_INVALID_AUTOPLAY = "MS_PLAYER_INVALID_AUTOPLAY", PLAYER_INVALID_VOLUME = "MS_PLAYER_INVALID_VOLUME", PLAYER_INVALID_REPEAT = "MS_PLAYER_INVALID_REPEAT", PLAYER_INVALID_PAUSE = "MS_PLAYER_INVALID_PAUSE", PLAYER_INVALID_SEEK = "MS_PLAYER_INVALID_SEEK", PLAYER_MOVE_FAILED = "MS_PLAYER_MOVE_FAILED", PLAYER_VOICE_RECEIVER_ERROR = "MS_PLAYER_VOICE_RECEIVER_ERROR", QUEUE_REDIS_ERROR = "MS_QUEUE_REDIS_ERROR", QUEUE_JSON_ERROR = "MS_QUEUE_JSON_ERROR", QUEUE_MEMORY_ERROR = "MS_QUEUE_MEMORY_ERROR", FILTER_APPLY_FAILED = "MS_FILTER_APPLY_FAILED", REST_REQUEST_FAILED = "MS_REST_REQUEST_FAILED", REST_UNAUTHORIZED = "MS_REST_UNAUTHORIZED", UTILS_TRACK_PARTIAL_INVALID = "MS_UTILS_TRACK_PARTIAL_INVALID", UTILS_TRACK_BUILD_FAILED = "MS_UTILS_TRACK_BUILD_FAILED", UTILS_AUTOPLAY_BUILD_FAILED = "MS_UTILS_AUTOPLAY_BUILD_FAILED", UTILS_PLAYER_SERIALIZE_FAILED = "MS_UTILS_PLAYER_SERIALIZE_FAILED", PLUGIN_LOAD_FAILED = "MS_PLUGIN_LOAD_FAILED", PLUGIN_RUNTIME_ERROR = "MS_PLUGIN_RUNTIME_ERROR" } declare const MagmaStreamErrorNumbers: Record; /** * The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks. */ declare class JsonQueue implements IQueue { readonly guildId: string; readonly manager: Manager; /** * The base path for the queue files. */ private basePath; /** * Whether the queue has been destroyed. */ private destroyed; /** * @param guildId The guild ID. * @param manager The manager. */ constructor(guildId: string, manager: Manager); /** * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s. * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue. */ add(track: Track | Track[], offset?: number): Promise; /** * @param track The track to add. */ addPrevious(track: Track | Track[]): Promise; /** * Clears the queue. */ clear(): Promise; /** * Clears the previous tracks. */ clearPrevious(): Promise; /** * Removes the first track from the queue. */ dequeue(): Promise; /** * Destroys the queue and releases all resources. * After calling this method, the queue must not be used again. */ destroy(): Promise; /** * @returns The total duration of the queue. */ duration(): Promise; /** * Adds a track to the front of the queue. */ enqueueFront(track: Track | Track[]): Promise; /** * Tests whether all elements in the queue pass the test implemented by the provided function. */ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * Filters the queue. */ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * Finds the first track in the queue that satisfies the provided testing function. */ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * @returns The current track. */ getCurrent(): Promise; /** * @returns The previous tracks. */ getPrevious(): Promise; /** * @returns The tracks in the queue from start to end. */ getSlice(start?: number, end?: number): Promise; /** * @returns The tracks in the queue. */ getTracks(): Promise; /** * Maps the queue to a new array. */ mapAsync(callback: (track: Track, index: number, array: Track[]) => T): Promise; /** * Modifies the queue at the specified index. */ modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise; /** * @returns The newest track. */ popPrevious(): Promise; /** * Removes a track from the queue. * @param position The position to remove the track at. * @param end The end position to remove the track at. */ remove(position?: number): Promise; remove(start: number, end: number): Promise; /** * Shuffles the queue by round-robin. */ roundRobinShuffle(): Promise; /** * @param track The track to set. */ setCurrent(track: Track | null): Promise; /** * @param track The track to set. */ setPrevious(track: Track | Track[]): Promise; /** * Shuffles the queue. */ shuffle(): Promise; /** * @returns The size of the queue. */ size(): Promise; /** * Tests whether at least one element in the queue passes the test implemented by the provided function. */ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * @returns The total size of the queue. */ totalSize(): Promise; /** * Shuffles the queue by user. */ userBlockShuffle(): Promise; /** * @returns The current path. */ private get currentPath(); /** * @param filePath The file path. */ private deleteFile; /** * Ensures the directory exists. */ private ensureDir; /** * @returns The queue. */ private getQueue; /** * @returns The previous path. */ private get previousPath(); /** * @returns The queue path. */ private get queuePath(); /** * @param filePath The file path. * @returns The JSON data. */ private readJSON; /** * @param queue The queue. */ private setQueue; /** * @param filePath The file path. * @param data The data to write. */ private writeJSON; } /** * The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks. */ declare class MemoryQueue extends Array implements IQueue { /** The current track */ current: Track | null; /** The previous tracks */ previous: Track[]; /** The Manager instance. */ manager: Manager; /** The guild ID property. */ guildId: string; /** * Whether the queue has been destroyed. */ private destroyed; /** * Constructs a new Queue. * @param guildId The guild ID. * @param manager The Manager instance. */ constructor(guildId: string, manager: Manager); /** * Adds a track to the queue. * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s. * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue. */ add(track: Track | Track[], offset?: number): void; /** * Adds a track to the previous tracks. * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s. */ addPrevious(track: Track | Track[]): void; /** * Clears the queue. * This will remove all tracks from the queue and emit a state update event. */ clear(): void; /** * Clears the previous tracks. */ clearPrevious(): void; /** * Removes the first element from the queue. */ dequeue(): Track | undefined; /** * Destroys the queue and releases all resources. * After calling this method, the queue must not be used again. */ destroy(): void; /** * The total duration of the queue in milliseconds. * This includes the duration of the currently playing track. */ duration(): number; /** * Adds the specified track or tracks to the front of the queue. * @param track The track or tracks to add. */ enqueueFront(track: Track | Track[]): void; /** * @returns Whether all elements in the queue satisfy the provided testing function. */ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean; /** * @returns A new array with all elements that pass the test implemented by the provided function. */ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track[]; /** * @returns The first element in the queue that satisfies the provided testing function. */ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track | undefined; /** * @returns The current track. */ getCurrent(): Track | null; /** * @returns The previous tracks. */ getPrevious(): Track[]; /** * @returns The tracks in the queue from start to end. */ getSlice(start?: number, end?: number): Track[]; /** * @returns The tracks in the queue. */ getTracks(): Track[]; /** * @returns A new array with the results of calling a provided function on every element in the queue. */ mapAsync(callback: (track: Track, index: number, array: Track[]) => T): T[]; /** * Modifies the queue at the specified index. * @param start The index at which to start modifying the queue. * @param deleteCount The number of elements to remove from the queue. * @param items The elements to add to the queue. * @returns The modified queue. */ modifyAt(start: number, deleteCount?: number, ...items: Track[]): Track[]; /** * @returns The newest track. */ popPrevious(): Track | null; /** * Removes track(s) from the queue. * @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove. * If two numbers are provided, they will be used as the start and end of a range of tracks to remove. * @param end Optional, end of the range of tracks to remove. * @returns The removed track(s). */ remove(position?: number): Track[]; remove(start: number, end: number): Track[]; /** * Shuffles the queue to play tracks requested by each user one by one. */ roundRobinShuffle(): void; /** * @param track The track to set. */ setCurrent(track: Track | null): void; /** * @param tracks The tracks to set. */ setPrevious(tracks: Track[]): void; /** * Shuffles the queue. * This will randomize the order of the tracks in the queue and emit a state update event. */ shuffle(): void; /** * The size of tracks in the queue. * This does not include the currently playing track. * @returns The size of tracks in the queue. */ size(): number; /** * @returns Whether at least one element in the queue satisfies the provided testing function. */ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean; /** * The total size of tracks in the queue including the current track. * This includes the current track if it is not null. * @returns The total size of tracks in the queue including the current track. */ totalSize(): number; /** * Shuffles the queue to play tracks requested by each user one block at a time. */ userBlockShuffle(): void; } /** * The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks. */ declare class RedisQueue implements IQueue { readonly guildId: string; readonly manager: Manager; /** * The prefix for the Redis keys. */ redisPrefix: string; /** * The Redis instance. */ private redis; /** * Whether the queue has been destroyed. */ private destroyed; /** * Constructs a new RedisQueue. * @param guildId The guild ID. * @param manager The Manager instance. */ constructor(guildId: string, manager: Manager); /** * Adds a track or tracks to the queue. * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s. * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue. */ add(track: Track | Track[], offset?: number): Promise; /** * Adds a track or tracks to the previous tracks. * @param track The track or tracks to add. */ addPrevious(track: Track | Track[]): Promise; /** * Clears the queue. */ clear(): Promise; /** * Clears the previous tracks. */ clearPrevious(): Promise; /** * Removes the first track from the queue. */ dequeue(): Promise; /** * Destroys the queue and releases all resources. * After calling this method, the queue must not be used again. */ destroy(): Promise; /** * @returns The total duration of the queue in milliseconds. * This includes the duration of the currently playing track. */ duration(): Promise; /** * Adds a track to the front of the queue. * @param track The track or tracks to add. */ enqueueFront(track: Track | Track[]): Promise; /** * Whether all tracks in the queue match the specified condition. * @param callback The condition to match. * @returns Whether all tracks in the queue match the specified condition. */ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * Filters the tracks in the queue. * @param callback The condition to match. * @returns The tracks that match the condition. */ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * Finds the first track in the queue that matches the specified condition. * @param callback The condition to match. * @returns The first track that matches the condition. */ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * @returns The current track. */ getCurrent(): Promise; /** * @returns The previous tracks. */ getPrevious(): Promise; /** * @returns The tracks in the queue from the start to the end. */ getSlice(start?: number, end?: number): Promise; /** * @returns The tracks in the queue. */ getTracks(): Promise; /** * Maps the tracks in the queue. * @returns The tracks in the queue after the specified index. */ mapAsync(callback: (track: Track, index: number, array: Track[]) => T): Promise; /** * Modifies the queue at the specified index. * @param start The start index. * @param deleteCount The number of tracks to delete. * @param items The tracks to insert. * @returns The removed tracks. */ modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise; /** * Removes the newest track. * @returns The newest track. */ popPrevious(): Promise; /** * Removes the track at the specified index. * @param position The position to remove the track at. * @param end The end position to remove the track at. */ remove(position?: number): Promise; remove(start: number, end: number): Promise; /** * Shuffles the queue round-robin style. */ roundRobinShuffle(): Promise; /** * Sets the current track. * @param track The track to set. */ setCurrent(track: Track | null): Promise; /** * Sets the previous track(s). * @param track The track to set. */ setPrevious(track: Track | Track[]): Promise; /** * Shuffles the queue. */ shuffle(): Promise; /** * @returns The size of the queue. */ size(): Promise; /** * @returns Whether any tracks in the queue match the specified condition. */ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise; /** * @returns The total size of tracks in the queue including the current track. */ totalSize(): Promise; /** * Shuffles the queue, but keeps the tracks of the same user together. */ userBlockShuffle(): Promise; /** * @returns The current key. */ private get currentKey(); /** * Deserializes a track from a string. */ private deserialize; /** * @returns The previous key. */ private get previousKey(); /** * @returns The queue key. */ private get queueKey(); /** * Helper to serialize/deserialize Track */ private serialize; } /** * Base abstract class for all plugins. * Users must extend this and implement load and unload methods. */ declare abstract class Plugin { readonly name: string; /** * @param name The name of the plugin */ constructor(name: string); /** * Load the plugin. * @param manager The MagmaStream Manager instance */ abstract load(manager: Manager): void; /** * Unload the plugin. * Called on shutdown to gracefully cleanup resources or detach listeners. * @param manager The MagmaStream Manager instance */ abstract unload(manager: Manager): void; } /** * Manager Options */ interface ManagerOptions { /** The state storage options. * * @default { type: StateStorageType.Collection, deleteDestroyedPlayers: true } */ stateStorage?: StateStorageOptions; /** Enable priority mode over least player count or load balancing? * @default false */ enablePriorityMode?: boolean; /** Automatically play the next track when the current one ends. * @default true */ playNextOnEnd?: boolean; /** An array of search platforms to use for autoplay. First to last matters * Use enum `AutoPlayPlatform`. * @default [AutoPlayPlatform.YouTube] */ autoPlaySearchPlatforms?: AutoPlayPlatform[]; /** The client ID to use. */ clientId?: string; /** Value to use for the `Client-Name` header. * @default "Magmastream" * * For NodeLink, leave it empty. */ clientName?: string; /** The array of shard IDs connected to this manager instance. * @default 0 */ clusterId?: number; /** List of plugins to load. */ enabledPlugins?: Plugin[]; /** The default search platform to use. * Use enum `SearchPlatform`. * @default SearchPlatform.YouTube */ defaultSearchPlatform?: SearchPlatform; /** The last.fm API key. * If you need to create one go here: https://www.last.fm/api/account/create. * If you already have one, get it from here: https://www.last.fm/api/accounts. */ lastFmApiKey?: string; /** The maximum number of previous tracks to store. * @default 20 */ maxPreviousTracks?: number; /** The array of nodes to connect to. */ nodes?: NodeOptions[]; /** Whether the YouTube video titles should be replaced if the Author does not exactly match. * @default false */ normalizeYouTubeTitles?: boolean; /** An array of track properties to keep. `track` will always be present. */ trackPartial?: TrackPartial[]; /** Use the least amount of players or least load? * Use enum `UseNodeOptions`. * @default UseNodeOptions.LeastPlayers */ useNode?: UseNodeOptions.LeastLoad | UseNodeOptions.LeastPlayers; /** Whether the manager should listen to SIGINT and SIGTERM events. * @default true */ listenToSIGEvents?: boolean; /** * Function to send data to the websocket. * @param id The ID of the node to send the data to. * @param payload The payload to send. */ send?: (packet: DiscordPacket) => unknown; /** * User cache getter. Required when using `new Manager(...)` directly, optional for built-in wrappers. * When resolving a user from a partial ID, this function will be called first. * Should return the full user object if cached, or undefined if not. * @param id The ID of the user to get. * @returns The user object if cached, or undefined if not. */ getUser?: (id: string) => AnyUser | undefined; /** * Guild cache getter. Required when using `new Manager(...)` directly, optional for built-in wrappers. * When resolving a guild from a partial ID, this function will be called first. * Should return the full guild object if cached, or undefined if not. * @param id The ID of the guild to get. * @returns The guild object if cached, or undefined if not. */ getGuild?: (id: string) => AnyGuild | undefined; } /** * Manager options for direct `new Manager(...)` usage. * Built-in wrappers provide these cache hooks automatically, so they only require {@link ManagerOptions}. */ interface StandaloneManagerOptions extends ManagerOptions { getUser: (id: string) => AnyUser | undefined; getGuild: (id: string) => AnyGuild | undefined; } /** * State Storage Options */ interface StateStorageOptions { type: StateStorageType; redisConfig?: RedisConfig; jsonConfig?: JsonConfig; deleteDestroyedPlayers?: boolean; } /** * Node Options */ interface NodeOptions { /** The host for the node. */ host: string; /** The port for the node. * @default 2333 */ port?: number; /** The password for the node. * @default "youshallnotpass" */ password?: string; /** Whether the host uses SSL. * @default false */ useSSL?: boolean; /** The identifier for the node. * @default host */ identifier?: string; /** The maxRetryAttempts for the node. * @default 30 */ maxRetryAttempts?: number; /** The retryDelayMs for the node. * @default 60000 */ retryDelayMs?: number; /** Whether to resume the previous session. * @default false */ enableSessionResumeOption?: boolean; /** The time in seconds the lavalink server will wait before it removes the player. * @default 60 */ sessionTimeoutSeconds?: number; /** The timeout used for api calls. * @default 10000 */ apiRequestTimeoutMs?: number; /** Priority of the node. * @default 0 */ nodePriority?: number; /** Whether the node is a NodeLink. * @default false */ isNodeLink?: boolean; /** Whether the node is a backup node. * @default false */ isBackup?: boolean; } /** * Portable User */ interface PortableUser { id: string; username?: string; } /** * Any user */ type AnyUser = PortableUser | User | ClientUser | User$1 | User$2 | User$3 | User$4 | ClientUser$1; /** * Portable Message */ interface PortableMessage { id: string; } /** * Any message */ type AnyMessage = PortableMessage | Message | Message$1 | Message$2 | Message$3 | Message$4; /** * Any guild */ type AnyGuild = Guild | Guild$1 | Guild$2 | Guild$3 | Guild$4<"cached">; /** * Discord Packet */ interface DiscordPacket { /** * The opcode for the payload */ op: number; /** * Event data */ d: any; /** * Sequence number, used for resuming sessions and heartbeats */ s?: number; /** * The event name for this payload */ t?: string; } /** * Player Update Voice State */ interface PlayerUpdateVoiceState { /** * The session id of the voice connection */ sessionId: string; /** * Event data */ event: VoiceServerUpdate; } /** * Voice Server Update */ interface VoiceServerUpdate { /** * The token for the session */ token: string; /** * Guild if of the voice connection */ guild_id: string; /** * The endpoint lavalink will connect to */ endpoint: string; } /** * Redis Configuration */ interface RedisConfig extends RedisOptions { prefix?: string; } /** * JSON Configuration */ interface JsonConfig { path: string; } /** * Player State Update Event */ type PlayerStateUpdateEvent = { changeType: PlayerStateEventTypes.TrackChange; details: TrackChangeEvent; } | { changeType: PlayerStateEventTypes.PauseChange; details: PauseChangeEvent; } | { changeType: PlayerStateEventTypes.QueueChange; details: QueueChangeEvent; } | { changeType: PlayerStateEventTypes.ConnectionChange; details: ConnectionChangeEvent; } | { changeType: PlayerStateEventTypes.AutoPlayChange; details: AutoplayChangeEvent; } | { changeType: PlayerStateEventTypes.ChannelChange; details: ChannelChangeEvent; } | { changeType: PlayerStateEventTypes.VolumeChange; details: VolumeChangeEvent; } | { changeType: PlayerStateEventTypes.RepeatChange; details: RepeatChangeEvent; } | { changeType: PlayerStateEventTypes.FilterChange; details: FilterChangeEvent; }; /** * Autoplay Change Event */ interface AutoplayChangeEvent { type: "autoplay"; action: "toggle"; previousAutoplay: boolean | null; currentAutoplay: boolean | null; } /** * Connection Change Event */ interface ConnectionChangeEvent { type: "connection"; action: "connect" | "disconnect"; previousConnection: boolean | null; currentConnection: boolean | null; } interface FilterChangeEvent { type: "filter"; action: "change"; } /** * Repeat Change Event */ interface RepeatChangeEvent { type: "repeat"; action: "dynamic" | "track" | "queue" | "none"; previousRepeat: "dynamic" | "track" | "queue" | null; currentRepeat: "dynamic" | "track" | "queue" | null; } /** * Pause Change Event */ interface PauseChangeEvent { type: "pause"; action: "pause" | "resume" | "toggle"; previousPause: boolean | null; currentPause: boolean | null; } /** * Queue Change Event */ interface QueueChangeEvent { type: "queue"; action: "add" | "remove" | "clear" | "shuffle" | "roundRobin" | "userBlock" | "autoPlayAdd"; previousQueueLength: number | null; currentQueueLength: number | null; tracks?: Track[]; } /** * Track Change Event */ interface TrackChangeEvent { type: "track"; action: "start" | "end" | "previous" | "timeUpdate" | "autoPlay"; track: Track; previousTime?: number | null; currentTime?: number | null; } /** * Volume Change Event */ interface VolumeChangeEvent { type: "volume"; action: "adjust"; previousVolume: number | null; currentVolume: number | null; } /** * Channel Change Event */ interface ChannelChangeEvent { type: "channel"; action: "text" | "voice"; previousChannel: string | null; currentChannel: string | null; } /** * Track */ interface Track { /** The base64 encoded track. */ readonly track: string; /** The artwork url of the track. */ readonly artworkUrl: string | null; /** The track source name. */ readonly sourceName: TrackSourceName; /** The title of the track. */ title: string; /** The identifier of the track. */ readonly identifier: string; /** The author of the track. */ author: string; /** The duration of the track. */ readonly duration: number; /** The ISRC of the track. */ readonly isrc: string; /** If the track is seekable. */ readonly isSeekable: boolean; /** If the track is a stream.. */ readonly isStream: boolean; /** The uri of the track. */ readonly uri: string; /** The thumbnail of the track or null if it's a unsupported source. */ readonly thumbnail: string | null; /** The user that requested the track. */ requester: AnyUser; /** Displays the track thumbnail with optional size or null if it's a unsupported source. */ displayThumbnail(size?: Sizes): string | null; /** Additional track info provided by plugins. */ pluginInfo: TrackPluginInfo; /** Add your own data to the track. */ customData: Record; /** If the track got added by autoplay. */ readonly isAutoplay: boolean; } /** * Track Plugin Info */ interface TrackPluginInfo { albumName?: string; albumUrl?: string; artistArtworkUrl?: string; artistUrl?: string; isPreview?: string; previewUrl?: string; } /** * Search Query */ interface SearchQuery { /** The source to search from. */ source?: SearchPlatform; /** The query to search for. */ query: string; } /** * Lavalink Response */ interface LavalinkResponse { loadType: LoadTypes; data: TrackData[] | PlaylistRawData; } /** * Track Data */ interface TrackData { /** The track information. */ encoded: string; /** The detailed information of the track. */ info: TrackDataInfo; /** Additional track info provided by plugins. */ pluginInfo: Record; } /** * Playlist Raw Data */ interface PlaylistRawData { info: { /** The playlist name. */ name: string; }; /** Addition info provided by plugins. */ pluginInfo: object; /** The tracks of the playlist */ tracks: TrackData[]; } /** * Track Data Info */ interface TrackDataInfo { identifier: string; isSeekable: boolean; author: string; length: number; isrc?: string; isStream: boolean; title: string; uri?: string; artworkUrl?: string; sourceName?: TrackSourceName; } /** * LavaPlayer */ interface LavaPlayer { guildId: string; track: TrackData; volume: number; paused: boolean; state: { time: number; position: number; connected: boolean; ping: number; }; voice: LavalinkVoiceStateResponse; filters: Record; } /** * Error or Empty Search Result */ interface ErrorOrEmptySearchResult { /** The load type of the result. */ loadType: LoadTypes.Empty | LoadTypes.Error; } /** * Track Search Result */ interface TrackSearchResult { /** The load type is always 'track' */ loadType: LoadTypes.Track; /** The track obtained */ tracks: [Track]; } /** * Search Result */ interface SearchSearchResult { /** The load type is always 'search' */ loadType: LoadTypes.Search; /** The tracks of the search result */ tracks: Track[]; } /** * Playlist Search Result */ interface PlaylistSearchResult { /** The playlist load type */ loadType: LoadTypes.Playlist; /** The tracks of the playlist */ tracks: Track[]; /** The playlist info */ playlist: PlaylistData; } /** * Album Search Result */ interface AlbumSearchResult { loadType: LoadTypes.Album; tracks: Track[]; playlist: PlaylistData; } /** * Artist Search Result */ interface ArtistSearchResult { loadType: LoadTypes.Artist; tracks: Track[]; playlist: PlaylistData; } /** * Station Search Result */ interface StationSearchResult { loadType: LoadTypes.Station; tracks: Track[]; playlist: PlaylistData; } /** * Podcast Search Result */ interface PodcastSearchResult { loadType: LoadTypes.Podcast; tracks: Track[]; playlist: PlaylistData; } /** * Show Search Result */ interface ShowSearchResult { loadType: LoadTypes.Show; tracks: Track[]; playlist: PlaylistData; } /** * Short Search Result */ interface ShortSearchResult { loadType: LoadTypes.Short; tracks: [Track]; } /** * Playlist Data */ interface PlaylistData { /** The playlist name. */ name: string; /** Requester of playlist. */ requester: AnyUser; /** More playlist information. */ playlistInfo: PlaylistInfoData[]; /** The length of the playlist. */ duration: number; /** The songs of the playlist. */ tracks: Track[]; } /** * Playlist Info Data */ interface PlaylistInfoData { /** Url to playlist. */ url: string; /** Type is always playlist in that case. */ type: string; /** ArtworkUrl of playlist */ artworkUrl: string; /** Number of total tracks in playlist */ totalTracks: number; /** Author of playlist */ author: string; } /** * Manager Events */ interface ManagerEvents { [ManagerEventTypes.ChapterStarted]: [player: Player, track: Track, payload: SponsorBlockChapterStarted]; [ManagerEventTypes.ChaptersLoaded]: [player: Player, track: Track, payload: SponsorBlockChaptersLoaded]; [ManagerEventTypes.Debug]: [info: string]; [ManagerEventTypes.LyricsFound]: [player: Player, track: Track, payload: LyricsFoundEvent]; [ManagerEventTypes.LyricsLine]: [player: Player, track: Track, payload: LyricsLineEvent]; [ManagerEventTypes.LyricsNotFound]: [player: Player, track: Track, payload: LyricsNotFoundEvent]; [ManagerEventTypes.NodeConnect]: [node: Node]; [ManagerEventTypes.NodeCreate]: [node: Node]; [ManagerEventTypes.NodeDestroy]: [node: Node]; [ManagerEventTypes.NodeDisconnect]: [node: Node, reason: { code?: number; reason?: string; }]; [ManagerEventTypes.NodeError]: [node: Node, error: Error]; [ManagerEventTypes.NodeRaw]: [payload: unknown]; [ManagerEventTypes.NodeReconnect]: [node: Node]; [ManagerEventTypes.PlayerCreate]: [player: Player]; [ManagerEventTypes.PlayerDestroy]: [player: Player]; [ManagerEventTypes.PlayerDisconnect]: [player: Player, oldChannel: string]; [ManagerEventTypes.PlayerMove]: [player: Player, oldChannel: string, newChannel: string]; [ManagerEventTypes.PlayerRestored]: [player: Player, node: Node]; [ManagerEventTypes.PlayerStateUpdate]: [oldPlayer: Player, newPlayer: Player, changeType: PlayerStateUpdateEvent]; [ManagerEventTypes.QueueEnd]: [player: Player, track: Track, payload: TrackEndEvent]; [ManagerEventTypes.RestoreComplete]: [node: Node]; [ManagerEventTypes.SegmentSkipped]: [player: Player, track: Track, payload: SponsorBlockSegmentSkipped]; [ManagerEventTypes.SegmentsLoaded]: [player: Player, track: Track, payload: SponsorBlockSegmentsLoaded]; [ManagerEventTypes.SocketClosed]: [player: Player, payload: WebSocketClosedEvent]; [ManagerEventTypes.TrackEnd]: [player: Player, track: Track, payload: TrackEndEvent]; [ManagerEventTypes.TrackError]: [player: Player, track: Track, payload: TrackExceptionEvent]; [ManagerEventTypes.TrackStart]: [player: Player, track: Track, payload: TrackStartEvent]; [ManagerEventTypes.TrackStuck]: [player: Player, track: Track, payload: TrackStuckEvent]; [ManagerEventTypes.VoiceReceiverDisconnect]: [player: Player]; [ManagerEventTypes.VoiceReceiverConnect]: [player: Player]; [ManagerEventTypes.VoiceReceiverError]: [player: Player, error: Error]; [ManagerEventTypes.VoiceReceiverStartSpeaking]: [player: Player, data: unknown]; [ManagerEventTypes.VoiceReceiverEndSpeaking]: [player: Player, data: unknown]; } /** * Voice Packet */ interface VoicePacket { t?: "VOICE_SERVER_UPDATE" | "VOICE_STATE_UPDATE"; d: DiscordVoiceState | VoiceServer; } /** * Voice Server */ interface VoiceServer { token: string; guild_id: string; endpoint: string; } interface Extendable { Player: typeof Player; Queue: typeof MemoryQueue | typeof RedisQueue | typeof JsonQueue; Node: typeof Node; } /** * Voice State */ interface PlayerVoiceState { op: "voiceUpdate"; guildId: string; event: VoiceServer; sessionId?: string; channelId?: string; } /** * Voice State */ interface DiscordVoiceState { guild_id: string; user_id: string; session_id: string; channel_id: string; } /** @deprecated Use DiscordVoiceState or PlayerVoiceState instead */ type VoiceState = DiscordVoiceState | PlayerVoiceState; /** * Node Message */ interface NodeMessage extends NodeStats { type: PlayerEventType; op: "stats" | "playerUpdate" | "event"; guildId: string; } /** * PlayerEvent interface */ interface PlayerEvent { op: "event"; type: PlayerEventType; guildId: string; } /** * Exception interface */ interface Exception { message: string; severity: SeverityTypes; cause: string; } /** * TrackStartEvent interface */ interface TrackStartEvent extends PlayerEvent { type: "TrackStartEvent"; track: TrackData; } /** * TrackEndEvent interface */ interface TrackEndEvent extends PlayerEvent { type: "TrackEndEvent"; track: TrackData; reason: TrackEndReasonTypes; } /** * TrackExceptionEvent interface */ interface TrackExceptionEvent extends PlayerEvent { exception?: Exception; guildId: string; type: "TrackExceptionEvent"; } /** * TrackStuckEvent interface */ interface TrackStuckEvent extends PlayerEvent { type: "TrackStuckEvent"; thresholdMs: number; } /** * WebSocketClosedEvent interface */ interface WebSocketClosedEvent extends PlayerEvent { type: "WebSocketClosedEvent"; code: number; reason: string; byRemote: boolean; } /** * SponsorBlockSegmentsLoaded interface */ interface SponsorBlockSegmentsLoaded extends PlayerEvent { type: "SegmentsLoaded"; segments: { category: string; start: number; end: number; }[]; } /** * SponsorBlockSegmentSkipped interface */ interface SponsorBlockSegmentSkipped extends PlayerEvent { type: "SegmentSkipped"; segment: { category: string; start: number; end: number; }; } /** * SponsorBlockChapterStarted interface */ interface SponsorBlockChapterStarted extends PlayerEvent { type: "ChapterStarted"; /** The chapter which started */ chapter: { /** The name of the chapter */ name: string; start: number; end: number; duration: number; }; } /** * SponsorBlockChaptersLoaded interface */ interface SponsorBlockChaptersLoaded extends PlayerEvent { type: "ChaptersLoaded"; /** All chapters loaded */ chapters: { /** The name of the chapter */ name: string; start: number; end: number; duration: number; }[]; } /** * NodeStats interface */ interface NodeStats { /** The amount of players on the node. */ players: number; /** The amount of playing players on the node. */ playingPlayers: number; /** The uptime for the node. */ uptime: number; /** The memory stats for the node. */ memory: MemoryStats; /** The cpu stats for the node. */ cpu: CPUStats; /** The frame stats for the node. */ frameStats: FrameStats; } /** * NodeStats interface */ interface NodeStats { /** The amount of players on the node. */ players: number; /** The amount of playing players on the node. */ playingPlayers: number; /** The uptime for the node. */ uptime: number; /** The memory stats for the node. */ memory: MemoryStats; /** The cpu stats for the node. */ cpu: CPUStats; /** The frame stats for the node. */ frameStats: FrameStats; } /** * MemoryStats interface */ interface MemoryStats { /** The free memory of the allocated amount. */ free: number; /** The used memory of the allocated amount. */ used: number; /** The total allocated memory. */ allocated: number; /** The reservable memory. */ reservable: number; } /** * CPUStats interface */ interface CPUStats { /** The core amount the host machine has. */ cores: number; /** The system load. */ systemLoad: number; /** The lavalink load. */ lavalinkLoad: number; } /** * FrameStats interface */ interface FrameStats { /** The amount of sent frames. */ sent?: number; /** The amount of nulled frames. */ nulled?: number; /** The amount of deficit frames. */ deficit?: number; } /** * LavalinkInfo interface */ interface LavalinkInfo { version: { semver: string; major: number; minor: number; patch: number; preRelease: string; }; buildTime: number; git: { branch: string; commit: string; commitTime: number; }; jvm: string; lavaplayer: string; sourceManagers: string[]; filters: string[]; plugins: { name: string; version: string; }[]; } /** * LyricsLine interface */ interface LyricsLine { timestamp: number; duration: number; line: string; plugin: object; } /** * Lyrics interface */ interface Lyrics { source: string; provider: string; text?: string; lines: LyricsLine[]; plugin: object[]; } /** * LyricsFoundEvent interface */ interface LyricsFoundEvent extends PlayerEvent { type: "LyricsFoundEvent"; guildId: string; lyrics: Lyrics; } /** * LyricsNotFoundEvent interface */ interface LyricsNotFoundEvent extends PlayerEvent { type: "LyricsNotFoundEvent"; guildId: string; } /** * LyricsLineEvent interface */ interface LyricsLineEvent extends PlayerEvent { type: "LyricsLineEvent"; guildId: string; lineIndex: number; line: LyricsLine; skipped: boolean; } /** * NodeLink Get Lyrics Multiple interface */ interface NodeLinkGetLyricsMultiple { loadType: "lyricsMultiple"; data: NodeLinkGetLyricsData[]; } /** * NodeLink Get Lyrics Empty interface */ interface NodeLinkGetLyricsEmpty { loadType: "empty"; data: Record; } /** * NodeLink Get Lyrics Data interface */ interface NodeLinkGetLyricsData { name: string; synced: boolean; data: { startTime?: number; endTime?: number; text: string; }[]; rtl: boolean; } /** * NodeLink Get Lyrics Single interface */ interface NodeLinkGetLyricsSingle { loadType: "lyricsSingle"; data: NodeLinkGetLyricsData; } /** * NodeLink Get Lyrics Error interface */ interface NodeLinkGetLyricsError { loadType: "error"; data: { message: string; severity: Severity; cause: string; trace?: string; }; } /** * Start Speaking Event Voice Receiver Data interface */ interface StartSpeakingEventVoiceReceiverData { /** * The user ID of the user who started speaking. */ userId: string; /** * The guild ID of the guild where the user started speaking. */ guildId: string; } /** * End Speaking Event Voice Receiver Data interface */ interface EndSpeakingEventVoiceReceiverData { /** * The user ID of the user who stopped speaking. */ userId: string; /** * The guild ID of the guild where the user stopped speaking. */ guildId: string; /** * The audio data received from the user in base64. */ data: string; /** * The type of the audio data. Can be either opus or pcm. Older versions may include ogg/opus. */ type: "opus" | "pcm"; } /** * Base Voice Receiver Event interface */ interface BaseVoiceReceiverEvent { op: "speak"; } /** * Start Speaking Event Voice Receiver interface */ interface StartSpeakingEventVoiceReceiver extends BaseVoiceReceiverEvent { type: "startSpeakingEvent"; data: StartSpeakingEventVoiceReceiverData; } /** * End Speaking Event Voice Receiver interface */ interface EndSpeakingEventVoiceReceiver extends BaseVoiceReceiverEvent { type: "endSpeakingEvent"; data: EndSpeakingEventVoiceReceiverData; } /** * PlayerOptions interface */ interface PlayerOptions { /** The guild ID the Player belongs to. */ guildId: string; /** The text channel the Player belongs to. */ textChannelId: string; /** The voice channel the Player belongs to. */ voiceChannelId?: string; /** The node identifier the Player uses. */ nodeIdentifier?: string; /** The initial volume the Player will use. */ volume?: number; /** If the player should mute itself. */ selfMute?: boolean; /** If the player should deaf itself. */ selfDeafen?: boolean; /** Whether to apply the volume as a filter. */ applyVolumeAsFilter?: boolean; /** Whether to pause the player when the voice connection is disconnected. */ pauseOnDisconnect?: boolean; } /** * PlayOptions interface */ interface PlayOptions { /** The position to start the track. */ readonly startTime?: number; /** The position to end the track. */ readonly endTime?: number; /** Whether to not replace the track if a play payload is sent. */ readonly noReplace?: boolean; } /** * RestPlayOptions interface */ interface RestPlayOptions { /** The guild ID the Player belongs to. */ guildId: string; /** Whether to not replace the track if a play payload is sent. */ noReplace?: boolean; data: { /** The base64 encoded track. */ track?: { /** The base64 encoded track. */ encoded?: string | null; /** The track ID. */ identifier?: string | null; /** The user data of the track. */ userData?: object; }; /** The player position in a track. */ position?: number; /** The track time to end at. */ endTime?: number; /** The player volume level. */ volume?: number; /** Whether the player is paused. */ paused?: boolean; /** The audio effects. */ filters?: object; /** voice payload. */ voice?: LavalinkVoiceStateUpdate; }; } /** * PlayerStateEntry interface */ interface SerializedPlayerState { clusterId: number; guildId: string; voiceChannelId: string | null; textChannelId: string | null; volume: number; position: number; isAutoplay?: boolean; autoplayTries?: number; paused: boolean; playing: boolean; trackRepeat: boolean; queueRepeat: boolean; dynamicRepeat: boolean; dynamicLoopInterval?: number; voiceState: PlayerVoiceState; options: PlayerOptions; node: { sessionId: string; options: { identifier: string; }; } | null; queue: { current: Track | null; tracks: Track[]; previous: Array; }; filters: { bassBoostlevel: number | null; equalizer: EqualizerBand[]; distortion: DistortionOptions; karaoke: KaraokeOptions; timescale: TimescaleOptions; vibrato: VibratoOptions; rotation: RotationOptions; reverb: ReverbOptions; volume: number; filterStatus: Record; } | null; data?: Record & { clientUser?: AnyUser; nowPlayingMessage?: { id: string; channelId: string; guildId: string; } | null; }; } /** * Lavalink voice state response */ type LavalinkVoiceStateResponse = { token: string; endpoint: string; sessionId: string; channelId: string | null; }; /** * Lavalink voice state update */ type LavalinkVoiceStateUpdate = { token: string; endpoint: string; sessionId: string; channelId: string; }; /** * Lavalink session */ interface LavalinkSession { resuming?: boolean; timeout?: number; } /** * ManagerInitOptions interface */ interface ManagerInitOptions { clientId?: string; clusterId?: number; } /** * EqualizerBand interface */ interface EqualizerBand { /** The band number being 0 to 14. */ band: number; /** The gain amount being -0.25 to 1.00, 0.25 being double. */ gain: number; } /** Options for adjusting the timescale of audio. */ interface TimescaleOptions { speed?: number; pitch?: number; rate?: number; } /** Options for applying vibrato effect to audio. */ interface VibratoOptions { frequency: number; depth: number; } /** Options for applying rotation effect to audio. */ interface RotationOptions { rotationHz: number; } /** Options for applying karaoke effect to audio. */ interface KaraokeOptions { level?: number; monoLevel?: number; filterBand?: number; filterWidth?: number; } /** Options for applying distortion effect to audio. */ interface DistortionOptions { sinOffset?: number; sinScale?: number; cosOffset?: number; cosScale?: number; tanOffset?: number; tanScale?: number; offset?: number; scale?: number; } /** Options for applying reverb effect to audio. */ interface ReverbOptions { wet?: number; dry?: number; roomSize?: number; damping?: number; } interface LastFmResponse { error?: number; toptracks?: { track: Array<{ name: string; artist: { name: string; }; }>; }; similartracks?: { track: Array<{ name: string; artist: { name: string; }; }>; }; results?: { trackmatches?: { track: Array<{ artist: string; }>; }; }; } /** * Queue interface */ interface IQueue { getCurrent(): Track | Promise; setCurrent(track: Track | null): void | Promise; getPrevious(): Track[] | Promise; addPrevious(track: Track | Track[]): void | Promise; setPrevious(track: Track | Track[]): void | Promise; /** Get newest track (index 0) */ popPrevious(): Track | Promise; clearPrevious(): void | Promise; size(): number | Promise; totalSize(): number | Promise; duration(): number | Promise; add(track: Track | Track[], offset?: number): void | Promise; remove(start?: number, end?: number): Track[] | Promise; clear(): void | Promise; dequeue(): Track | Promise; enqueueFront(track: Track | Track[]): void | Promise; getTracks(): Track[] | Promise; getSlice(start?: number, end?: number): Track[] | Promise; modifyAt(start: number, deleteCount?: number, ...items: Track[]): Track[] | Promise; shuffle(): void | Promise; userBlockShuffle(): void | Promise; roundRobinShuffle(): void | Promise; mapAsync(callback: (track: Track, index: number, array: Track[]) => T): T[] | Promise; filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track[] | Promise; findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track | Promise; someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean | Promise; everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean | Promise; destroy(): void | Promise; } /** * Sizes Enum type */ type Sizes = "0" | "1" | "2" | "3" | "default" | "mqdefault" | "hqdefault" | "maxresdefault"; /** * Track Source Name Enum type */ type TrackSourceName = keyof typeof TrackSourceTypes; /** * Use Node Option Enum type */ type UseNodeOption = keyof typeof UseNodeOptions; /** * Track End Reason Enum type */ type TrackEndReason = keyof typeof TrackEndReasonTypes; /** * Player Event Type Enum type */ type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted" | "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent"; /** * Severity Types Enum type */ type Severity = keyof typeof SeverityTypes; /** * SponsorBlock Segment Events Enum type */ type SponsorBlockSegmentEvents = SponsorBlockSegmentSkipped | SponsorBlockSegmentsLoaded | SponsorBlockChapterStarted | SponsorBlockChaptersLoaded; /** * SponsorBlock Segment Event Type Enum type */ type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "ChapterStarted" | "ChaptersLoaded"; /** * Player Events Enum type */ type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents | LyricsEvent; /** * Load Type Enum type */ type LoadType = keyof typeof LoadTypes; /** * NodeLink Get Lyrics Enum type */ type NodeLinkGetLyrics = NodeLinkGetLyricsSingle | NodeLinkGetLyricsMultiple | NodeLinkGetLyricsEmpty | NodeLinkGetLyricsError; /** * Voice Receiver Event Enum type */ type VoiceReceiverEvent = StartSpeakingEventVoiceReceiver | EndSpeakingEventVoiceReceiver; /** * Search Result Enum type */ type SearchResult = TrackSearchResult | SearchSearchResult | PlaylistSearchResult | ErrorOrEmptySearchResult | AlbumSearchResult | ArtistSearchResult | StationSearchResult | PodcastSearchResult | ShowSearchResult | ShortSearchResult; /** * Lyrics Event Enum type */ type LyricsEvent = LyricsFoundEvent | LyricsNotFoundEvent | LyricsLineEvent; /** * Lyrics Event Type Enum type */ type LyricsEventType = "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent"; declare class Player { options: PlayerOptions; /** The Queue for the Player. */ queue: IQueue; /** The filters applied to the audio. */ filters: Filters; /** Whether the queue repeats the track. */ trackRepeat: boolean; /** Whether the queue repeats the queue. */ queueRepeat: boolean; /**Whether the queue repeats and shuffles after each song. */ dynamicRepeat: boolean; /** The time the player is in the track. */ position: number; /** Whether the player is playing. */ playing: boolean; /** Whether the player is paused. */ paused: boolean; /** The volume for the player */ volume: number; /** The Node for the Player. */ node: Node; /** The guild ID for the player. */ guildId: string; /** The voice channel for the player. */ voiceChannelId: string | null; /** The text channel for the player. */ textChannelId: string | null; /**The now playing message. */ nowPlayingMessage?: AnyMessage; /** The current state of the player. */ state: StateTypes; /** The equalizer bands array. */ bands: number[]; /** The voice state object from the node. */ voiceState: PlayerVoiceState; /** The Manager. */ manager: Manager; /** The autoplay state of the player. */ isAutoplay: boolean; /** The number of times to try autoplay before emitting queueEnd. */ autoplayTries: number; /** The cluster ID for the player. */ clusterId: number; private readonly data; private dynamicLoopInterval; dynamicRepeatIntervalMs: number | null; private static _manager; /** Should only be used when the node is a NodeLink */ protected voiceReceiverWsClient: WebSocket | null; protected isConnectToVoiceReceiver: boolean; protected voiceReceiverReconnectTimeout: NodeJS.Timeout | null; protected voiceReceiverAttempt: number; protected voiceReceiverReconnectTries: number; /** * Creates a new player, returns one if it already exists. * @param options The player options. * @see https://docs.magmastream.com/main/introduction/getting-started */ constructor(options: PlayerOptions); /** * Initializes the static properties of the Player class. * @hidden * @param manager The Manager to use. */ static init(manager: Manager): void; /** * Set custom data. * @param key - The key to set the data for. * @param value - The value to set the data to. */ set(key: string, value: unknown): void; /** * Retrieves custom data associated with a given key. * @template T - The expected type of the data. * @param {string} key - The key to retrieve the data for. * @returns {T} - The data associated with the key, cast to the specified type. */ get(key: string): T; /** * Same as Manager#search() but a shortcut on the player itself. * @param query * @param requester */ search(query: string | SearchQuery, requester?: T): Promise; /** * Connects the player to the voice channel. * @throws {RangeError} If no voice channel has been set. * @returns {void} */ connect(): void; /** * Disconnects the player from the voice channel. * @returns {this} The player instance. */ disconnect(): Promise; /** * Destroys the player and clears the queue. * @param {boolean} disconnect - Whether to disconnect the player from the voice channel. * @returns {Promise} - Whether the player was successfully destroyed. * @emits {PlayerDestroy} - Emitted when the player is destroyed. * @emits {PlayerStateUpdate} - Emitted when the player state is updated. */ destroy(disconnect?: boolean): Promise; /** * Sets the player voice channel. * @param {string} channel - The new voice channel ID. * @returns {this} - The player instance. * @throws {TypeError} If the channel parameter is not a string. */ setVoiceChannelId(channel: string): this; /** * Sets the player text channel. * * This method updates the text channel associated with the player. It also * emits a player state update event indicating the change in the channel. * * @param {string} channel - The new text channel ID. * @returns {this} - The player instance for method chaining. * @throws {TypeError} If the channel parameter is not a string. */ setTextChannelId(channel: string): this; /** * Sets the now playing message. * * @param message - The message of the now playing message. * @returns The now playing message. */ setNowPlayingMessage(message: AnyMessage): AnyMessage; /** * Plays the next track. * * If a track is provided, it will be played. Otherwise, the next track in the queue will be played. * If the queue is not empty, but the current track has not finished yet, it will be replaced with the provided track. * * @param {object} [optionsOrTrack] - The track to play or the options to play with. * @param {object} [playOptions] - The options to play with. * * @returns {Promise} */ play(): Promise; play(track: Track): Promise; play(options: PlayOptions): Promise; play(track: Track, options: PlayOptions): Promise; /** * Sets the autoplay-state of the player. * * Autoplay is a feature that makes the player play a recommended * track when the current track ends. * * @param {boolean} autoplayState - Whether or not autoplay should be enabled. * @param {object} AutoplayUser - The user-object that should be used as the bot-user. * @param {number} [tries=3] - The number of times the player should try to find a * recommended track if the first one doesn't work. * @returns {this} - The player instance. */ setAutoplay(autoplayState: boolean, AutoplayUser?: T, tries?: number): this; /** * Gets recommended tracks and returns an array of tracks. * @param {Track} track - The track to find recommendations for. * @returns {Promise} - Array of recommended tracks. */ getRecommendedTracks(track: Track): Promise; /** * Sets the volume of the player. * @param {number} volume - The new volume. Must be between 0 and 500 when using filter mode (100 = 100%). * @returns {Promise} - The updated player. * @throws {TypeError} If the volume is not a number. * @throws {RangeError} If the volume is not between 0 and 500 when using filter mode (100 = 100%). * @emits {PlayerStateUpdate} - Emitted when the volume is changed. * @example * player.setVolume(50); */ setVolume(volume: number): Promise; /** * Sets the sponsorblock for the player. This will set the sponsorblock segments for the player to the given segments. * @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided. * @returns {Promise} The promise is resolved when the operation is complete. */ setSponsorBlock(segments?: SponsorBlockSegment[]): Promise; /** * Gets the sponsorblock for the player. * @returns {Promise} The sponsorblock segments. */ getSponsorBlock(): Promise; /** * Deletes the sponsorblock for the player. This will remove all sponsorblock segments that have been set for the player. * @returns {Promise} */ deleteSponsorBlock(): Promise; /** * Sets the track repeat mode. * When track repeat is enabled, the current track will replay after it ends. * Disables queueRepeat and dynamicRepeat modes if enabled. * * @param repeat - A boolean indicating whether to enable track repeat. * @returns {this} - The player instance. * @throws {TypeError} If the repeat parameter is not a boolean. */ setTrackRepeat(repeat: boolean): this; /** * Sets the queue repeat. * @param repeat Whether to repeat the queue or not * @returns {this} - The player instance. * @throws {TypeError} If the repeat parameter is not a boolean */ setQueueRepeat(repeat: boolean): this; /** * Sets the queue to repeat and shuffles the queue after each song. * @param repeat "true" or "false". * @param ms After how many milliseconds to trigger dynamic repeat. * @returns {this} - The player instance. * @throws {TypeError} If the repeat parameter is not a boolean. * @throws {RangeError} If the queue size is less than or equal to 1. */ setDynamicRepeat(repeat: boolean, ms: number): Promise; /** * Restarts the currently playing track from the beginning. * If there is no track playing, it will play the next track in the queue. * @returns {Promise} The current instance of the Player class for method chaining. */ restart(): Promise; /** * Stops the player and optionally removes tracks from the queue. * @param {number} [amount] The amount of tracks to remove from the queue. If not provided, removes the current track if it exists. * @returns {Promise} - The player instance. * @throws {RangeError} If the amount is greater than the queue length. */ stop(amount?: number): Promise; /** * Skips the current track. * @returns {this} - The player instance. * @throws {Error} If there are no tracks in the queue. * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type. */ pause(pause: boolean): Promise; /** * Skips to the previous track in the queue. * @returns {this} - The player instance. * @throws {Error} If there are no previous tracks in the queue. * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type. */ previous(addBackToQueue?: boolean): Promise; /** * Seeks to a given position in the currently playing track. * @param position - The position in milliseconds to seek to. * @returns {this} - The player instance. * @throws {Error} If the position is invalid. * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type. */ seek(position: number): Promise; /** * Returns the current repeat state of the player. * @param player The player to get the repeat state from. * @returns The repeat state of the player, or null if it is not repeating. */ private getRepeatState; /** * Automatically moves the player to a usable node. * @returns {Promise} - The player instance or void if not moved. */ autoMoveNode(): Promise; /** * Moves the player to another node. * @param {string} identifier - The identifier of the node to move to. * @returns {Promise} - The player instance after being moved. */ moveNode(identifier: string): Promise; /** * Retrieves the data associated with the player. * @returns {Record} - The data associated with the player. */ getData(): Record; /** * Retrieves the dynamic loop interval of the player. * @returns {NodeJS.Timeout | null} - The dynamic loop interval of the player. */ getDynamicLoopIntervalPublic(): NodeJS.Timeout | null; /** * Retrieves the data associated with the player. * @returns {Record} - The data associated with the player. */ getSerializableData(): Record; /** * Retrieves the current lyrics for the playing track. * @param skipTrackSource - Indicates whether to skip the track source when fetching lyrics. * @returns {Promise} - The lyrics of the current track. */ getCurrentLyrics(skipTrackSource?: boolean): Promise; /** * Sets up the voice receiver for the player. * @returns {Promise} - A promise that resolves when the voice receiver is set up. * @throws {Error} - If the node is not a NodeLink. */ setupVoiceReceiver(): Promise; /** * Removes the voice receiver for the player. * @returns {Promise} - A promise that resolves when the voice receiver is removed. * @throws {Error} - If the node is not a NodeLink. */ removeVoiceReceiver(): Promise; /** * Closes the voice receiver for the player. * @param {number} code - The code to close the voice receiver with. * @param {string} reason - The reason to close the voice receiver with. * @returns {Promise} - A promise that resolves when the voice receiver is closed. */ private closeVoiceReceiver; /** * Reconnects the voice receiver for the player. * @returns {Promise} - A promise that resolves when the voice receiver is reconnected. */ private reconnectVoiceReceiver; /** * Disconnects the voice receiver for the player. * @returns {Promise} - A promise that resolves when the voice receiver is disconnected. */ private disconnectVoiceReceiver; /** * Opens the voice receiver for the player. * @returns {Promise} - A promise that resolves when the voice receiver is opened. */ private openVoiceReceiver; /** * Handles a voice receiver message. * @param {string} payload - The payload to handle. * @returns {Promise} - A promise that resolves when the voice receiver message is handled. */ private onVoiceReceiverMessage; /** * Handles a voice receiver error. * @param {Error} error - The error to handle. * @returns {Promise} - A promise that resolves when the voice receiver error is handled. */ private onVoiceReceiverError; /** * Updates the voice state for the player. * @returns {Promise} - A promise that resolves when the voice state is updated. */ updateVoice(): Promise; } /** Handles the requests sent to the Lavalink REST API. */ declare class Rest { /** The Node that this Rest instance is connected to. */ private node; /** The password for the Node. */ private readonly password; /** The URL of the Node. */ private readonly url; /** The Manager instance. */ manager: Manager; /** Whether the node is a NodeLink. */ isNodeLink: boolean; constructor(node: Node, manager: Manager); /** * Gets the session ID. * @returns {string} Returns the session ID. */ private get sessionId(); /** * Sets the session ID. * This method is used to set the session ID after a resume operation is done. * @param {string} sessionId The session ID to set. * @returns {string} Returns the set session ID. */ setSessionId(sessionId: string): string; /** * Retrieves the player that is currently running on the node. * @param {string} guildId The guild ID of the player to retrieve. * @returns {Promise} Returns the player. */ getPlayer(guildId: string): Promise; /** * Sends a PATCH request to update player related data. * @param {RestPlayOptions} options The options to update the player with. * @returns {Promise} Returns the updated player. */ updatePlayer(options: RestPlayOptions): Promise; /** * Sends a DELETE request to the server to destroy the player. * @param {string} guildId The guild ID of the player to destroy. * @returns {Promise} Returns void (204 No Content). */ destroyPlayer(guildId: string): Promise; /** * Updates the session status for resuming. * @param {boolean} resuming - Indicates whether the session should be set to resuming. * @param {number} timeout - The timeout duration for the session resume. * @returns {Promise} The updated session. */ updateSession(resuming: boolean, timeout: number): Promise; /** * Sends a request to the specified endpoint and returns the response data. * @param {string} method The HTTP method to use for the request. * @param {string} endpoint The endpoint to send the request to. * @param {unknown} [body] The data to send in the request body. * @returns {Promise} The response data of the request. */ private request; /** * Sends a GET request to the specified endpoint and returns the response data. * @param {string} endpoint The endpoint to send the GET request to. * @returns {Promise} The response data of the GET request. */ get(endpoint: string): Promise; /** * Sends a PATCH request to the specified endpoint and returns the response data. * @param {string} endpoint The endpoint to send the PATCH request to. * @param {unknown} body The data to send in the request body. * @returns {Promise} The response data of the PATCH request. */ patch(endpoint: string, body: unknown): Promise; /** * Sends a POST request to the specified endpoint and returns the response data. * @param {string} endpoint The endpoint to send the POST request to. * @param {unknown} body The data to send in the request body. * @returns {Promise} The response data of the POST request. */ post(endpoint: string, body: unknown): Promise; /** * Sends a PUT request to the specified endpoint and returns the response data. * @param {string} endpoint The endpoint to send the PUT request to. * @param {unknown} body The data to send in the request body. * @returns {Promise} The response data of the PUT request. */ put(endpoint: string, body: unknown): Promise; /** * Sends a DELETE request to the specified endpoint. * @param {string} endpoint - The endpoint to send the DELETE request to. * @returns {Promise} Void. */ delete(endpoint: string): Promise; } declare class Node { manager: Manager; options: NodeOptions; /** The socket for the node. */ socket: WebSocket$1 | null; /** The stats for the node. */ stats: NodeStats; /** The manager for the node */ /** The node's session ID. */ sessionId: string | null; /** The REST instance. */ readonly rest: Rest; /** Actual Lavalink information of the node. */ info: LavalinkInfo | null; /** Whether the node is a NodeLink. */ isNodeLink: boolean; private reconnectTimeout?; private reconnectAttempts; private redisPrefix?; private sessionIdsMap; /** * Creates an instance of Node. * @param manager - The manager for the node. * @param options - The options for the node. */ constructor(manager: Manager, options: NodeOptions); /** * Checks if the Node is currently connected. * This method returns true if the Node has an active WebSocket connection, indicating it is ready to receive and process commands. */ get connected(): boolean; /** Returns the full address for this node, including the host and port. */ get address(): string; private getCompositeKey; private getRedisSessionIdsKey; private getNodeSessionsDir; private getNodeSessionPath; /** * Loads session IDs from the sessionIds.json file if it exists. * The session IDs are used to resume sessions for each node. * * The session IDs are stored in the sessionIds.json file as a composite key * of the node identifier and cluster ID. This allows multiple clusters to * be used with the same node identifier. */ loadSessionIds(): Promise; /** * Updates the session ID in the sessionIds.json file. * * This method is called after the session ID has been updated, and it * writes the new session ID to the sessionIds.json file. * * @remarks * The session ID is stored in the sessionIds.json file as a composite key * of the node identifier and cluster ID. This allows multiple clusters to * be used with the same node identifier. */ updateSessionId(): Promise; private updateSessionIdFile; private updateSessionIdRedis; /** * Connects to the Node. * * @remarks * If the node is already connected, this method will do nothing. * If the node has a session ID, it will be sent in the headers of the WebSocket connection. * If the node has no session ID but the `enableSessionResumeOption` option is true, it will use the session ID * stored in the sessionIds.json file if it exists. */ connect(): Promise; /** * Destroys the node and cleans up associated resources. * * This method emits a debug event indicating that the node is being destroyed and attempts * to automatically move all players connected to the node to a usable one. It then closes * the WebSocket connection, removes all event listeners, and clears the reconnect timeout. * Finally, it emits a "nodeDestroy" event and removes the node from the manager. * * @returns {Promise} A promise that resolves when the node and its resources have been destroyed. */ destroy(): Promise; /** * Attempts to reconnect to the node if the connection is lost. * * This method is called when the WebSocket connection is closed * unexpectedly. It will attempt to reconnect to the node after a * specified delay, and will continue to do so until the maximum * number of retry attempts is reached or the node is manually destroyed. * If the maximum number of retry attempts is reached, an error event * will be emitted and the node will be destroyed. * * @returns {Promise} - Resolves when the reconnection attempt is scheduled. * @emits {debug} - Emits a debug event indicating the node is attempting to reconnect. * @emits {nodeReconnect} - Emits a nodeReconnect event when the node is attempting to reconnect. * @emits {nodeError} - Emits an error event if the maximum number of retry attempts is reached. * @emits {nodeDestroy} - Emits a nodeDestroy event if the maximum number of retry attempts is reached. */ private reconnect; /** * Upgrades the node to a NodeLink. * * @param request - The incoming message. */ private upgrade; /** * Handles the "open" event emitted by the WebSocket connection. * * This method is called when the WebSocket connection is established. * It clears any existing reconnect timeouts, emits a debug event * indicating the node is connected, and emits a "nodeConnect" event * with the node as the argument. */ protected open(): void; /** * Handles the "close" event emitted by the WebSocket connection. * * This method is called when the WebSocket connection is closed. * It emits a "nodeDisconnect" event with the node and the close event as arguments, * and a debug event indicating the node is disconnected. * It then attempts to move all players connected to that node to a useable one. * If the close event was not initiated by the user, it will also attempt to reconnect. * * @param {number} code The close code of the WebSocket connection. * @param {string} reason The reason for the close event. * @returns {Promise} A promise that resolves when the disconnection is handled. */ protected close(code: number, reason: string): Promise; /** * Handles the "error" event emitted by the WebSocket connection. * * This method is called when an error occurs on the WebSocket connection. * It emits a "nodeError" event with the node and the error as arguments and * a debug event indicating the error on the node. * @param {Error} error The error that occurred. */ protected error(error: Error): void; /** * Handles incoming messages from the Lavalink WebSocket connection. * @param {Buffer | string} d The message received from the WebSocket connection. * @returns {Promise} A promise that resolves when the message is handled. * @emits {debug} - Emits a debug event with the message received from the WebSocket connection. * @emits {nodeError} - Emits a nodeError event if an unexpected op is received. * @emits {nodeRaw} - Emits a nodeRaw event with the raw message received from the WebSocket connection. * @private */ protected message(d: Buffer | string): Promise; /** * Handles an event emitted from the Lavalink node. * @param {PlayerEvent & PlayerEvents} payload The event emitted from the node. * @returns {Promise} A promise that resolves when the event has been handled. * @private */ protected handleEvent(payload: PlayerEvent & PlayerEvents): Promise; /** * Emitted when a new track starts playing. * @param {Player} player The player that started playing the track. * @param {Track} track The track that started playing. * @param {TrackStartEvent} payload The payload of the event emitted by the node. * @private */ protected trackStart(player: Player, track: Track, payload: TrackStartEvent): void; /** * Emitted when a track ends playing. * @param {Player} player - The player that the track ended on. * @param {Track} track - The track that ended. * @param {TrackEndEvent} payload - The payload of the event emitted by the node. * @private */ trackEnd(player: Player, track: Track, payload: TrackEndEvent): Promise; /** * Handles autoplay logic for a player. * This method is responsible for selecting an appropriate method of autoplay * and executing it. If autoplay is not enabled or all attempts have failed, * it will return false. * @param {Player} player - The player to handle autoplay for. * @param {number} attempt - The current attempt number of the autoplay. * @returns {Promise} A promise that resolves to a boolean indicating if autoplay was successful. * @private */ private handleAutoplay; /** * Handles the scenario when a track fails to play or load. * Shifts the queue to the next track and emits a track end event. * If there is no next track, handles the queue end scenario. * If autoplay is enabled, plays the next track. * * @param {Player} player - The player instance associated with the track. * @param {Track} track - The track that failed. * @param {TrackEndEvent} payload - The event payload containing details about the track end. * @returns {Promise} A promise that resolves when the track failure has been processed. * @private */ private handleFailedTrack; /** * Handles the scenario when a track is repeated. * Shifts the queue to the next track and emits a track end event. * If there is no next track, handles the queue end scenario. * If autoplay is enabled, plays the next track. * * @param {Player} player - The player instance associated with the track. * @param {Track} track - The track that is repeated. * @param {TrackEndEvent} payload - The event payload containing details about the track end. * @returns {Promise} A promise that resolves when the repeated track has been processed. * @private */ private handleRepeatedTrack; /** * Plays the next track in the queue. * Updates the queue by shifting the current track to the previous track * and plays the next track if autoplay is enabled. * * @param {Player} player - The player associated with the track. * @param {Track} track - The track that has ended. * @param {TrackEndEvent} payload - The event payload containing additional data about the track end event. * @returns {void} * @private */ private playNextTrack; /** * Handles the event when a queue ends. * If autoplay is enabled, attempts to play the next track in the queue using the autoplay logic. * If all attempts fail, resets the player state and emits the `queueEnd` event. * @param {Player} player - The player associated with the track. * @param {Track} track - The track that has ended. * @param {TrackEndEvent} payload - The event payload containing additional data about the track end event. * @returns {Promise} A promise that resolves when the queue end processing is complete. */ queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise; /** * Fetches the lyrics of a track from the Lavalink node. * * If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics. * * Requires the `lavalyrics-plugin` to be present in the Lavalink node. * Requires the `lavasrc-plugin` or `java-lyrics-plugin` to be present in the Lavalink node. * * @param {Track} track - The track to fetch the lyrics for. * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL. * @param {string} [language="en"] - The language of the lyrics. * @returns {Promise} A promise that resolves with the lyrics data. */ getLyrics(track: Track, skipTrackSource?: boolean, language?: string): Promise; /** * Subscribes to lyrics for a player. * @param {string} guildId - The ID of the guild to subscribe to lyrics for. * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL. * @returns {Promise} A promise that resolves when the subscription is complete. * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available. */ lyricsSubscribe(guildId: string, skipTrackSource?: boolean): Promise; /** * Unsubscribes from lyrics for a player. * @param {string} guildId - The ID of the guild to unsubscribe from lyrics for. * @returns {Promise} A promise that resolves when the unsubscription is complete. * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available. */ lyricsUnsubscribe(guildId: string): Promise; /** * Handles the event when a track becomes stuck during playback. * Stops the current track and emits a `trackStuck` event. * * @param {Player} player - The player associated with the track that became stuck. * @param {Track} track - The track that became stuck. * @param {TrackStuckEvent} payload - The event payload containing additional data about the track stuck event. * @returns {void} * @protected */ protected trackStuck(player: Player, track: Track, payload: TrackStuckEvent): Promise; /** * Handles the event when a track has an error during playback. * Stops the current track and emits a `trackError` event. * * @param {Player} player - The player associated with the track that had an error. * @param {Track} track - The track that had an error. * @param {TrackExceptionEvent} payload - The event payload containing additional data about the track error event. * @returns {void} * @protected */ protected trackError(player: Player, track: Track, payload: TrackExceptionEvent): Promise; /** * Emitted when the WebSocket connection for a player closes. * The payload of the event will contain the close code and reason if provided. * @param {Player} player - The player associated with the WebSocket connection. * @param {WebSocketClosedEvent} payload - The event payload containing additional data about the WebSocket close event. */ protected socketClosed(player: Player, payload: WebSocketClosedEvent): void; /** * Emitted when the segments for a track are loaded. * The payload of the event will contain the segments. * @param {Player} player - The player associated with the segments. * @param {Track} track - The track associated with the segments. * @param {SponsorBlockSegmentsLoaded} payload - The event payload containing additional data about the segments loaded event. */ private sponsorBlockSegmentLoaded; /** * Emitted when a segment of a track is skipped using the sponsorblock plugin. * The payload of the event will contain the skipped segment. * @param {Player} player - The player associated with the skipped segment. * @param {Track} track - The track associated with the skipped segment. * @param {SponsorBlockSegmentSkipped} payload - The event payload containing additional data about the segment skipped event. */ private sponsorBlockSegmentSkipped; /** * Emitted when chapters for a track are loaded using the sponsorblock plugin. * The payload of the event will contain the chapters. * @param {Player} player - The player associated with the chapters. * @param {Track} track - The track associated with the chapters. * @param {SponsorBlockChaptersLoaded} payload - The event payload containing additional data about the chapters loaded event. */ private sponsorBlockChaptersLoaded; /** * Emitted when a chapter of a track is started using the sponsorblock plugin. * The payload of the event will contain the started chapter. * @param {Player} player - The player associated with the started chapter. * @param {Track} track - The track associated with the started chapter. * @param {SponsorBlockChapterStarted} payload - The event payload containing additional data about the chapter started event. */ private sponsorBlockChapterStarted; /** * Emitted when lyrics for a track are found. * The payload of the event will contain the lyrics. * @param {Player} player - The player associated with the lyrics. * @param {Track} track - The track associated with the lyrics. * @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event. */ private lyricsFound; /** * Emitted when lyrics for a track are not found. * The payload of the event will contain the track. * @param {Player} player - The player associated with the lyrics. * @param {Track} track - The track associated with the lyrics. * @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event. */ private lyricsNotFound; /** * Emitted when a line of lyrics for a track is received. * The payload of the event will contain the lyrics line. * @param {Player} player - The player associated with the lyrics line. * @param {Track} track - The track associated with the lyrics line. * @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event. */ private lyricsLine; /** * Fetches Lavalink node information. * @returns {Promise} A promise that resolves to the Lavalink node information. */ fetchInfo(): Promise; /** * Gets the current sponsorblock segments for a player. * @param {Player} player - The player to get the sponsorblocks for. * @returns {Promise} A promise that resolves to the sponsorblock segments. * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node. */ getSponsorBlock(player: Player): Promise; /** * Sets the sponsorblock segments for a player. * @param {Player} player - The player to set the sponsor blocks for. * @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided. * @returns {Promise} The promise is resolved when the operation is complete. * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node. * @throws {RangeError} If no segments are provided. * @throws {SyntaxError} If an invalid sponsorblock is provided. * @example * ```ts * // use it on the player via player.setSponsorBlock(); * player.setSponsorBlock([SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]); * ``` */ setSponsorBlock(player: Player, segments?: SponsorBlockSegment[]): Promise; /** * Deletes the sponsorblock segments for a player. * @param {Player} player - The player to delete the sponsorblocks for. * @returns {Promise} The promise is resolved when the operation is complete. * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node. */ deleteSponsorBlock(player: Player): Promise; /** * Creates a README.md or README.txt file in the magmastream directory * if it doesn't already exist. This file is used to store player data * for autoresume and other features. * @private */ private createReadmeFile; } /** * The main hub for interacting with Lavalink and using Magmastream. */ declare class Manager extends EventEmitter { /** The map of players. */ readonly players: Collection; /** The map of nodes. */ readonly nodes: Collection; /** The options that were set. */ readonly options: ManagerOptions; initiated: boolean; redis?: Redis; private _send; private _getUser?; private _getGuild?; private loadedPlugins; /** * Initiates the Manager class. * @param options * @param options.enabledPlugins - An array of enabledPlugins to load. * @param options.nodes - An array of node options to create nodes from. * @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created. * @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found. * @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on. * @param options.clientName - The name of the client to send to Lavalink. * @param options.defaultSearchPlatform - The default search platform to use when searching for tracks. * @param options.useNode - The strategy to use when selecting a node to play on. * @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track. * @param options.eventBatchDuration - The duration to wait before processing the collected player state events. * @param options.eventBatchInterval - The interval to wait before processing the collected player state events. */ constructor(options: StandaloneManagerOptions); constructor(options: ManagerOptions, isWrapper: true); /** * Initiates the Manager. * @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers). * @param clusterId - The cluster ID which runs the current process (required). * @returns The manager instance. */ init(options?: ManagerInitOptions): Promise; /** * Searches the enabled sources based off the URL or the `source` property. * @param query * @param requester * @returns The search result. */ search(query: string | SearchQuery, requester?: T): Promise; /** * Returns a player or undefined if it does not exist. * @param guildId The guild ID of the player to retrieve. * @returns The player if it exists, undefined otherwise. */ getPlayer(guildId: string): Player | undefined; /** * Creates a player or returns one if it already exists. * @param options The options to create the player with. * @returns The created player. */ create(options: PlayerOptions): Player; /** * Destroys a player. * @param guildId The guild ID of the player to destroy. * @returns A promise that resolves when the player has been destroyed. */ destroy(guildId: string): Promise; /** * Creates a new node or returns an existing one if it already exists. * @param options - The options to create the node with. * @returns The created node. */ createNode(options: NodeOptions): Node; /** * Destroys a node if it exists. Emits a debug event if the node is found and destroyed. * @param identifier - The identifier of the node to destroy. * @returns {void} * @emits {debug} - Emits a debug message indicating the node is being destroyed. */ destroyNode(identifier: string): Promise; /** * Attaches an event listener to the manager. * @param event The event to listen for. * @param listener The function to call when the event is emitted. * @returns The manager instance for chaining. */ on(event: T, listener: (...args: ManagerEvents[T]) => void): this; /** * Updates the voice state of a player based on the provided data. * @param data - The data containing voice state information, which can be a VoicePacket, VoiceServer, or VoiceState. * @returns A promise that resolves when the voice state update is handled. * @emits {debug} - Emits a debug message indicating the voice state is being updated. */ updateVoiceState(data: VoicePacket | VoiceServer | DiscordVoiceState): Promise; /** * Decodes an array of base64 encoded tracks and returns an array of TrackData. * Emits a debug event with the tracks being decoded. * @param tracks - An array of base64 encoded track strings. * @returns A promise that resolves to an array of TrackData objects. * @throws Will throw an error if no nodes are available or if the API request fails. */ decodeTracks(tracks: string[]): Promise; /** * Decodes a base64 encoded track and returns a TrackData. * @param track - The base64 encoded track string. * @returns A promise that resolves to a TrackData object. * @throws Will throw an error if no nodes are available or if the API request fails. */ decodeTrack(track: string): Promise; /** * Saves player states. * @param {string} guildId - The guild ID of the player to save */ savePlayerState(guildId: string): Promise; /** * Sleeps for a specified amount of time. * @param ms The amount of time to sleep in milliseconds. * @returns A promise that resolves after the specified amount of time. */ private sleep; private restorePlayerFromState; private restoreQueue; private restorePreviousQueue; private restoreRepeatState; private restorePlayerData; private restoreFilters; /** * Loads player states from the JSON file. * @param nodeId The ID of the node to load player states from. * @returns A promise that resolves when the player states have been loaded. */ loadPlayerStates(nodeId: string): Promise; /** * Returns the node to use based on the configured `useNode` and `enablePriorityMode` options. * If `enablePriorityMode` is true, the node is chosen based on priority, otherwise it is chosen based on the `useNode` option. * If `useNode` is "leastLoad", the node with the lowest load is chosen, if it is "leastPlayers", the node with the fewest players is chosen. * If `enablePriorityMode` is false and `useNode` is not set, the node with the lowest load is chosen. * @returns {Node} The node to use. */ get useableNode(): Node; /** * Handles the shutdown of the process by saving all active players' states. * This function is called when the process is about to exit. * It iterates through all players and calls {@link savePlayerState} to save their states. * After saving, it exits the process. * @param stopProcess - A function to stop the process. */ handleShutdown(stopProcess?: () => Promise): Promise; /** * Parses a YouTube title into a clean title and author. * @param title - The original title of the YouTube video. * @param originalAuthor - The original author of the YouTube video. * @returns An object with the clean title and author. */ private parseYouTubeTitle; /** * Balances brackets in a given string by ensuring all opened brackets are closed correctly. * @param str - The input string that may contain unbalanced brackets. * @returns A new string with balanced brackets. */ private balanceBrackets; /** * Escapes a string by replacing special regex characters with their escaped counterparts. * @param string - The string to escape. * @returns The escaped string. */ /** * Checks if the given data is a voice update. * @param data The data to check. * @returns Whether the data is a voice update. */ private isVoiceUpdate; /** * Determines if the provided update is a valid voice update. * A valid update must contain either a token or a session_id. * * @param update - The voice update data to validate, which can be a VoicePacket, VoiceServer, or VoiceState. * @returns {boolean} - True if the update is valid, otherwise false. */ private isValidUpdate; /** * Handles a voice server update by updating the player's voice state and sending the voice state to the Lavalink node. * @param player The player for which the voice state is being updated. * @param update The voice server data received from Discord. * @returns A promise that resolves when the voice state update is handled. * @emits {debug} - Emits a debug message indicating the voice state is being updated. */ private handleVoiceServerUpdate; /** * Handles a voice state update by updating the player's voice channel and session ID if provided, or by disconnecting and destroying the player if the channel ID is null. * @param player The player for which the voice state is being updated. * @param update The voice state data received from Discord. * @emits {playerMove} - Emits a player move event if the channel ID is provided and the player is currently connected to a different voice channel. * @emits {playerDisconnect} - Emits a player disconnect event if the channel ID is null. */ private handleVoiceStateUpdate; /** * Cleans up an inactive player by removing its state data. * This is done to prevent stale state data from accumulating. * @param guildId The guild ID of the player to clean up. */ cleanupInactivePlayer(guildId: string): Promise; /** * Loads the enabled plugins. */ private loadPlugins; /** * Unloads the enabled plugins. */ private unloadPlugins; /** * Clears all player states from the file system. * This is done to prevent stale state files from accumulating on the file system. */ private clearAllStoredPlayers; /** * Returns the nodes that has the least load. * The load is calculated by dividing the lavalink load by the number of cores. * The result is multiplied by 100 to get a percentage. * @returns {Collection} */ private get leastLoadNode(); /** * Returns the nodes that have the least amount of players. * Filters out disconnected nodes and sorts the remaining nodes * by the number of players in ascending order. * @returns {Collection} A collection of nodes sorted by player count. */ private get leastPlayersNode(); /** * Returns a node based on priority. * The nodes are sorted by priority in descending order, and then a random number * between 0 and 1 is generated. The node that has a cumulative weight greater than or equal to the * random number is returned. * If no node has a cumulative weight greater than or equal to the random number, the node with the * lowest load is returned. * @returns {Node} The node to use. */ private get priorityNode(); protected send(packet: GatewayVoiceStateUpdate): unknown; protected getUserFromCache(id: string): AnyUser | undefined; protected getGuildFromCache(id: string): AnyGuild | undefined; sendPacket(packet: GatewayVoiceStateUpdate): unknown; /** * Resolves a PortableUser or ID to a real user object. * Can be overridden by wrapper managers to return wrapper-specific User classes. */ resolveUser(user: AnyUser | string): Promise; /** * Resolves a Guild ID to a real guild object. * Can be overridden by wrapper managers to return wrapper-specific Guild classes. */ resolveGuild(guildId: string): AnyGuild; } declare class Filters { distortion: DistortionOptions | null; equalizer: Band[]; karaoke: KaraokeOptions | null; rotation: RotationOptions | null; timescale: TimescaleOptions | null; vibrato: VibratoOptions | null; reverb: ReverbOptions | null; volume: number; bassBoostlevel: number; filtersStatus: Record; manager: Manager; player: Player; constructor(player: Player, manager: Manager); /** * Updates the player's audio filters. * * This method sends a request to the player's node to update the filter settings * based on the current properties of the `Filters` instance. The filters include * distortion, equalizer, karaoke, rotation, timescale, vibrato, and volume. Once * the request is sent, it ensures that the player's audio output reflects the * changes in filter settings. * * @returns {Promise} - Returns a promise that resolves to the current instance * of the Filters class for method chaining. */ updateFilters(): Promise; /** * Applies a specific filter to the player. * * This method allows you to set the value of a specific filter property. * The filter property must be a valid key of the Filters object. * * @param {{ property: T; value: Filters[T] }} filter - An object containing the filter property and value. * @param {boolean} [updateFilters=true] - Whether to update the filters after applying the filter. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ private applyFilter; private emitPlayersTasteUpdate; /** * Sets the status of a specific filter. * * This method updates the filter status to either true or false, indicating whether * the filter is applied or not. This helps track which filters are active. * * @param {AvailableFilters} filter - The filter to update. * @param {boolean} status - The status to set (true for active, false for inactive). * @returns {this} - Returns the current instance of the Filters class for method chaining. */ private setFilterStatus; /** * Retrieves the status of a specific filter. * * This method returns whether a specific filter is currently applied or not. * * @param {AvailableFilters} filter - The filter to check. * @returns {boolean} - Returns true if the filter is active, false otherwise. */ getFilterStatus(filter: AvailableFilters): boolean; /** * Clears all filters applied to the audio. * * This method resets all filter settings to their default values and removes any * active filters from the player. * * @returns {this} - Returns the current instance of the Filters class for method chaining. */ clearFilters(): Promise; /** * Sets the own equalizer bands on the audio. * * This method adjusts the equalization curve of the player's audio output, * allowing you to control the frequency response. * * @param {Band[]} [bands] - The equalizer bands to apply (band, gain). * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ setEqualizer(bands?: Band[]): Promise; /** * Sets the own karaoke options to the audio. * * This method adjusts the audio so that it sounds like a karaoke song, with the * original vocals removed. Note that not all songs can be successfully made into * karaoke tracks, and some tracks may not sound as good. * * @param {KaraokeOptions} [karaoke] - The karaoke settings to apply (level, monoLevel, filterBand, filterWidth). * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ setKaraoke(karaoke?: KaraokeOptions): Promise; /** * Sets the own timescale options to the audio. * * This method adjusts the speed and pitch of the audio, allowing you to control the playback speed. * * @param {TimescaleOptions} [timescale] - The timescale settings to apply (speed and pitch). * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ setTimescale(timescale?: TimescaleOptions): Promise; /** * Sets the own vibrato options to the audio. * * This method applies a vibrato effect to the audio, which adds a wavering, * pulsing quality to the sound. The effect is created by rapidly varying the * pitch of the audio. * * @param {VibratoOptions} [vibrato] - The vibrato settings to apply (frequency, depth). * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ setVibrato(vibrato?: VibratoOptions): Promise; /** * Sets the own rotation options effect to the audio. * * This method applies a rotation effect to the audio, which simulates the sound * moving around the listener's head. This effect can create a dynamic and immersive * audio experience by altering the directionality of the sound. * * @param {RotationOptions} [rotation] - The rotation settings to apply (rotationHz). * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ setRotation(rotation?: RotationOptions): Promise; /** * Sets the own distortion options effect to the audio. * * This method applies a distortion effect to the audio, which adds a rougher, * more intense quality to the sound. The effect is created by altering the * audio signal to create a more jagged, irregular waveform. * * @param {DistortionOptions} [distortion] - The distortion settings to apply (sinOffset, sinScale, cosOffset, cosScale, tanOffset, tanScale, offset, scale). * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ setDistortion(distortion?: DistortionOptions): Promise; /** * Sets the bass boost level on the audio. * * This method scales the gain of a predefined equalizer curve to the specified level. * The curve is designed to emphasize or reduce low frequencies, creating a bass-heavy * or bass-reduced effect. * * @param {number} level - The level of bass boost to apply. The value ranges from -3 to 3, * where negative values reduce bass, 0 disables the effect, * and positive values increase bass. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. * * @example * // Apply different levels of bass boost or reduction: * await player.bassBoost(3); // Maximum Bass Boost * await player.bassBoost(2); // Medium Bass Boost * await player.bassBoost(1); // Mild Bass Boost * await player.bassBoost(0); // No Effect (Disabled) * await player.bassBoost(-1); // Mild Bass Reduction * await player.bassBoost(-2); // Medium Bass Reduction * await player.bassBoost(-3); // Maximum Bass Removal */ bassBoost(stage: number): Promise; /** * Toggles the chipmunk effect on the audio. * * This method applies or removes a chipmunk effect by adjusting the timescale settings. * When enabled, it increases the speed, pitch, and rate of the audio, resulting in a high-pitched, fast playback * similar to the sound of a chipmunk. * * @param {boolean} status - Whether to enable or disable the chipmunk effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ chipmunk(status: boolean): Promise; /** * Toggles the "China" effect on the audio. * * This method applies or removes a filter that reduces the pitch of the audio by half, * without changing the speed or rate. This creates a "hollow" or "echoey" sound. * * @param {boolean} status - Whether to enable or disable the "China" effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ china(status: boolean): Promise; /** * Toggles the 8D audio effect on the audio. * * This method applies or removes an 8D audio effect by adjusting the rotation settings. * When enabled, it creates a sensation of the audio moving around the listener's head, * providing an immersive audio experience. * * @param {boolean} status - Whether to enable or disable the 8D effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ eightD(status: boolean): Promise; /** * Toggles the nightcore effect on the audio. * * This method applies or removes a nightcore effect by adjusting the timescale settings. * When enabled, it increases the speed and pitch of the audio, giving it a more * upbeat and energetic feel. * * @param {boolean} status - Whether to enable or disable the nightcore effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ nightcore(status: boolean): Promise; /** * Toggles the slowmo effect on the audio. * * This method applies or removes a slowmo effect by adjusting the timescale settings. * When enabled, it slows down the audio while keeping the pitch the same, giving it * a more relaxed and calming feel. * * @param {boolean} status - Whether to enable or disable the slowmo effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ slowmo(status: boolean): Promise; /** * Toggles a soft equalizer effect to the audio. * * This method applies or removes a soft equalizer effect by adjusting the equalizer settings. * When enabled, it reduces the bass and treble frequencies, giving the audio a softer and more * mellow sound. * * @param {boolean} status - Whether to enable or disable the soft equalizer effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ soft(status: boolean): Promise; /** * Toggles the TV equalizer effect on the audio. * * This method applies or removes a TV equalizer effect by adjusting the equalizer settings. * When enabled, it enhances specific frequency bands to mimic the audio characteristics * typically found in television audio outputs. * * @param {boolean} status - Whether to enable or disable the TV equalizer effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ tv(status: boolean): Promise; /** * Toggles the treble/bass equalizer effect on the audio. * * This method applies or removes a treble/bass equalizer effect by adjusting the equalizer settings. * When enabled, it enhances the treble and bass frequencies, giving the audio a more balanced sound. * * @param {boolean} status - Whether to enable or disable the treble/bass equalizer effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ trebleBass(status: boolean): Promise; /** * Toggles the vaporwave effect on the audio. * * This method applies or removes a vaporwave effect by adjusting the equalizer settings. * When enabled, it gives the audio a dreamy and nostalgic feel, characteristic of the vaporwave genre. * * @param {boolean} status - Whether to enable or disable the vaporwave effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ vaporwave(status: boolean): Promise; /** * Toggles the distortion effect on the audio. * * This method applies or removes a distortion effect by adjusting the distortion settings. * When enabled, it adds a rougher, more intense quality to the sound by altering the * audio signal to create a more jagged, irregular waveform. * * @param {boolean} status - Whether to enable or disable the distortion effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ distort(status: boolean): Promise; /** * Toggles the party effect on the audio. * * This method applies or removes a party effect by adjusting the equalizer settings. * When enabled, it enhances the bass and treble frequencies, providing a more energetic and lively sound. * * @param {boolean} status - Whether to enable or disable the party effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ pop(status: boolean): Promise; /** * Toggles a party effect on the audio. * * This method applies a party effect to audio. * @param {boolean} status - Whether to enable or disable the party effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ party(status: boolean): Promise; /** * Toggles earrape effect on the audio. * * This method applies earrape effect to audio. * @param {boolean} status - Whether to enable or disable the earrape effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ earrape(status: boolean): Promise; /** * Toggles electronic effect on the audio. * * This method applies electronic effect to audio. * @param {boolean} status - Whether to enable or disable the electronic effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ electronic(status: boolean): Promise; /** * Toggles radio effect on the audio. * * This method applies radio effect to audio. * @param {boolean} status - Whether to enable or disable the radio effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ radio(status: boolean): Promise; /** * Toggles a tremolo effect on the audio. * * This method applies a tremolo effect to audio. * @param {boolean} status - Whether to enable or disable the tremolo effect. * @returns {this} - Returns the current instance of the Filters class for method chaining. */ tremolo(status: boolean): Promise; /** * Toggless a darthvader effect on the audio. * * This method applies a darthvader effect to audio. * @param {boolean} status - Whether to enable or disable the darthvader effect. * @returns {this} - Returns the current instance of the Filters class for method chaining. */ darthvader(status: boolean): Promise; /** * Toggles a daycore effect on the audio. * * This method applies a daycore effect to audio. * @param {boolean} status - Whether to enable or disable the daycore effect. * @returns {this} - Returns the current instance of the Filters class for method chaining. */ daycore(status: boolean): Promise; /** * Toggles a doubletime effect on the audio. * * This method applies a doubletime effect to audio. * @param {boolean} status - Whether to enable or disable the doubletime effect. * @returns {this} - Returns the current instance of the Filters class for method chaining */ doubletime(status: boolean): Promise; /** * Toggles the demon effect on the audio. * * This method applies or removes a demon effect by adjusting the equalizer, * timescale, and reverb settings. When enabled, it creates a deeper and more * intense sound by lowering the pitch and adding reverb to the audio. * * @param {boolean} status - Whether to enable or disable the demon effect. * @returns {Promise} - Returns the current instance of the Filters class for method chaining. */ demon(status: boolean): Promise; } declare abstract class TrackUtils { static trackPartial: TrackPartial[] | null; private static manager; /** * Initializes the TrackUtils class with the given manager. * @param manager The manager instance to use. * @hidden */ static init(manager: Manager): void; /** * Sets the partial properties for the Track class. If a Track has some of its properties removed by the partial, * it will be considered a partial Track. * @param {TrackPartial} partial The array of string property names to remove from the Track class. */ static setTrackPartial(partial: TrackPartial[]): void; /** * Checks if the provided argument is a valid Track. * @param value The value to check. * @returns {boolean} Whether the provided argument is a valid Track. */ static isTrack(track: unknown): track is Track; /** * Checks if the provided argument is a valid Track array. * @param value The value to check. * @returns {boolean} Whether the provided argument is a valid Track array. */ static isTrackArray(value: unknown): value is Track[]; /** * Checks if the provided argument is a valid Track or Track array. * @param value The value to check. * @returns {boolean} Whether the provided argument is a valid Track or Track array. */ static validate(value: unknown): value is Track | Track[]; /** * Builds a Track from the raw data from Lavalink and a optional requester. * @param data The raw data from Lavalink to build the Track from. * @param requester The user who requested the track, if any. * @param isAutoPlay Whether the track is autoplayed. Defaults to false. * @returns The built Track. */ static build(data: TrackData, requester?: T, isAutoplay?: boolean): Track; /** * Validates a search result. * @param result The search result to validate. * @returns Whether the search result is valid. */ static isErrorOrEmptySearchResult(result: SearchResult): result is ErrorOrEmptySearchResult; /** * Revives a track. * @param track The track to revive. * @returns The revived track. */ static revive(track: Track): Track; } declare abstract class AutoPlayUtils { private static manager; /** * Initializes the AutoPlayUtils class with the given manager. * @param manager The manager instance to use. * @hidden */ static init(manager: Manager): Promise; /** * Gets recommended tracks for the given track. * @param track The track to get recommended tracks for. * @returns An array of recommended tracks. */ static getRecommendedTracks(track: Track): Promise; /** * Gets recommended tracks from Last.fm for the given track. * @param track The track to get recommended tracks for. * @param apiKey The API key for Last.fm. * @returns An array of recommended tracks. */ static getRecommendedTracksFromLastFm(track: Track, apiKey: string): Promise; /** * Gets recommended tracks from the given source. * @param track The track to get recommended tracks for. * @param platform The source to get recommended tracks from. * @returns An array of recommended tracks. */ static getRecommendedTracksFromSource(track: Track, platform: AutoPlayPlatform): Promise; /** * Searches for a track using the manager and returns resolved tracks. * @param query The search query (artist - title). * @param requester The requester who initiated the search. * @returns An array of resolved tracks, or an empty array if not found or error occurred. */ private static resolveTracksFromQuery; /** * Resolves the first available track from a search query using the specified source. * Useful for normalizing tracks that lack platform-specific metadata or URIs. * * @param query - The search query string (usually "Artist - Title"). * @param source - The search platform to use (e.g., Spotify, Deezer, YouTube). * @param requester - The requester object, used for context or attribution. * @returns A single resolved {@link Track} object if found, or `null` if the search fails or returns no results. */ private static resolveFirstTrackFromQuery; private static isPlaylistRawData; private static isTrackData; private static isTrackDataArray; static buildTracksFromResponse(recommendedResult: LavalinkResponse, requester?: T): Track[]; } declare abstract class PlayerUtils { private static manager; /** * Initializes the PlayerUtils class with the given manager. * @param manager The manager instance to use. * @hidden */ static init(manager: Manager): void; /** * Serializes a Player instance to avoid circular references. * @param player The Player instance to serialize * @returns The serialized Player instance */ static serializePlayer(player: Player): Promise | null; /** * Gets the base directory for player data. */ static getPlayersBaseDir(): string; /** * Gets the path to the player's directory. */ static getGuildDir(guildId: string): string; /** * Gets the path to the player's state file. */ static getPlayerStatePath(guildId: string): string; /** * Gets the path to the player's current track file. */ static getPlayerCurrentPath(guildId: string): string; /** * Gets the path to the player's queue file. */ static getPlayerQueuePath(guildId: string): string; /** * Gets the path to the player's previous tracks file. */ static getPlayerPreviousPath(guildId: string): string; /** * Gets the Redis key for player storage. */ static getRedisKey(): string; } /** Gets or extends structures to extend the built in, or already extended, classes to add more functionality. */ declare abstract class Structure { /** * Extends a class. * @param name * @param extender */ static extend(name: K, extender: (target: Extendable[K]) => T): T; /** * Get a structure from available structures by name. * @param name */ static get(name: K): Extendable[K]; } declare abstract class JSONUtils { static safe(obj: T, space?: number): string; static serializeTrack(track: Track): string; } interface MagmaStreamErrorOptions { code: MagmaStreamErrorCode; message?: string; cause?: Error; context?: T; } declare class MagmaStreamError extends Error { readonly code: MagmaStreamErrorCode; readonly number: number; readonly context?: T; constructor({ code, message, cause, context }: MagmaStreamErrorOptions); } /** * Cloudstorm wrapper for Magmastream. * * @note Unlike other wrappers, CloudStorm is a gateway-only library with no cache. * You must manually call `manager.init({ clientId: "your-bot-id" })` inside your `ready` event. * * @example * ```typescript * const client = new Client("token", { intents: ["GUILDS", "GUILD_VOICE_STATES"] }); * const manager = new CloudstormManager(client, options); * * client.once("ready", async () => { * await manager.init({ clientId: "your-bot-id" }); * }); * ``` */ declare class CloudstormManager extends Manager { readonly client: Client; constructor(client: Client, options?: ManagerOptions); protected send(packet: GatewayVoiceStateUpdate): void; resolveUser(user: AnyUser | string): Promise; resolveGuild(guildId: string): AnyGuild; } /** * Discord.js wrapper for Magmastream. */ declare class DiscordJSManager extends Manager { readonly client: Client$1; constructor(client: Client$1, options?: ManagerOptions); protected send(packet: GatewayVoiceStateUpdate): void; resolveUser(user: AnyUser | string): Promise; resolveGuild(guildId: string): Guild | null; } /** * Discordeno wrapper for Magmastream. */ declare class DiscordenoManager extends Manager { readonly client: Bot; constructor(client: Bot, options?: ManagerOptions); protected send(packet: GatewayVoiceStateUpdate): void; /** * Resolve a user by ID or partial info. * Uses user-provided cache getter if available, otherwise falls back to minimal info. */ resolveUser(user: AnyUser | string): Promise; resolveGuild(guildId: string): AnyGuild; } /** * Eris wrapper for Magmastream. */ declare class ErisManager extends Manager { readonly client: Client$2; constructor(client: Client$2, options?: ManagerOptions); protected send(packet: GatewayVoiceStateUpdate): void; resolveUser(user: AnyUser | string): Promise; resolveGuild(guildId: string): Guild$3; } /** * Oceanic wrapper for Magmastream. */ declare class OceanicManager extends Manager { readonly client: Client$3; constructor(client: Client$3, options?: ManagerOptions); protected send(packet: GatewayVoiceStateUpdate): void; resolveUser(user: AnyUser | string): Promise; resolveGuild(guildId: string): Guild$1; } /** * Seyfert wrapper for Magmastream. * * @note This wrapper does require the manual implementation of the "raw" and "ready" events, to call the `updateVoiceState` and `init` methods respectively. * * @example * ```typescript * const client = new Client(); * const manager = new SeyfertManager(client, options); * * client.events.values.RAW = { * data: { name: "raw" }, * run: async (data) => { * await manager.updateVoiceState(data); * } * } * * client.events.values.READY = { * data: { name: "ready" }, * run: async (user, client) => { * await manager.init({ clientId: client.botId }); * } * } * ``` */ declare class SeyfertManager extends Manager { readonly client: Client$4 | WorkerClient; constructor(client: Client$4 | WorkerClient, options?: ManagerOptions); protected send(packet: GatewayVoiceStateUpdate): void; resolveUser(user: AnyUser | string): Promise; resolveGuild(guildId: string): Guild$4<"cached">; } export { AutoPlayPlatform, AutoPlayUtils, AvailableFilters, CloudstormManager, DiscordJSManager, DiscordenoManager, ErisManager, Filters, JSONUtils, JsonQueue, LoadTypes, MagmaStreamError, MagmaStreamErrorCode, MagmaStreamErrorNumbers, Manager, ManagerEventTypes, MemoryQueue, Node, OceanicManager, Player, PlayerStateEventTypes, PlayerUtils, Plugin, RedisQueue, Rest, SearchPlatform, SeverityTypes, SeyfertManager, SponsorBlockSegment, StateStorageType, StateTypes, Structure, TrackEndReasonTypes, TrackPartial, TrackSourceTypes, TrackUtils, UseNodeOptions }; export type { AlbumSearchResult, AnyGuild, AnyMessage, AnyUser, ArtistSearchResult, CPUStats, DiscordPacket, DiscordVoiceState, DistortionOptions, EndSpeakingEventVoiceReceiver, EndSpeakingEventVoiceReceiverData, EqualizerBand, ErrorOrEmptySearchResult, Exception, Extendable, FrameStats, IQueue, JsonConfig, KaraokeOptions, LastFmResponse, LavaPlayer, LavalinkInfo, LavalinkResponse, LavalinkSession, LavalinkVoiceStateResponse, LavalinkVoiceStateUpdate, LoadType, Lyrics, LyricsEvent, LyricsEventType, LyricsFoundEvent, LyricsLine, LyricsLineEvent, LyricsNotFoundEvent, ManagerEvents, ManagerInitOptions, ManagerOptions, MemoryStats, NodeLinkGetLyrics, NodeLinkGetLyricsEmpty, NodeLinkGetLyricsError, NodeLinkGetLyricsMultiple, NodeLinkGetLyricsSingle, NodeMessage, NodeOptions, NodeStats, PlayOptions, PlayerEvent, PlayerEventType, PlayerEvents, PlayerOptions, PlayerStateUpdateEvent, PlayerUpdateVoiceState, PlayerVoiceState, PlaylistData, PlaylistInfoData, PlaylistRawData, PlaylistSearchResult, PodcastSearchResult, PortableMessage, PortableUser, RedisConfig, RestPlayOptions, ReverbOptions, RotationOptions, SearchQuery, SearchResult, SearchSearchResult, SerializedPlayerState, Severity, ShortSearchResult, ShowSearchResult, Sizes, SponsorBlockChapterStarted, SponsorBlockChaptersLoaded, SponsorBlockSegmentEventType, SponsorBlockSegmentEvents, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, StandaloneManagerOptions, StartSpeakingEventVoiceReceiver, StartSpeakingEventVoiceReceiverData, StateStorageOptions, StationSearchResult, TimescaleOptions, Track, TrackData, TrackDataInfo, TrackEndEvent, TrackEndReason, TrackExceptionEvent, TrackPluginInfo, TrackSearchResult, TrackSourceName, TrackStartEvent, TrackStuckEvent, UseNodeOption, VibratoOptions, VoicePacket, VoiceReceiverEvent, VoiceServer, VoiceServerUpdate, VoiceState, WebSocketClosedEvent };