distube 3.0.0-beta.9 → 3.0.3
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/LICENSE +21 -21
- package/README.md +64 -51
- package/dist/DisTube.d.ts +522 -0
- package/dist/DisTube.d.ts.map +1 -0
- package/dist/DisTube.js +794 -0
- package/dist/DisTube.js.map +1 -0
- package/dist/constant.d.ts +130 -0
- package/dist/constant.d.ts.map +1 -0
- package/dist/constant.js +150 -0
- package/dist/constant.js.map +1 -0
- package/dist/core/DisTubeBase.d.ts +55 -0
- package/dist/core/DisTubeBase.d.ts.map +1 -0
- package/dist/core/DisTubeBase.js +76 -0
- package/dist/core/DisTubeBase.js.map +1 -0
- package/dist/core/DisTubeHandler.d.ts +95 -0
- package/dist/core/DisTubeHandler.d.ts.map +1 -0
- package/dist/core/DisTubeHandler.js +337 -0
- package/dist/core/DisTubeHandler.js.map +1 -0
- package/dist/core/DisTubeOptions.d.ts +26 -0
- package/dist/core/DisTubeOptions.d.ts.map +1 -0
- package/dist/core/DisTubeOptions.js +93 -0
- package/dist/core/DisTubeOptions.js.map +1 -0
- package/dist/core/DisTubeStream.d.ts +52 -0
- package/dist/core/DisTubeStream.d.ts.map +1 -0
- package/dist/core/DisTubeStream.js +109 -0
- package/dist/core/DisTubeStream.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +19 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/manager/BaseManager.d.ts +18 -0
- package/dist/core/manager/BaseManager.d.ts.map +1 -0
- package/dist/core/manager/BaseManager.js +44 -0
- package/dist/core/manager/BaseManager.js.map +1 -0
- package/dist/core/manager/QueueManager.d.ts +60 -0
- package/dist/core/manager/QueueManager.d.ts.map +1 -0
- package/dist/core/manager/QueueManager.js +202 -0
- package/dist/core/manager/QueueManager.js.map +1 -0
- package/dist/core/manager/index.d.ts +3 -0
- package/dist/core/manager/index.d.ts.map +1 -0
- package/dist/core/manager/index.js +15 -0
- package/dist/core/manager/index.js.map +1 -0
- package/dist/core/voice/DJSAdapter.d.ts +4 -0
- package/dist/core/voice/DJSAdapter.d.ts.map +1 -0
- package/dist/core/voice/DJSAdapter.js +61 -0
- package/dist/core/voice/DJSAdapter.js.map +1 -0
- package/dist/core/voice/DisTubeVoice.d.ts +85 -0
- package/dist/core/voice/DisTubeVoice.d.ts.map +1 -0
- package/dist/core/voice/DisTubeVoice.js +246 -0
- package/dist/core/voice/DisTubeVoice.js.map +1 -0
- package/dist/core/voice/DisTubeVoiceManager.d.ts +41 -0
- package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -0
- package/dist/core/voice/DisTubeVoiceManager.js +67 -0
- package/dist/core/voice/DisTubeVoiceManager.js.map +1 -0
- package/dist/core/voice/index.d.ts +4 -0
- package/dist/core/voice/index.d.ts.map +1 -0
- package/dist/core/voice/index.js +16 -0
- package/dist/core/voice/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/http.d.ts +8 -0
- package/dist/plugin/http.d.ts.map +1 -0
- package/dist/plugin/http.js +20 -0
- package/dist/plugin/http.js.map +1 -0
- package/dist/plugin/https.d.ts +14 -0
- package/dist/plugin/https.d.ts.map +1 -0
- package/dist/plugin/https.js +50 -0
- package/dist/plugin/https.js.map +1 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +16 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/youtube-dl.d.ts +11 -0
- package/dist/plugin/youtube-dl.d.ts.map +1 -0
- package/dist/plugin/youtube-dl.js +75 -0
- package/dist/plugin/youtube-dl.js.map +1 -0
- package/dist/struct/CustomPlugin.d.ts +27 -0
- package/dist/struct/CustomPlugin.d.ts.map +1 -0
- package/dist/struct/CustomPlugin.js +35 -0
- package/dist/struct/CustomPlugin.js.map +1 -0
- package/dist/struct/DisTubeError.d.ts +56 -0
- package/dist/struct/DisTubeError.d.ts.map +1 -0
- package/dist/struct/DisTubeError.js +75 -0
- package/dist/struct/DisTubeError.js.map +1 -0
- package/dist/struct/ExtractorPlugin.d.ts +29 -0
- package/dist/struct/ExtractorPlugin.d.ts.map +1 -0
- package/dist/struct/ExtractorPlugin.js +32 -0
- package/dist/struct/ExtractorPlugin.js.map +1 -0
- package/dist/struct/Playlist.d.ts +42 -0
- package/dist/struct/Playlist.d.ts.map +1 -0
- package/dist/struct/Playlist.js +104 -0
- package/dist/struct/Playlist.js.map +1 -0
- package/dist/struct/Plugin.d.ts +82 -0
- package/dist/struct/Plugin.d.ts.map +1 -0
- package/dist/struct/Plugin.js +108 -0
- package/dist/struct/Plugin.js.map +1 -0
- package/dist/struct/Queue.d.ts +217 -0
- package/dist/struct/Queue.d.ts.map +1 -0
- package/dist/struct/Queue.js +481 -0
- package/dist/struct/Queue.js.map +1 -0
- package/dist/struct/SearchResult.d.ts +28 -0
- package/dist/struct/SearchResult.d.ts.map +1 -0
- package/dist/struct/SearchResult.js +79 -0
- package/dist/struct/SearchResult.js.map +1 -0
- package/dist/struct/Song.d.ts +68 -0
- package/dist/struct/Song.d.ts.map +1 -0
- package/dist/struct/Song.js +229 -0
- package/dist/struct/Song.js.map +1 -0
- package/dist/struct/TaskQueue.d.ts +33 -0
- package/dist/struct/TaskQueue.d.ts.map +1 -0
- package/dist/struct/TaskQueue.js +58 -0
- package/dist/struct/TaskQueue.js.map +1 -0
- package/dist/struct/index.d.ts +10 -0
- package/dist/struct/index.d.ts.map +1 -0
- package/dist/struct/index.js +22 -0
- package/dist/struct/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/type.d.ts +159 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +3 -0
- package/dist/type.js.map +1 -0
- package/dist/util.d.ts +47 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +205 -0
- package/dist/util.js.map +1 -0
- package/package.json +88 -62
- package/src/DisTube.js +0 -851
- package/src/DisTubeBase.js +0 -39
- package/src/DisTubeHandler.js +0 -440
- package/src/DisTubeOptions.js +0 -82
- package/src/Filter.js +0 -36
- package/src/Playlist.js +0 -75
- package/src/Plugin/CustomPlugin.js +0 -26
- package/src/Plugin/ExtractorPlugin.js +0 -25
- package/src/Plugin/Plugin.js +0 -36
- package/src/Plugin/http.js +0 -27
- package/src/Plugin/https.js +0 -27
- package/src/Queue.js +0 -340
- package/src/SearchResult.js +0 -57
- package/src/Song.js +0 -169
- package/src/util.js +0 -65
- package/typings/DisTube.d.ts +0 -553
- package/typings/DisTubeBase.d.ts +0 -31
- package/typings/DisTubeHandler.d.ts +0 -130
- package/typings/DisTubeOptions.d.ts +0 -5
- package/typings/Filter.d.ts +0 -83
- package/typings/Playlist.d.ts +0 -58
- package/typings/Plugin/CustomPlugin.d.ts +0 -21
- package/typings/Plugin/ExtractorPlugin.d.ts +0 -20
- package/typings/Plugin/Plugin.d.ts +0 -31
- package/typings/Plugin/http.d.ts +0 -4
- package/typings/Plugin/https.d.ts +0 -4
- package/typings/Queue.d.ts +0 -227
- package/typings/SearchResult.d.ts +0 -51
- package/typings/Song.d.ts +0 -153
- package/typings/util.d.ts +0 -6
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type ytdl from "@distube/ytdl-core";
|
|
2
|
+
import type { CustomPlugin, DisTubeVoice, ExtractorPlugin, Playlist, Queue, SearchResult, Song } from ".";
|
|
3
|
+
import type { Guild, GuildMember, Interaction, Message, Snowflake, StageChannel, TextChannel, User, VoiceChannel, VoiceState } from "discord.js";
|
|
4
|
+
declare type Awaitable = Promise<void> | void;
|
|
5
|
+
export declare type DisTubeVoiceEvents = {
|
|
6
|
+
disconnect: (error?: Error) => Awaitable;
|
|
7
|
+
error: (error: Error) => Awaitable;
|
|
8
|
+
finish: () => Awaitable;
|
|
9
|
+
};
|
|
10
|
+
export declare type DisTubeEvents = {
|
|
11
|
+
/** Emitted after DisTube add a new song to the playing {@link Queue}. */
|
|
12
|
+
addSong: (queue: Queue, song: Song) => Awaitable;
|
|
13
|
+
/**
|
|
14
|
+
* Emitted when DisTube play a song.
|
|
15
|
+
*
|
|
16
|
+
* If {@link DisTubeOptions.emitNewSongOnly} is `true`,
|
|
17
|
+
* this event is not emitted when looping a song or next song is the previous one.
|
|
18
|
+
*/
|
|
19
|
+
playSong: (queue: Queue, song: Song) => Awaitable;
|
|
20
|
+
/** Emitted when DisTube finished a song. */
|
|
21
|
+
finishSong: (queue: Queue, song: Song) => Awaitable;
|
|
22
|
+
/**
|
|
23
|
+
* Emitted when there is no user in the voice channel,
|
|
24
|
+
* {@link DisTubeOptions.leaveOnEmpty} is `true` and there is a playing queue.
|
|
25
|
+
*
|
|
26
|
+
* If there is no playing queue (stopped and {@link DisTubeOptions.leaveOnStop} is `false`),
|
|
27
|
+
* it will leave the channel without emitting this event.
|
|
28
|
+
*/
|
|
29
|
+
empty: (queue: Queue) => Awaitable;
|
|
30
|
+
/**
|
|
31
|
+
* Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.
|
|
32
|
+
* DisTube will leave voice channel if {@link DisTubeOptions.leaveOnFinish} is `true`.
|
|
33
|
+
*/
|
|
34
|
+
finish: (queue: Queue) => Awaitable;
|
|
35
|
+
/** Emitted when DisTube initialize a queue to change queue default properties. */
|
|
36
|
+
initQueue: (queue: Queue) => Awaitable;
|
|
37
|
+
/**
|
|
38
|
+
* Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty,
|
|
39
|
+
* and DisTube cannot find related songs to play.
|
|
40
|
+
*/
|
|
41
|
+
noRelated: (queue: Queue) => Awaitable;
|
|
42
|
+
/** Emitted when the bot is disconnected to a voice channel. */
|
|
43
|
+
disconnect: (queue: Queue) => Awaitable;
|
|
44
|
+
/** Emitted when a {@link Queue} is deleted with any reasons. */
|
|
45
|
+
deleteQueue: (queue: Queue) => Awaitable;
|
|
46
|
+
/**
|
|
47
|
+
* Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,
|
|
48
|
+
* and the search canceled due to {@link DisTubeOptions.searchTimeout}.
|
|
49
|
+
*/
|
|
50
|
+
searchCancel: (message: Message, query: string) => Awaitable;
|
|
51
|
+
/** Emitted when DisTube cannot find any results for the query. */
|
|
52
|
+
searchNoResult: (message: Message, query: string) => Awaitable;
|
|
53
|
+
/**
|
|
54
|
+
* Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,
|
|
55
|
+
* and after the user chose a search result to play.
|
|
56
|
+
*/
|
|
57
|
+
searchDone: (message: Message, answer: Message, query: string) => Awaitable;
|
|
58
|
+
/**
|
|
59
|
+
* Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,
|
|
60
|
+
* and the search canceled due to user's next message is not a number or out of results range.
|
|
61
|
+
*/
|
|
62
|
+
searchInvalidAnswer: (message: Message, answer: Message, query: string) => Awaitable;
|
|
63
|
+
/** Emitted when DisTube encounters an error. */
|
|
64
|
+
error: (channel: TextChannel, error: Error) => Awaitable;
|
|
65
|
+
/** Emitted after DisTube add a new playlist to the playing {@link Queue}. */
|
|
66
|
+
addList: (queue: Queue, playlist: Playlist) => Awaitable;
|
|
67
|
+
/**
|
|
68
|
+
* Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,
|
|
69
|
+
* and song param of {@link DisTube#playVoiceChannel} is invalid url.
|
|
70
|
+
* DisTube will wait for user's next message to choose a song manually.
|
|
71
|
+
*
|
|
72
|
+
* Safe search is enabled
|
|
73
|
+
* if {@link DisTubeOptions.nsfw} is disabled and the message's channel is not a nsfw channel.
|
|
74
|
+
*/
|
|
75
|
+
searchResult: (message: Message, results: SearchResult[], query: string) => Awaitable;
|
|
76
|
+
};
|
|
77
|
+
export declare type Filters = Record<string, string>;
|
|
78
|
+
export interface DisTubeOptions {
|
|
79
|
+
plugins?: (CustomPlugin | ExtractorPlugin)[];
|
|
80
|
+
emitNewSongOnly?: boolean;
|
|
81
|
+
leaveOnFinish?: boolean;
|
|
82
|
+
leaveOnStop?: boolean;
|
|
83
|
+
leaveOnEmpty?: boolean;
|
|
84
|
+
emptyCooldown?: number;
|
|
85
|
+
savePreviousSongs?: boolean;
|
|
86
|
+
searchSongs?: number;
|
|
87
|
+
searchCooldown?: number;
|
|
88
|
+
youtubeCookie?: string;
|
|
89
|
+
youtubeIdentityToken?: string;
|
|
90
|
+
youtubeDL?: boolean;
|
|
91
|
+
updateYouTubeDL?: boolean;
|
|
92
|
+
customFilters?: Filters;
|
|
93
|
+
ytdlOptions?: ytdl.downloadOptions;
|
|
94
|
+
nsfw?: boolean;
|
|
95
|
+
emitAddSongWhenCreatingQueue?: boolean;
|
|
96
|
+
emitAddListWhenCreatingQueue?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export declare type GuildIDResolvable = Queue | DisTubeVoice | Snowflake | Message | VoiceChannel | StageChannel | VoiceState | Guild | TextChannel | GuildMember | Interaction | string;
|
|
99
|
+
export interface OtherSongInfo {
|
|
100
|
+
src?: string;
|
|
101
|
+
id?: string;
|
|
102
|
+
title?: string;
|
|
103
|
+
name?: string;
|
|
104
|
+
is_live?: boolean;
|
|
105
|
+
isLive?: boolean;
|
|
106
|
+
_duration_raw?: string | number;
|
|
107
|
+
duration?: string | number;
|
|
108
|
+
webpage_url?: string;
|
|
109
|
+
url: string;
|
|
110
|
+
thumbnail?: string;
|
|
111
|
+
related?: Song[];
|
|
112
|
+
view_count?: string | number;
|
|
113
|
+
views?: string | number;
|
|
114
|
+
like_count?: string | number;
|
|
115
|
+
likes?: string | number;
|
|
116
|
+
dislike_count?: string | number;
|
|
117
|
+
dislikes?: string | number;
|
|
118
|
+
repost_count?: string | number;
|
|
119
|
+
reposts?: string | number;
|
|
120
|
+
uploader?: string;
|
|
121
|
+
uploader_url?: string;
|
|
122
|
+
age_limit?: string | number;
|
|
123
|
+
chapters?: Chapter[];
|
|
124
|
+
age_restricted?: boolean;
|
|
125
|
+
}
|
|
126
|
+
export interface Chapter {
|
|
127
|
+
/** Chapter title */
|
|
128
|
+
title: string;
|
|
129
|
+
/** Chapter start time in seconds */
|
|
130
|
+
start_time: number;
|
|
131
|
+
}
|
|
132
|
+
export interface PlaylistInfo {
|
|
133
|
+
/** The source of the playlist */
|
|
134
|
+
source: string;
|
|
135
|
+
/**
|
|
136
|
+
* User requested.
|
|
137
|
+
*/
|
|
138
|
+
member?: GuildMember;
|
|
139
|
+
/**
|
|
140
|
+
* User requested.
|
|
141
|
+
*/
|
|
142
|
+
user?: User;
|
|
143
|
+
/** Playlist songs. */
|
|
144
|
+
songs: Song[];
|
|
145
|
+
/**
|
|
146
|
+
* Playlist name.
|
|
147
|
+
*/
|
|
148
|
+
name?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Playlist URL.
|
|
151
|
+
*/
|
|
152
|
+
url?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Playlist thumbnail.
|
|
155
|
+
*/
|
|
156
|
+
thumbnail?: string;
|
|
157
|
+
}
|
|
158
|
+
export {};
|
|
159
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AAC1G,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,WAAW,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,aAAK,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEtC,oBAAY,kBAAkB,GAAG;IAC/B,UAAU,EAAE,CAAC,KAAK,CAAC,E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AO,EAAE,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,OAAO;IACtB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,sBAAsB;IACtB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/type.js
ADDED
package/dist/type.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"","sourcesContent":["import type ytdl from \"@distube/ytdl-core\";\nimport type { CustomPlugin, DisTubeVoice, ExtractorPlugin, Playlist, Queue, SearchResult, Song } from \".\";\nimport type {\n Guild,\n GuildMember,\n Interaction,\n Message,\n Snowflake,\n StageChannel,\n TextChannel,\n User,\n VoiceChannel,\n VoiceState,\n} from \"discord.js\";\n\ntype Awaitable = Promise<void> | void;\n\nexport type DisTubeVoiceEvents = {\n disconnect: (error?: Error) => Awaitable;\n error: (error: Error) => Awaitable;\n finish: () => Awaitable;\n};\n\nexport type DisTubeEvents = {\n /** Emitted after DisTube add a new song to the playing {@link Queue}. */\n addSong: (queue: Queue, song: Song) => Awaitable;\n /**\n * Emitted when DisTube play a song.\n *\n * If {@link DisTubeOptions.emitNewSongOnly} is `true`,\n * this event is not emitted when looping a song or next song is the previous one.\n */\n playSong: (queue: Queue, song: Song) => Awaitable;\n /** Emitted when DisTube finished a song. */\n finishSong: (queue: Queue, song: Song) => Awaitable;\n\n /**\n * Emitted when there is no user in the voice channel,\n * {@link DisTubeOptions.leaveOnEmpty} is `true` and there is a playing queue.\n *\n * If there is no playing queue (stopped and {@link DisTubeOptions.leaveOnStop} is `false`),\n * it will leave the channel without emitting this event.\n */\n empty: (queue: Queue) => Awaitable;\n /**\n * Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.\n * DisTube will leave voice channel if {@link DisTubeOptions.leaveOnFinish} is `true`.\n */\n finish: (queue: Queue) => Awaitable;\n /** Emitted when DisTube initialize a queue to change queue default properties. */\n initQueue: (queue: Queue) => Awaitable;\n /**\n * Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty,\n * and DisTube cannot find related songs to play.\n */\n noRelated: (queue: Queue) => Awaitable;\n /** Emitted when the bot is disconnected to a voice channel. */\n disconnect: (queue: Queue) => Awaitable;\n /** Emitted when a {@link Queue} is deleted with any reasons. */\n deleteQueue: (queue: Queue) => Awaitable;\n\n /**\n * Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,\n * and the search canceled due to {@link DisTubeOptions.searchTimeout}.\n */\n searchCancel: (message: Message, query: string) => Awaitable;\n /** Emitted when DisTube cannot find any results for the query. */\n searchNoResult: (message: Message, query: string) => Awaitable;\n\n /**\n * Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,\n * and after the user chose a search result to play.\n */\n searchDone: (message: Message, answer: Message, query: string) => Awaitable;\n /**\n * Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,\n * and the search canceled due to user's next message is not a number or out of results range.\n */\n searchInvalidAnswer: (message: Message, answer: Message, query: string) => Awaitable;\n\n /** Emitted when DisTube encounters an error. */\n error: (channel: TextChannel, error: Error) => Awaitable;\n /** Emitted after DisTube add a new playlist to the playing {@link Queue}. */\n addList: (queue: Queue, playlist: Playlist) => Awaitable;\n /**\n * Emitted when {@link DisTubeOptions.searchSongs} bigger than 0,\n * and song param of {@link DisTube#playVoiceChannel} is invalid url.\n * DisTube will wait for user's next message to choose a song manually.\n *\n * Safe search is enabled\n * if {@link DisTubeOptions.nsfw} is disabled and the message's channel is not a nsfw channel.\n */\n searchResult: (message: Message, results: SearchResult[], query: string) => Awaitable;\n};\n\nexport type Filters = Record<string, string>;\n\nexport interface DisTubeOptions {\n plugins?: (CustomPlugin | ExtractorPlugin)[];\n emitNewSongOnly?: boolean;\n leaveOnFinish?: boolean;\n leaveOnStop?: boolean;\n leaveOnEmpty?: boolean;\n emptyCooldown?: number;\n savePreviousSongs?: boolean;\n searchSongs?: number;\n searchCooldown?: number;\n youtubeCookie?: string;\n youtubeIdentityToken?: string;\n youtubeDL?: boolean;\n updateYouTubeDL?: boolean;\n customFilters?: Filters;\n ytdlOptions?: ytdl.downloadOptions;\n nsfw?: boolean;\n emitAddSongWhenCreatingQueue?: boolean;\n emitAddListWhenCreatingQueue?: boolean;\n}\n\nexport type GuildIDResolvable =\n | Queue\n | DisTubeVoice\n | Snowflake\n | Message\n | VoiceChannel\n | StageChannel\n | VoiceState\n | Guild\n | TextChannel\n | GuildMember\n | Interaction\n | string;\n\nexport interface OtherSongInfo {\n src?: string;\n id?: string;\n title?: string;\n name?: string;\n is_live?: boolean;\n isLive?: boolean;\n _duration_raw?: string | number;\n duration?: string | number;\n webpage_url?: string;\n url: string;\n thumbnail?: string;\n related?: Song[];\n view_count?: string | number;\n views?: string | number;\n like_count?: string | number;\n likes?: string | number;\n dislike_count?: string | number;\n dislikes?: string | number;\n repost_count?: string | number;\n reposts?: string | number;\n uploader?: string;\n uploader_url?: string;\n age_limit?: string | number;\n chapters?: Chapter[];\n age_restricted?: boolean;\n}\n\nexport interface Chapter {\n /** Chapter title */\n title: string;\n /** Chapter start time in seconds */\n start_time: number;\n}\n\nexport interface PlaylistInfo {\n /** The source of the playlist */\n source: string;\n /**\n * User requested.\n */\n member?: GuildMember;\n /**\n * User requested.\n */\n user?: User;\n /** Playlist songs. */\n songs: Song[];\n /**\n * Playlist name.\n */\n name?: string;\n /**\n * Playlist URL.\n */\n url?: string;\n /**\n * Playlist thumbnail.\n */\n thumbnail?: string;\n}\n"]}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { GuildIDResolvable } from ".";
|
|
2
|
+
import type { Client, ClientOptions, Guild, GuildMember, Message, Snowflake, StageChannel, TextChannel, VoiceChannel, VoiceState } from "discord.js";
|
|
3
|
+
/**
|
|
4
|
+
* Format duration to string
|
|
5
|
+
* @param {number} sec Duration in seconds
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatDuration(sec: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Convert formatted duration to seconds
|
|
11
|
+
* @param {*} input Formatted duration string
|
|
12
|
+
* @returns {number}
|
|
13
|
+
*/
|
|
14
|
+
export declare function toSecond(input: any): number;
|
|
15
|
+
/**
|
|
16
|
+
* Parse number from input
|
|
17
|
+
* @param {*} input Any
|
|
18
|
+
* @returns {number}
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseNumber(input: any): number;
|
|
21
|
+
/**
|
|
22
|
+
* Check if the string is an URL
|
|
23
|
+
* @param {string} input input
|
|
24
|
+
* @returns {boolean}
|
|
25
|
+
*/
|
|
26
|
+
export declare function isURL(input: any): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if the Client has enough intents to using DisTube
|
|
29
|
+
* @param {ClientOptions} options options
|
|
30
|
+
*/
|
|
31
|
+
export declare function checkIntents(options: ClientOptions): void;
|
|
32
|
+
/**
|
|
33
|
+
* Check if the voice channel is empty
|
|
34
|
+
* @param {Discord.VoiceState} voiceState voiceState
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
export declare function isVoiceChannelEmpty(voiceState: VoiceState): boolean;
|
|
38
|
+
export declare function isSnowflake(id: any): id is Snowflake;
|
|
39
|
+
export declare function isMemberInstance(member: any): member is GuildMember;
|
|
40
|
+
export declare function isTextChannelInstance(channel: any): channel is TextChannel;
|
|
41
|
+
export declare function isMessageInstance(message: any): message is Message;
|
|
42
|
+
export declare function isSupportedVoiceChannel(channel: any): channel is VoiceChannel | StageChannel;
|
|
43
|
+
export declare function isGuildInstance(guild: any): guild is Guild;
|
|
44
|
+
export declare function resolveGuildID(resolvable: GuildIDResolvable): Snowflake;
|
|
45
|
+
export declare function isClientInstance(client: any): client is Client;
|
|
46
|
+
export declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
|
|
47
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AAC3C,OAAO,KAAK,EAEV,MAAM,EACN,aAAa,EACb,KAAK,EACL,WAAW,EAEX,OAAO,EACP,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACX,MAAM,YAAY,CAAC;AAIpB;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQlD;AACD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAY3C;AACD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAG9C;AACD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CASzC;AACD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAQzD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAKnE;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,GAAG,GAAG,EAAE,IAAI,SAAS,CAMpD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,WAAW,CAQnE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,WAAW,CAQ1E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,OAAO,CAYlE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,YAAY,GAAG,YAAY,CAgB5F;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,KAAK,CAE1D;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,iBAAiB,GAAG,SAAS,CAWvE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,CAE9D;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,EACtC,UAAU,EAAE,MAAM,QAQnB"}
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkInvalidKey = exports.isClientInstance = exports.resolveGuildID = exports.isGuildInstance = exports.isSupportedVoiceChannel = exports.isMessageInstance = exports.isTextChannelInstance = exports.isMemberInstance = exports.isSnowflake = exports.isVoiceChannelEmpty = exports.checkIntents = exports.isURL = exports.parseNumber = exports.toSecond = exports.formatDuration = void 0;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const discord_js_1 = require("discord.js");
|
|
7
|
+
const formatInt = (int) => (int < 10 ? `0${int}` : int);
|
|
8
|
+
/**
|
|
9
|
+
* Format duration to string
|
|
10
|
+
* @param {number} sec Duration in seconds
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
function formatDuration(sec) {
|
|
14
|
+
if (!sec || !Number(sec))
|
|
15
|
+
return "00:00";
|
|
16
|
+
const seconds = Math.round(sec % 60);
|
|
17
|
+
const minutes = Math.floor((sec % 3600) / 60);
|
|
18
|
+
const hours = Math.floor(sec / 3600);
|
|
19
|
+
if (hours > 0)
|
|
20
|
+
return `${formatInt(hours)}:${formatInt(minutes)}:${formatInt(seconds)}`;
|
|
21
|
+
if (minutes > 0)
|
|
22
|
+
return `${formatInt(minutes)}:${formatInt(seconds)}`;
|
|
23
|
+
return `00:${formatInt(seconds)}`;
|
|
24
|
+
}
|
|
25
|
+
exports.formatDuration = formatDuration;
|
|
26
|
+
/**
|
|
27
|
+
* Convert formatted duration to seconds
|
|
28
|
+
* @param {*} input Formatted duration string
|
|
29
|
+
* @returns {number}
|
|
30
|
+
*/
|
|
31
|
+
function toSecond(input) {
|
|
32
|
+
if (!input)
|
|
33
|
+
return 0;
|
|
34
|
+
if (typeof input !== "string")
|
|
35
|
+
return Number(input) || 0;
|
|
36
|
+
if (input.match(/:/g)) {
|
|
37
|
+
const time = input.split(":").reverse();
|
|
38
|
+
let s = 0;
|
|
39
|
+
for (let i = 0; i < 3; i++)
|
|
40
|
+
if (time[i])
|
|
41
|
+
s += Number(time[i].replace(/[^\d.]+/g, "")) * Math.pow(60, i);
|
|
42
|
+
if (time.length > 3)
|
|
43
|
+
s += Number(time[3].replace(/[^\d.]+/g, "")) * 24 * 60 * 60;
|
|
44
|
+
return s;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return Number(input.replace(/[^\d.]+/g, "")) || 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.toSecond = toSecond;
|
|
51
|
+
/**
|
|
52
|
+
* Parse number from input
|
|
53
|
+
* @param {*} input Any
|
|
54
|
+
* @returns {number}
|
|
55
|
+
*/
|
|
56
|
+
function parseNumber(input) {
|
|
57
|
+
if (typeof input === "string")
|
|
58
|
+
return Number(input.replace(/[^\d.]+/g, "")) || 0;
|
|
59
|
+
return Number(input) || 0;
|
|
60
|
+
}
|
|
61
|
+
exports.parseNumber = parseNumber;
|
|
62
|
+
/**
|
|
63
|
+
* Check if the string is an URL
|
|
64
|
+
* @param {string} input input
|
|
65
|
+
* @returns {boolean}
|
|
66
|
+
*/
|
|
67
|
+
function isURL(input) {
|
|
68
|
+
if (typeof input !== "string" || input.includes(" "))
|
|
69
|
+
return false;
|
|
70
|
+
try {
|
|
71
|
+
const url = new url_1.URL(input);
|
|
72
|
+
if (!["https:", "http:"].includes(url.protocol) || !url.host)
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
exports.isURL = isURL;
|
|
81
|
+
/**
|
|
82
|
+
* Check if the Client has enough intents to using DisTube
|
|
83
|
+
* @param {ClientOptions} options options
|
|
84
|
+
*/
|
|
85
|
+
function checkIntents(options) {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
const requiredIntents = ["GUILD_VOICE_STATES"];
|
|
88
|
+
const bitfield = (_a = options.intents) !== null && _a !== void 0 ? _a : (_b = options === null || options === void 0 ? void 0 : options.ws) === null || _b === void 0 ? void 0 : _b.intents;
|
|
89
|
+
if (typeof bitfield === "undefined")
|
|
90
|
+
return;
|
|
91
|
+
const intents = new discord_js_1.Intents(bitfield);
|
|
92
|
+
for (const intent of requiredIntents) {
|
|
93
|
+
if (!intents.has(intent))
|
|
94
|
+
throw new _1.DisTubeError("MISSING_INTENTS", intent.toString());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.checkIntents = checkIntents;
|
|
98
|
+
/**
|
|
99
|
+
* Check if the voice channel is empty
|
|
100
|
+
* @param {Discord.VoiceState} voiceState voiceState
|
|
101
|
+
* @returns {boolean}
|
|
102
|
+
*/
|
|
103
|
+
function isVoiceChannelEmpty(voiceState) {
|
|
104
|
+
var _a, _b, _c;
|
|
105
|
+
const voiceChannel = (_c = (_b = (_a = voiceState.guild) === null || _a === void 0 ? void 0 : _a.me) === null || _b === void 0 ? void 0 : _b.voice) === null || _c === void 0 ? void 0 : _c.channel;
|
|
106
|
+
if (!voiceChannel)
|
|
107
|
+
return false;
|
|
108
|
+
const members = voiceChannel.members.filter(m => !m.user.bot);
|
|
109
|
+
return !members.size;
|
|
110
|
+
}
|
|
111
|
+
exports.isVoiceChannelEmpty = isVoiceChannelEmpty;
|
|
112
|
+
function isSnowflake(id) {
|
|
113
|
+
try {
|
|
114
|
+
return discord_js_1.SnowflakeUtil.deconstruct(id).timestamp > discord_js_1.SnowflakeUtil.EPOCH;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.isSnowflake = isSnowflake;
|
|
121
|
+
function isMemberInstance(member) {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
return (!!member &&
|
|
124
|
+
isSnowflake(member.id) &&
|
|
125
|
+
isSnowflake((_a = member.guild) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
126
|
+
isSnowflake((_b = member.user) === null || _b === void 0 ? void 0 : _b.id) &&
|
|
127
|
+
member.id === member.user.id);
|
|
128
|
+
}
|
|
129
|
+
exports.isMemberInstance = isMemberInstance;
|
|
130
|
+
function isTextChannelInstance(channel) {
|
|
131
|
+
var _a;
|
|
132
|
+
return (!!channel &&
|
|
133
|
+
isSnowflake(channel.id) &&
|
|
134
|
+
isSnowflake((_a = channel.guild) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
135
|
+
typeof channel.send === "function" &&
|
|
136
|
+
typeof channel.awaitMessages === "function");
|
|
137
|
+
}
|
|
138
|
+
exports.isTextChannelInstance = isTextChannelInstance;
|
|
139
|
+
function isMessageInstance(message) {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
// Simple check for using distube normally
|
|
142
|
+
return (!!message &&
|
|
143
|
+
isSnowflake(message.id) &&
|
|
144
|
+
isSnowflake((_a = message.guild) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
145
|
+
isTextChannelInstance(message.channel) &&
|
|
146
|
+
isMemberInstance(message.member) &&
|
|
147
|
+
isSnowflake((_b = message.author) === null || _b === void 0 ? void 0 : _b.id) &&
|
|
148
|
+
message.member.id === message.author.id &&
|
|
149
|
+
message.guild.id === message.channel.guild.id);
|
|
150
|
+
}
|
|
151
|
+
exports.isMessageInstance = isMessageInstance;
|
|
152
|
+
function isSupportedVoiceChannel(channel) {
|
|
153
|
+
var _a;
|
|
154
|
+
return (!!channel &&
|
|
155
|
+
channel.deleted === false &&
|
|
156
|
+
isSnowflake(channel.id) &&
|
|
157
|
+
isSnowflake((_a = channel.guild) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
158
|
+
typeof channel.full === "boolean" &&
|
|
159
|
+
[
|
|
160
|
+
// Djs v12
|
|
161
|
+
"voice",
|
|
162
|
+
"stage",
|
|
163
|
+
// Djs v13
|
|
164
|
+
"GUILD_VOICE",
|
|
165
|
+
"GUILD_STAGE_VOICE",
|
|
166
|
+
].includes(channel.type));
|
|
167
|
+
}
|
|
168
|
+
exports.isSupportedVoiceChannel = isSupportedVoiceChannel;
|
|
169
|
+
function isGuildInstance(guild) {
|
|
170
|
+
return !!guild && isSnowflake(guild.id) && typeof guild.fetchAuditLogs === "function";
|
|
171
|
+
}
|
|
172
|
+
exports.isGuildInstance = isGuildInstance;
|
|
173
|
+
function resolveGuildID(resolvable) {
|
|
174
|
+
let guildID;
|
|
175
|
+
if (typeof resolvable === "string") {
|
|
176
|
+
guildID = resolvable;
|
|
177
|
+
}
|
|
178
|
+
else if (typeof resolvable === "object") {
|
|
179
|
+
if (resolvable instanceof _1.Queue || resolvable instanceof _1.DisTubeVoice)
|
|
180
|
+
guildID = resolvable.id;
|
|
181
|
+
else if ("guild" in resolvable && isGuildInstance(resolvable.guild))
|
|
182
|
+
guildID = resolvable.guild.id;
|
|
183
|
+
else if ("id" in resolvable && isGuildInstance(resolvable))
|
|
184
|
+
guildID = resolvable.id;
|
|
185
|
+
}
|
|
186
|
+
if (!isSnowflake(guildID))
|
|
187
|
+
throw new _1.DisTubeError("INVALID_TYPE", "GuildIDResolvable", resolvable);
|
|
188
|
+
return guildID;
|
|
189
|
+
}
|
|
190
|
+
exports.resolveGuildID = resolveGuildID;
|
|
191
|
+
function isClientInstance(client) {
|
|
192
|
+
return !!client && typeof client.login === "function";
|
|
193
|
+
}
|
|
194
|
+
exports.isClientInstance = isClientInstance;
|
|
195
|
+
function checkInvalidKey(target, source, sourceName) {
|
|
196
|
+
if (typeof target !== "object" || Array.isArray(target)) {
|
|
197
|
+
throw new _1.DisTubeError("INVALID_TYPE", "object", target, sourceName);
|
|
198
|
+
}
|
|
199
|
+
const sourceKeys = Array.isArray(source) ? source : Object.keys(source);
|
|
200
|
+
const invalidKey = Object.keys(target).find(key => !sourceKeys.includes(key));
|
|
201
|
+
if (invalidKey)
|
|
202
|
+
throw new _1.DisTubeError("INVALID_KEY", sourceName, invalidKey);
|
|
203
|
+
}
|
|
204
|
+
exports.checkInvalidKey = checkInvalidKey;
|
|
205
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAC1B,wBAAsD;AACtD,2CAAoD;AAiBpD,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEhE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,GAAW;IACxC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAA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M,EAAE,UAAU,CAAC,CAAC;KACtE;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9E,IAAI,UAAU;QAAE,MAAM,IAAI,eAAY,CAAC,aAAa,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAChF,CAAC;AAXD,0CAWC","sourcesContent":["import { URL } from \"url\";\nimport { DisTubeError, DisTubeVoice, Queue } from \".\";\nimport { Intents, SnowflakeUtil } from \"discord.js\";\nimport type { GuildIDResolvable } from \".\";\nimport type {\n BitFieldResolvable,\n Client,\n ClientOptions,\n Guild,\n GuildMember,\n IntentsString,\n Message,\n Snowflake,\n StageChannel,\n TextChannel,\n VoiceChannel,\n VoiceState,\n} from \"discord.js\";\n\nconst formatInt = (int: number) => (int < 10 ? `0${int}` : int);\n\n/**\n * Format duration to string\n * @param {number} sec Duration in seconds\n * @returns {string}\n */\nexport function formatDuration(sec: number): string {\n if (!sec || !Number(sec)) return \"00:00\";\n const seconds = Math.round(sec % 60);\n const minutes = Math.floor((sec % 3600) / 60);\n const hours = Math.floor(sec / 3600);\n if (hours > 0) return `${formatInt(hours)}:${formatInt(minutes)}:${formatInt(seconds)}`;\n if (minutes > 0) return `${formatInt(minutes)}:${formatInt(seconds)}`;\n return `00:${formatInt(seconds)}`;\n}\n/**\n * Convert formatted duration to seconds\n * @param {*} input Formatted duration string\n * @returns {number}\n */\nexport function toSecond(input: any): number {\n if (!input) return 0;\n if (typeof input !== \"string\") return Number(input) || 0;\n if (input.match(/:/g)) {\n const time = input.split(\":\").reverse();\n let s = 0;\n for (let i = 0; i < 3; i++) if (time[i]) s += Number(time[i].replace(/[^\\d.]+/g, \"\")) * Math.pow(60, i);\n if (time.length > 3) s += Number(time[3].replace(/[^\\d.]+/g, \"\")) * 24 * 60 * 60;\n return s;\n } else {\n return Number(input.replace(/[^\\d.]+/g, \"\")) || 0;\n }\n}\n/**\n * Parse number from input\n * @param {*} input Any\n * @returns {number}\n */\nexport function parseNumber(input: any): number {\n if (typeof input === \"string\") return Number(input.replace(/[^\\d.]+/g, \"\")) || 0;\n return Number(input) || 0;\n}\n/**\n * Check if the string is an URL\n * @param {string} input input\n * @returns {boolean}\n */\nexport function isURL(input: any): boolean {\n if (typeof input !== \"string\" || input.includes(\" \")) return false;\n try {\n const url = new URL(input);\n if (![\"https:\", \"http:\"].includes(url.protocol) || !url.host) return false;\n } catch {\n return false;\n }\n return true;\n}\n/**\n * Check if the Client has enough intents to using DisTube\n * @param {ClientOptions} options options\n */\nexport function checkIntents(options: ClientOptions): void {\n const requiredIntents: BitFieldResolvable<IntentsString, number>[] = [\"GUILD_VOICE_STATES\"];\n const bitfield: BitFieldResolvable<IntentsString, number> = options.intents ?? (options?.ws as any)?.intents;\n if (typeof bitfield === \"undefined\") return;\n const intents = new Intents(bitfield);\n for (const intent of requiredIntents) {\n if (!intents.has(intent)) throw new DisTubeError(\"MISSING_INTENTS\", intent.toString());\n }\n}\n\n/**\n * Check if the voice channel is empty\n * @param {Discord.VoiceState} voiceState voiceState\n * @returns {boolean}\n */\nexport function isVoiceChannelEmpty(voiceState: VoiceState): boolean {\n const voiceChannel = voiceState.guild?.me?.voice?.channel;\n if (!voiceChannel) return false;\n const members = voiceChannel.members.filter(m => !m.user.bot);\n return !members.size;\n}\n\nexport function isSnowflake(id: any): id is Snowflake {\n try {\n return SnowflakeUtil.deconstruct(id).timestamp > SnowflakeUtil.EPOCH;\n } catch {\n return false;\n }\n}\n\nexport function isMemberInstance(member: any): member is GuildMember {\n return (\n !!member &&\n isSnowflake(member.id) &&\n isSnowflake(member.guild?.id) &&\n isSnowflake(member.user?.id) &&\n member.id === member.user.id\n );\n}\n\nexport function isTextChannelInstance(channel: any): channel is TextChannel {\n return (\n !!channel &&\n isSnowflake(channel.id) &&\n isSnowflake(channel.guild?.id) &&\n typeof channel.send === \"function\" &&\n typeof channel.awaitMessages === \"function\"\n );\n}\n\nexport function isMessageInstance(message: any): message is Message {\n // Simple check for using distube normally\n return (\n !!message &&\n isSnowflake(message.id) &&\n isSnowflake(message.guild?.id) &&\n isTextChannelInstance(message.channel) &&\n isMemberInstance(message.member) &&\n isSnowflake(message.author?.id) &&\n message.member.id === message.author.id &&\n message.guild.id === message.channel.guild.id\n );\n}\n\nexport function isSupportedVoiceChannel(channel: any): channel is VoiceChannel | StageChannel {\n return (\n !!channel &&\n channel.deleted === false &&\n isSnowflake(channel.id) &&\n isSnowflake(channel.guild?.id) &&\n typeof channel.full === \"boolean\" &&\n [\n // Djs v12\n \"voice\",\n \"stage\",\n // Djs v13\n \"GUILD_VOICE\",\n \"GUILD_STAGE_VOICE\",\n ].includes(channel.type)\n );\n}\n\nexport function isGuildInstance(guild: any): guild is Guild {\n return !!guild && isSnowflake(guild.id) && typeof guild.fetchAuditLogs === \"function\";\n}\n\nexport function resolveGuildID(resolvable: GuildIDResolvable): Snowflake {\n let guildID: string | undefined;\n if (typeof resolvable === \"string\") {\n guildID = resolvable;\n } else if (typeof resolvable === \"object\") {\n if (resolvable instanceof Queue || resolvable instanceof DisTubeVoice) guildID = resolvable.id;\n else if (\"guild\" in resolvable && isGuildInstance(resolvable.guild)) guildID = resolvable.guild.id;\n else if (\"id\" in resolvable && isGuildInstance(resolvable)) guildID = resolvable.id;\n }\n if (!isSnowflake(guildID)) throw new DisTubeError(\"INVALID_TYPE\", \"GuildIDResolvable\", resolvable);\n return guildID;\n}\n\nexport function isClientInstance(client: any): client is Client {\n return !!client && typeof client.login === \"function\";\n}\n\nexport function checkInvalidKey(\n target: Record<string, any>,\n source: Record<string, any> | string[],\n sourceName: string,\n) {\n if (typeof target !== \"object\" || Array.isArray(target)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", target, sourceName);\n }\n const sourceKeys = Array.isArray(source) ? source : Object.keys(source);\n const invalidKey = Object.keys(target).find(key => !sourceKeys.includes(key));\n if (invalidKey) throw new DisTubeError(\"INVALID_KEY\", sourceName, invalidKey);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,62 +1,88 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "distube",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "A Discord.js
|
|
5
|
-
"main": "
|
|
6
|
-
"typings": "
|
|
7
|
-
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"lint
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"music
|
|
28
|
-
"discord
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
},
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
},
|
|
55
|
-
"
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "distube",
|
|
3
|
+
"version": "3.0.3",
|
|
4
|
+
"description": "A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key. Support YouTube, SoundCloud, Bandcamp, Facebook, and 700+ more sites",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest --config .jestrc.json",
|
|
9
|
+
"docs": "docgen -s src/*.ts src/**/*.ts -o docs/docs.json -c pages/index.yml -g -j .jsconfig.json",
|
|
10
|
+
"lint": "eslint .",
|
|
11
|
+
"lint:fix": "eslint . --fix",
|
|
12
|
+
"prettier": "prettier --write **/*.{js,ts,json,yml,yaml}",
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"build:check": "tsc --noEmit --incremental false",
|
|
15
|
+
"publish:dev": "npm publish --tag dev",
|
|
16
|
+
"ncu": "ncu -u --dep dev,prod",
|
|
17
|
+
"_postinstall": "husky install",
|
|
18
|
+
"prepublishOnly": "pinst -d",
|
|
19
|
+
"postpublish": "pinst -e"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/skick1234/DisTube.git"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"youtube",
|
|
27
|
+
"music",
|
|
28
|
+
"discord",
|
|
29
|
+
"discordjs",
|
|
30
|
+
"bot",
|
|
31
|
+
"distube",
|
|
32
|
+
"queue",
|
|
33
|
+
"musicbot",
|
|
34
|
+
"discord-music-bot",
|
|
35
|
+
"music-bot",
|
|
36
|
+
"discord-js"
|
|
37
|
+
],
|
|
38
|
+
"author": "Skick (https://github.com/skick1234/)",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/skick1234/DisTube/issues"
|
|
42
|
+
},
|
|
43
|
+
"funding": {
|
|
44
|
+
"url": "https://patreon.com/DisTube"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://distube.js.org/",
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@distube/youtube-dl": "^2.2.4",
|
|
49
|
+
"@distube/ytdl-core": "^4.9.3",
|
|
50
|
+
"@distube/ytpl": "^1.1.1",
|
|
51
|
+
"@distube/ytsr": "^1.1.5",
|
|
52
|
+
"prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main",
|
|
53
|
+
"tiny-typed-emitter": "^2.1.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@babel/core": "^7.16.0",
|
|
57
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
58
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
59
|
+
"@babel/preset-env": "^7.16.0",
|
|
60
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
61
|
+
"@commitlint/cli": "^14.1.0",
|
|
62
|
+
"@commitlint/config-conventional": "^14.1.0",
|
|
63
|
+
"@discordjs/voice": "^0.7.2",
|
|
64
|
+
"@distube/docgen": "github:distubejs/docgen",
|
|
65
|
+
"@types/jest": "^27.0.2",
|
|
66
|
+
"@types/node": "^16.11.7",
|
|
67
|
+
"babel-jest": "^27.3.1",
|
|
68
|
+
"discord.js": "^13.3.1",
|
|
69
|
+
"eslint": "^7.32.0",
|
|
70
|
+
"eslint-config-distube": "^1.4.0",
|
|
71
|
+
"husky": "^7.0.4",
|
|
72
|
+
"jest": "^27.3.1",
|
|
73
|
+
"jsdoc-babel": "^0.5.0",
|
|
74
|
+
"lint-staged": "^11.2.6",
|
|
75
|
+
"npm-check-updates": "^12.0.2",
|
|
76
|
+
"pinst": "^2.1.6",
|
|
77
|
+
"prettier": "^2.4.1",
|
|
78
|
+
"typescript": "^4.4.4"
|
|
79
|
+
},
|
|
80
|
+
"peerDependencies": {
|
|
81
|
+
"@discordjs/opus": "*",
|
|
82
|
+
"@discordjs/voice": ">=0.5.6",
|
|
83
|
+
"discord.js": "^12.5.0||13.x"
|
|
84
|
+
},
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">=12.0.0"
|
|
87
|
+
}
|
|
88
|
+
}
|