discord-player 7.0.0-dev.1 → 7.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -23
- package/dist/index.d.ts +6 -103
- package/dist/index.js +56 -281
- package/dist/index.mjs +0 -8
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -86,28 +86,6 @@ $ npm install --save ffmpeg-binaries
|
|
|
86
86
|
|
|
87
87
|
> Use `FFMPEG_PATH` environment variable to load ffmpeg from custom path.
|
|
88
88
|
|
|
89
|
-
#### Streaming Library
|
|
90
|
-
|
|
91
|
-
**The following method is deprecated and will be removed in the future. Please switch to [discord-player-youtubei](https://npmjs.com/discord-player-youtubei).**
|
|
92
|
-
|
|
93
|
-
**Not recommended**:
|
|
94
|
-
|
|
95
|
-
YouTube streaming is not supported without installing one of the following package. If you want to add support for YouTube playback, you need to install a streaming library. This step is not needed if you do not plan on using youtube source.
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
$ npm install --save youtube-ext
|
|
99
|
-
# or
|
|
100
|
-
$ npm install --save play-dl
|
|
101
|
-
# or
|
|
102
|
-
$ npm install --save @distube/ytdl-core
|
|
103
|
-
# or
|
|
104
|
-
$ npm install --save yt-stream
|
|
105
|
-
# or
|
|
106
|
-
$ npm install --save ytdl-core
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Once you have completed these installations, let's proceed with writing a simple music bot.
|
|
110
|
-
|
|
111
89
|
### Setup
|
|
112
90
|
|
|
113
91
|
Let's create a main player instance. This instance handles and keeps track of all the queues and its components.
|
|
@@ -147,13 +125,31 @@ const { Player, createErisCompat } = require('discord-player');
|
|
|
147
125
|
const player = new Player(createErisCompat(client));
|
|
148
126
|
```
|
|
149
127
|
|
|
128
|
+
Before you add the command, make sure to provide the context to the commands if you wish to use discord-player's hooks (like `useMainPlayer`).
|
|
129
|
+
|
|
130
|
+
### Before
|
|
131
|
+
|
|
132
|
+
```js index.js
|
|
133
|
+
// execute the command
|
|
134
|
+
await command.execute(interaction);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### After
|
|
138
|
+
|
|
139
|
+
```js index.js
|
|
140
|
+
// execute the command
|
|
141
|
+
await player.context.provide({ guild: interaction.guild }, () => command.execute(interaction));
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This allows discord-player to automatically know the current guild and the queue, resulting in cleaner code and seamless integration. This eradicates the need to pass the player instance to the command or use hacks like `client.player = player`.
|
|
145
|
+
|
|
150
146
|
Let's move on to the command part. You can define the command as per your requirements. We will only focus on the command part:
|
|
151
147
|
|
|
152
148
|
```js play.js
|
|
153
149
|
const { useMainPlayer } = require('discord-player');
|
|
154
150
|
|
|
155
151
|
export async function execute(interaction) {
|
|
156
|
-
const player = useMainPlayer();
|
|
152
|
+
const player = useMainPlayer(); // get player instance
|
|
157
153
|
const channel = interaction.member.voice.channel;
|
|
158
154
|
if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel
|
|
159
155
|
const query = interaction.options.getString('query', true); // we need input/query to play
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ import { BridgeProvider } from '@discord-player/extractor';
|
|
|
12
12
|
import { RequestOptions } from 'http';
|
|
13
13
|
import { StreamType, AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, AudioPlayerStatus } from 'discord-voip';
|
|
14
14
|
export { AudioPlayer, CreateAudioPlayerOptions, JoinConfig, JoinVoiceChannelOptions, createAudioPlayer, getVoiceConnection, getVoiceConnections, joinVoiceChannel } from 'discord-voip';
|
|
15
|
-
import { downloadOptions } from 'ytdl-core';
|
|
16
15
|
import { FFmpegLib } from '@discord-player/ffmpeg';
|
|
17
16
|
export * from '@discord-player/ffmpeg';
|
|
18
17
|
|
|
@@ -1808,27 +1807,19 @@ declare function useContext<T = unsafe>(context: Context<T>): T | undefined;
|
|
|
1808
1807
|
* @param node guild queue node resolvable
|
|
1809
1808
|
*/
|
|
1810
1809
|
declare function useHistory<Meta = unknown>(): GuildQueueHistory<Meta> | null;
|
|
1811
|
-
declare function useHistory<Meta = unknown>(node: NodeResolvable): GuildQueueHistory<Meta> | null;
|
|
1812
1810
|
|
|
1813
1811
|
/**
|
|
1814
1812
|
* Fetch guild queue player node
|
|
1815
1813
|
* @param node Guild queue node resolvable
|
|
1816
1814
|
*/
|
|
1817
1815
|
declare function usePlayer<Meta = unknown>(): GuildQueuePlayerNode<Meta> | null;
|
|
1818
|
-
declare function usePlayer<Meta = unknown>(node: NodeResolvable): GuildQueuePlayerNode<Meta> | null;
|
|
1819
1816
|
|
|
1820
1817
|
/**
|
|
1821
1818
|
* Fetch guild queue
|
|
1822
1819
|
* @param node Guild queue node resolvable
|
|
1823
1820
|
*/
|
|
1824
1821
|
declare function useQueue<Meta = unknown>(): GuildQueue<Meta> | null;
|
|
1825
|
-
declare function useQueue<Meta = unknown>(node: NodeResolvable): GuildQueue<Meta> | null;
|
|
1826
1822
|
|
|
1827
|
-
/**
|
|
1828
|
-
* Fetch main player instance
|
|
1829
|
-
* @deprecated
|
|
1830
|
-
*/
|
|
1831
|
-
declare function useMasterPlayer(): Player;
|
|
1832
1823
|
/**
|
|
1833
1824
|
* Fetch main player instance
|
|
1834
1825
|
*/
|
|
@@ -1841,7 +1832,6 @@ type MetadataDispatch<T> = readonly [() => T, (metadata: T | SetterFN$1<T, T>) =
|
|
|
1841
1832
|
* @param node Guild queue node resolvable
|
|
1842
1833
|
*/
|
|
1843
1834
|
declare function useMetadata<T = unknown>(): MetadataDispatch<T>;
|
|
1844
|
-
declare function useMetadata<T = unknown>(node: NodeResolvable): MetadataDispatch<T>;
|
|
1845
1835
|
|
|
1846
1836
|
interface TimelineDispatcherOptions {
|
|
1847
1837
|
ignoreFilters: boolean;
|
|
@@ -1851,7 +1841,7 @@ interface TimelineDispatcherOptions {
|
|
|
1851
1841
|
* @param node Guild queue node resolvable
|
|
1852
1842
|
* @param options Options for timeline dispatcher
|
|
1853
1843
|
*/
|
|
1854
|
-
declare function useTimeline(
|
|
1844
|
+
declare function useTimeline(options?: Partial<TimelineDispatcherOptions>): {
|
|
1855
1845
|
readonly timestamp: PlayerTimestamp;
|
|
1856
1846
|
readonly volume: number;
|
|
1857
1847
|
readonly paused: boolean;
|
|
@@ -1881,24 +1871,8 @@ type VolumeDispatch = readonly [() => number, (volume: number | SetterFN) => boo
|
|
|
1881
1871
|
* @param node Guild queue node resolvable
|
|
1882
1872
|
*/
|
|
1883
1873
|
declare function useVolume(): VolumeDispatch;
|
|
1884
|
-
declare function useVolume(node: NodeResolvable): VolumeDispatch;
|
|
1885
|
-
|
|
1886
|
-
declare const instances: Collection<string, Player>;
|
|
1887
|
-
|
|
1888
|
-
declare const getPlayer: () => Player | null;
|
|
1889
|
-
interface HooksCtx {
|
|
1890
|
-
guild: Guild;
|
|
1891
|
-
}
|
|
1892
|
-
declare const getQueue: <T = unknown>(node: NodeResolvable) => GuildQueue<T> | null;
|
|
1893
|
-
interface HookDeclarationContext {
|
|
1894
|
-
getQueue: typeof getQueue;
|
|
1895
|
-
getPlayer: typeof getPlayer;
|
|
1896
|
-
instances: typeof instances;
|
|
1897
|
-
}
|
|
1898
|
-
type HookDeclaration<T extends (...args: any[]) => any> = (context: HookDeclarationContext) => T;
|
|
1899
|
-
declare function createHook<T extends HookDeclaration<(...args: any[]) => any>>(hook: T): ReturnType<T>;
|
|
1900
1874
|
|
|
1901
|
-
declare const knownExtractorKeys: readonly ["SpotifyExtractor", "AppleMusicExtractor", "SoundCloudExtractor", "
|
|
1875
|
+
declare const knownExtractorKeys: readonly ["SpotifyExtractor", "AppleMusicExtractor", "SoundCloudExtractor", "VimeoExtractor", "ReverbnationExtractor", "AttachmentExtractor"];
|
|
1902
1876
|
type ExtractorLoaderOptionDict = {
|
|
1903
1877
|
[K in (typeof knownExtractorKeys)[number]]?: ConstructorParameters<typeof _discord_player_extractor[K]>[1];
|
|
1904
1878
|
};
|
|
@@ -2128,10 +2102,6 @@ declare class BaseExtractor<T extends object = object> {
|
|
|
2128
2102
|
* @param message The debug message
|
|
2129
2103
|
*/
|
|
2130
2104
|
debug(message: string): boolean;
|
|
2131
|
-
/**
|
|
2132
|
-
* IP rotator instance, if available
|
|
2133
|
-
*/
|
|
2134
|
-
get routePlanner(): IPRotator | null;
|
|
2135
2105
|
/**
|
|
2136
2106
|
* A flag to indicate `Demuxable` stream support for `opus`/`ogg/opus`/`webm/opus` formats.
|
|
2137
2107
|
*/
|
|
@@ -2310,42 +2280,8 @@ declare class VoiceUtils {
|
|
|
2310
2280
|
getConnection(guild: Snowflake, group?: string): VoiceConnection | undefined;
|
|
2311
2281
|
}
|
|
2312
2282
|
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
usage: number;
|
|
2316
|
-
readonly cidr: string;
|
|
2317
|
-
readonly cidrSize: number;
|
|
2318
|
-
constructor(block: string);
|
|
2319
|
-
consume(): void;
|
|
2320
|
-
}
|
|
2321
|
-
interface IPRotationConfig {
|
|
2322
|
-
/**
|
|
2323
|
-
* IP blocks to use
|
|
2324
|
-
*/
|
|
2325
|
-
blocks: string[];
|
|
2326
|
-
/**
|
|
2327
|
-
* IPs to exclude
|
|
2328
|
-
*/
|
|
2329
|
-
exclude?: string[];
|
|
2330
|
-
/**
|
|
2331
|
-
* Max retries to find an IP that is not excluded
|
|
2332
|
-
*/
|
|
2333
|
-
maxRetries?: number;
|
|
2334
|
-
}
|
|
2335
|
-
declare class IPRotator {
|
|
2336
|
-
#private;
|
|
2337
|
-
config: IPRotationConfig;
|
|
2338
|
-
blocks: IPBlock[];
|
|
2339
|
-
failures: Map<string, number>;
|
|
2340
|
-
MAX_NEXT_RETRIES: number;
|
|
2341
|
-
constructor(config: IPRotationConfig);
|
|
2342
|
-
getIP(): {
|
|
2343
|
-
ip: string;
|
|
2344
|
-
family: 4 | 6;
|
|
2345
|
-
};
|
|
2346
|
-
isFailedOrExcluded(ip: string): boolean;
|
|
2347
|
-
addFailed(ip: string): void;
|
|
2348
|
-
static getRandomIP(address: string, start?: number, end?: number): string;
|
|
2283
|
+
interface HooksCtx {
|
|
2284
|
+
guild: Guild;
|
|
2349
2285
|
}
|
|
2350
2286
|
|
|
2351
2287
|
interface PlayerNodeInitializationResult<T = unknown> {
|
|
@@ -2369,7 +2305,6 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
2369
2305
|
* The version of discord-player
|
|
2370
2306
|
*/
|
|
2371
2307
|
static readonly version: string;
|
|
2372
|
-
static _singletonKey: symbol;
|
|
2373
2308
|
/**
|
|
2374
2309
|
* The unique identifier of this player instance
|
|
2375
2310
|
*/
|
|
@@ -2398,10 +2333,6 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
2398
2333
|
* The player events channel
|
|
2399
2334
|
*/
|
|
2400
2335
|
events: PlayerEventsEmitter<GuildQueueEvents<any>>;
|
|
2401
|
-
/**
|
|
2402
|
-
* The route planner
|
|
2403
|
-
*/
|
|
2404
|
-
routePlanner: IPRotator | null;
|
|
2405
2336
|
/**
|
|
2406
2337
|
* The player version
|
|
2407
2338
|
*/
|
|
@@ -2426,26 +2357,12 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
2426
2357
|
*/
|
|
2427
2358
|
onVoiceStateUpdate(handler: VoiceStateHandler): void;
|
|
2428
2359
|
debug(m: string): boolean;
|
|
2429
|
-
/**
|
|
2430
|
-
* Creates discord-player singleton instance.
|
|
2431
|
-
* @param client The client that instantiated player
|
|
2432
|
-
* @param options Player initializer options
|
|
2433
|
-
*/
|
|
2434
|
-
static singleton(client: Client, options?: Omit<PlayerInitOptions, 'ignoreInstance'>): Player;
|
|
2435
2360
|
/**
|
|
2436
2361
|
* Creates new discord-player instance.
|
|
2437
2362
|
* @param client The client that instantiated player
|
|
2438
2363
|
* @param options Player initializer options
|
|
2439
2364
|
*/
|
|
2440
|
-
static create(client: Client, options?:
|
|
2441
|
-
/**
|
|
2442
|
-
* Get all active master player instances
|
|
2443
|
-
*/
|
|
2444
|
-
static getAllPlayers(): Player[];
|
|
2445
|
-
/**
|
|
2446
|
-
* Clear all master player instances
|
|
2447
|
-
*/
|
|
2448
|
-
static clearAllPlayers(): void;
|
|
2365
|
+
static create(client: Client, options?: PlayerInitOptions): Player;
|
|
2449
2366
|
/**
|
|
2450
2367
|
* The current query cache provider in use
|
|
2451
2368
|
*/
|
|
@@ -2469,7 +2386,6 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
2469
2386
|
*
|
|
2470
2387
|
* // outputs something like
|
|
2471
2388
|
* // {
|
|
2472
|
-
* // instances: number,
|
|
2473
2389
|
* // queuesCount: number,
|
|
2474
2390
|
* // queryCacheEnabled: boolean,
|
|
2475
2391
|
* // queues: [
|
|
@@ -2482,7 +2398,6 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
2482
2398
|
* ```
|
|
2483
2399
|
*/
|
|
2484
2400
|
generateStatistics(): {
|
|
2485
|
-
instances: number;
|
|
2486
2401
|
queuesCount: number;
|
|
2487
2402
|
queryCacheEnabled: boolean;
|
|
2488
2403
|
queues: GuildQueueStatisticsMetadata[];
|
|
@@ -3094,10 +3009,6 @@ interface PlaylistJSON {
|
|
|
3094
3009
|
tracks: TrackJSON[];
|
|
3095
3010
|
}
|
|
3096
3011
|
interface PlayerInitOptions {
|
|
3097
|
-
/**
|
|
3098
|
-
* The options passed to `ytdl-core`.
|
|
3099
|
-
*/
|
|
3100
|
-
ytdlOptions?: downloadOptions;
|
|
3101
3012
|
/**
|
|
3102
3013
|
* The voice connection timeout
|
|
3103
3014
|
*/
|
|
@@ -3122,10 +3033,6 @@ interface PlayerInitOptions {
|
|
|
3122
3033
|
* Query cache provider
|
|
3123
3034
|
*/
|
|
3124
3035
|
queryCache?: QueryCacheProvider<any> | null;
|
|
3125
|
-
/**
|
|
3126
|
-
* Ignore player instance
|
|
3127
|
-
*/
|
|
3128
|
-
ignoreInstance?: boolean;
|
|
3129
3036
|
/**
|
|
3130
3037
|
* Use legacy version of ffmpeg
|
|
3131
3038
|
*/
|
|
@@ -3134,10 +3041,6 @@ interface PlayerInitOptions {
|
|
|
3134
3041
|
* Set bridge provider
|
|
3135
3042
|
*/
|
|
3136
3043
|
bridgeProvider?: BridgeProvider;
|
|
3137
|
-
/**
|
|
3138
|
-
* IP rotator config
|
|
3139
|
-
*/
|
|
3140
|
-
ipconfig?: IPRotationConfig;
|
|
3141
3044
|
/**
|
|
3142
3045
|
* Skip ffmpeg process when possible
|
|
3143
3046
|
*/
|
|
@@ -3391,4 +3294,4 @@ declare const DependencyReportGenerator: {
|
|
|
3391
3294
|
|
|
3392
3295
|
declare const version: string;
|
|
3393
3296
|
|
|
3394
|
-
export { AFilterGraph, AsyncQueue, AsyncQueueAcquisitionOptions, AsyncQueueEntry, AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, Context, ContextReceiver, CreateStreamOps, DependenciesReport, DependencyReportGenerator, DiscordPlayerQueryResultCache, Encodable, EqualizerConfigurationPreset, ExtractorExecutionContext, ExtractorExecutionEvents, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorLoaderOptionDict, ExtractorResolvable, ExtractorSearchContext, ExtractorSession, ExtractorStreamable, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, FFmpegReport, FFmpegStreamOptions, FilterGraph, FiltersName, GuildNodeCreateOptions, GuildNodeInit, GuildNodeManager, GuildQueue, GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvent, GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, GuildQueueStatistics, GuildQueueStatisticsMetadata,
|
|
3297
|
+
export { AFilterGraph, AsyncQueue, AsyncQueueAcquisitionOptions, AsyncQueueEntry, AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, Context, ContextReceiver, CreateStreamOps, DependenciesReport, DependencyReportGenerator, DiscordPlayerQueryResultCache, Encodable, EqualizerConfigurationPreset, ExtractorExecutionContext, ExtractorExecutionEvents, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorLoaderOptionDict, ExtractorResolvable, ExtractorSearchContext, ExtractorSession, ExtractorStreamable, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, FFmpegReport, FFmpegStreamOptions, FilterGraph, FiltersName, GuildNodeCreateOptions, GuildNodeInit, GuildNodeManager, GuildQueue, GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvent, GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, GuildQueueStatistics, GuildQueueStatisticsMetadata, LrcGetParams, LrcGetResult, LrcLib, LrcSearchParams, LrcSearchResult, MaybeNull, MetadataDispatch, NextFunction, NodeResolvable, OnAfterCreateStreamHandler, OnBeforeCreateStreamHandler, PackageJSON, PlayOptions, Player, PlayerEvent, PlayerEvents, PlayerEventsEmitter, PlayerInitOptions, PlayerNodeInitializationResult, PlayerNodeInitializerOptions, PlayerProgressbarOptions, PlayerSearchResult, PlayerTimestamp, PlayerTriggeredReason, Playlist, PlaylistInitData, PlaylistJSON, PostProcessedResult, QueryCache, QueryCacheOptions, QueryCacheProvider, QueryCacheResolverContext, QueryExtractorSearch, QueryResolver, QueryType, QueueFilters, QueueRepeatMode, RawTrackData, RequestEntity, ResolvedQuery, ResourcePlayOptions, Runtime, RuntimeType, SearchOptions, SearchQueryType, SearchResult, SearchResultData, SequentialBucket, SerializedPlaylist, SerializedTrack, SerializedType, SetterFN$1 as SetterFN, SkipOptions, StreamConfig, StreamDispatcher, TimeData, TimelineDispatcherOptions, Track, TrackJSON, TrackLike, TrackResolvable, TrackSkipReason, TrackSource, TypeUtil, Util, VALIDATE_QUEUE_CAP, VoiceConnectConfig, VoiceEvents, VoiceStateHandler, VoiceUtils, WithMetadata, createContext, createErisCompat, createFFmpegStream, decode, deserialize, encode, isErisProxy, onAfterCreateStream, onBeforeCreateStream, serialize, tryIntoThumbnailString, useContext, useHistory, useMainPlayer, useMetadata, usePlayer, useQueue, useTimeline, useVolume, version };
|