damonjs
Version:
A modified Shoukaku wrapper with enhanced queue support.
250 lines (249 loc) • 9.18 kB
TypeScript
import { DamonJs } from '../DamonJs';
import { DamonJsQueue } from './Supports/DamonJsQueue';
import { Player, Node, FilterOptions, Connection, Shoukaku, Band, KaraokeSettings, TimescaleSettings, FreqSettings, RotationSettings, DistortionSettings, ChannelMixSettings, LowPassSettings } from 'shoukaku';
import { DamonJsPlayerOptions, PlayerState, PlayOptions, DamonJsSearchOptions, DamonJsSearchResult, DamonJsEvents, LoopState } from '../Modules/Interfaces';
import { DamonJsTrack } from './Supports/DamonJsTrack';
import { Snowflake } from 'discord.js';
import EventEmitter from 'events';
export declare class DamonJsPlayer {
private options;
textId: Snowflake;
private lockMap;
private readonly damonjs;
player: Player;
shoukaku: Shoukaku;
connection: Connection;
readonly queue: DamonJsQueue;
state: PlayerState;
loop: LoopState;
readonly data: Map<string, any>;
search: (query: string, options: DamonJsSearchOptions) => Promise<DamonJsSearchResult>;
readonly stats: {
skipAttemptData: {
skipAttempts: number[];
destroyTriggers: number[];
lastSkipTime: number;
};
};
events: EventEmitter;
constructor(damonjs: DamonJs, shoukaku: Shoukaku, player: Player, connection: Connection, options: DamonJsPlayerOptions);
private executePlaybackOperation;
private processPlaybackQueue;
init(): Promise<void>;
private playbackQueue;
private initEventListeners;
private handleTrackEnd;
private handleTrackException;
private handleTrackStuck;
private handleResolveError;
private handleTrackStart;
private handlePlayerEmpty;
private handleTrackSkip;
private handleTrackPlay;
private handlePlayerDestroy;
private handleTrackResumed;
private handleTrackClosed;
private handleTrackUpdate;
/**
* Get GuildId
*/
get guildId(): string;
/**
* Get VoiceId
*/
get voiceId(): string | null;
/**
* Get Deaf Status
*/
get deaf(): boolean;
/**
* Get Playing Status
*/
get playing(): boolean;
/**
* Get Paused Status
*/
get paused(): boolean;
/**
* Get Mute Status
*/
get mute(): boolean;
/**
* Get volume
*/
get volume(): number;
/**
* Get Filter volume
*/
get filterVolume(): number | undefined;
/**
* Get player position
*/
get position(): number;
/**
* Get filters
*/
get filters(): FilterOptions;
get node(): Node;
/**
* Pause the player
* @param pause Whether to pause or not
* @returns Promise<DamonJsPlayer>
*/
pause(pause: boolean): Promise<DamonJsPlayer>;
/**
* Set loop mode
* @param [loop] Loop mode
* @returns DamonJsPlayer
*/
setLoop(loop?: LoopState): DamonJsPlayer;
/**
* Play a track
* @param {DamonJsTrack} tracks Track to play
* @param {PlayOptions} options Play options
* @returns {Promise<DamonJsPlayer>}
*/
play(tracks?: DamonJsTrack[], options?: PlayOptions): Promise<DamonJsPlayer>;
/**
* Skips to the next track in the queue.
* @returns {Promise<DamonJsPlayer>}
*/
skip(): Promise<DamonJsPlayer>;
/**
* Stops the currently playing track.
* @returns {Promise<DamonJsPlayer>}
*/
stopTrack(): Promise<DamonJsPlayer>;
/**
* Skips to the previous track in the queue.
* @returns {Promise<DamonJsPlayer>}
*/
previous(): Promise<DamonJsPlayer>;
/**
* Skips to the specified track in the queue.
* If the player is in a destroyed state, it will throw an error.
* If the player is currently looping the track or queue, it will continue to do so.
* If the provided track ID exists in the queue, it will skip to that track.
* If the provided track ID is greater than the queue length, it will skip to the last track.
* If the provided track ID is out of bounds, it will skip to the previous track.
*
* @param trackId - The ID of the track to skip to.
* @returns A Promise that resolves to the DamonJsPlayer instance.
* @throws {DamonJsError} If the player is already destroyed.
*/
skipto(trackId: number): Promise<DamonJsPlayer>;
/**
* seek to a specifc position
* @param position Position
* @returns Promise<DamonJsPlayer>
*/
seek(position: number): Promise<DamonJsPlayer>;
/**
* Set the Global volume
* @param volume Volume
* @returns Promise<DamonJsPlayer>
*/
setGlobalVolume(volume: number): Promise<DamonJsPlayer>;
/**
* Set the Filter volume
* @param volume Volume
* @returns Promise<DamonJsPlayer>
*/
setFilterVolume(volume: number): Promise<DamonJsPlayer>;
/**
* Set voice channel and move the player to the voice channel
* @param voiceId Voice channel ID
* @returns DamonJsPlayer
*/
setVoiceChannel(voiceId: Snowflake): DamonJsPlayer;
/**
* Set text channel
* @param textId Text channel ID
* @returns DamonJsPlayer
*/
setTextChannel(textId: Snowflake): DamonJsPlayer;
/**
* Set the Mute State
* @param mute Mute State
* @returns DamonJsPlayer
*/
setMute(mute?: boolean): DamonJsPlayer;
/**
* Set the Deaf State
* @param deaf Deaf State
* @returns DamonJsPlayer
*/
setDeaf(deaf?: boolean): DamonJsPlayer;
/**
* Change the equalizer settings applied to the currently playing track
* @param equalizer An array of objects that conforms to the Bands type that define volumes at different frequencies
* @returns Promise<DamonJsPlayer>
*/
setEqualizer(equalizer: Band[]): Promise<DamonJsPlayer>;
/**
* Change the karaoke settings applied to the currently playing track
* @param karaoke An object that conforms to the KaraokeSettings type that defines a range of frequencies to mute
* @returns Promise<DamonJsPlayer>
*/
setKaraoke(karaoke?: KaraokeSettings): Promise<DamonJsPlayer>;
/**
* Change the timescale settings applied to the currently playing track
* @param timescale An object that conforms to the TimescaleSettings type that defines the time signature to play the audio at
* @returns Promise<DamonJsPlayer>
*/
setTimescale(timescale?: TimescaleSettings): Promise<DamonJsPlayer>;
/**
* Change the tremolo settings applied to the currently playing track
* @param tremolo An object that conforms to the FreqSettings type that defines an oscillation in volume
* @returns Promise<DamonJsPlayer>
*/
setTremolo(tremolo?: FreqSettings): Promise<DamonJsPlayer>;
/**
* Change the vibrato settings applied to the currently playing track
* @param vibrato An object that conforms to the FreqSettings type that defines an oscillation in pitch
* @returns Promise<DamonJsPlayer>
*/
setVibrato(vibrato?: FreqSettings): Promise<DamonJsPlayer>;
/**
* Change the rotation settings applied to the currently playing track
* @param rotation An object that conforms to the RotationSettings type that defines the frequency of audio rotating round the listener
* @returns Promise<DamonJsPlayer>
*/
setRotation(rotation?: RotationSettings): Promise<DamonJsPlayer>;
/**
* Change the distortion settings applied to the currently playing track
* @param distortion An object that conforms to DistortionSettings that defines distortions in the audio
* @returns Promise<DamonJsPlayer>
*/
setDistortion(distortion: DistortionSettings): Promise<DamonJsPlayer>;
/**
* Change the channel mix settings applied to the currently playing track
* @param channelMix An object that conforms to ChannelMixSettings that defines how much the left and right channels affect each other (setting all factors to 0.5 causes both channels to get the same audio)
* @returns Promise<DamonJsPlayer>
*/
setChannelMix(channelMix: ChannelMixSettings): Promise<DamonJsPlayer>;
/**
* Change the low pass settings applied to the currently playing track
* @param lowPass An object that conforms to LowPassSettings that defines the amount of suppression on higher frequencies
* @returns Promise<DamonJsPlayer>
*/
setLowPass(lowPass: LowPassSettings): Promise<DamonJsPlayer>;
/**
* Change the all filter settings applied to the currently playing track
* @param filters An object that conforms to FilterOptions that defines all filters to apply/modify
* @returns Promise<DamonJsPlayer>
*/
setFilters(filters: FilterOptions): Promise<DamonJsPlayer>;
/**
* Move player to another node
* @param name? Name of node to move to, or the default ideal node
* @returns true if the player was moved, false if not
*/
move(name?: string): Promise<DamonJsPlayer>;
/**
* Destroy the player
* @returns Promise<DamonJsPlayer>
*/
destroy(): Promise<DamonJsPlayer>;
emit<K extends keyof DamonJsEvents>(event: K, ...args: DamonJsEvents[K]): void;
}