spotify
This commit is contained in:
parent
3582f1c2ad
commit
49087bcec1
4 changed files with 20 additions and 6 deletions
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
* text=auto eol=lf
|
|
@ -187,7 +187,10 @@ export class Player extends EventEmitter {
|
|||
if (matchSpotifyURL) {
|
||||
const spotifyData = await spotify.getPreview(query).catch(() => {});
|
||||
if (spotifyData) {
|
||||
tracks = await Util.ytSearch(`${spotifyData.artist} - ${spotifyData.title}`, {
|
||||
const searchString = this.options.disableArtistSearch
|
||||
? spotifyData.title
|
||||
: `${spotifyData.artist} - ${spotifyData.title}`;
|
||||
tracks = await Util.ytSearch(searchString, {
|
||||
user: message.author,
|
||||
player: this,
|
||||
limit: 1
|
||||
|
@ -208,8 +211,16 @@ export class Player extends EventEmitter {
|
|||
playlist.tracks.items.map(async (item: any) => {
|
||||
const sq =
|
||||
queryType === 'spotify_album'
|
||||
? `${item.artists[0].name} - ${item.name}`
|
||||
: `${item.track.artists[0].name} - ${item.name}`;
|
||||
? `${
|
||||
this.options.disableArtistSearch
|
||||
? item.artists[0].name
|
||||
: `${item.artists[0].name} - `
|
||||
}${item.name}`
|
||||
: `${
|
||||
this.options.disableArtistSearch
|
||||
? item.track.artists[0].name
|
||||
: `${item.track.artists[0].name} - `
|
||||
}${item.name}`;
|
||||
|
||||
const data = await Util.ytSearch(sq, {
|
||||
limit: 1,
|
||||
|
@ -1422,6 +1433,7 @@ export default Player;
|
|||
* @property {YTDLDownloadOptions} [ytdlDownloadOptions={}] The download options passed to `ytdl-core`
|
||||
* @property {Boolean} [useSafeSearch=false] If it should use `safe search` method for youtube searches
|
||||
* @property {Boolean} [disableAutoRegister=false] If it should disable auto-registeration of `@discord-player/extractor`
|
||||
* @property {Boolean} [disableArtistSearch=false] If it should disable artist search for spotify
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,7 @@ export interface PlayerOptions {
|
|||
ytdlDownloadOptions?: downloadOptions;
|
||||
useSafeSearch?: boolean;
|
||||
disableAutoRegister?: boolean;
|
||||
disableArtistSearch?: boolean;
|
||||
}
|
||||
|
||||
export type FiltersName = keyof QueueFilters;
|
||||
|
|
|
@ -4,7 +4,7 @@ import YouTube from 'youtube-sr';
|
|||
import { Track } from '../Structures/Track';
|
||||
// @ts-ignore
|
||||
import { validateURL as SoundcloudValidateURL } from 'soundcloud-scraper';
|
||||
import { VoiceChannel } from 'discord.js';
|
||||
import { StageChannel, VoiceChannel } from 'discord.js';
|
||||
|
||||
const spotifySongRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/;
|
||||
const spotifyPlaylistRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:playlist\/|\?uri=spotify:playlist:)((\w|-){22})/;
|
||||
|
@ -190,10 +190,10 @@ export class Util {
|
|||
|
||||
/**
|
||||
* Checks if the given voice channel is empty
|
||||
* @param {DiscordVoiceChannel} channel The voice channel
|
||||
* @param {DiscordVoiceChannel|DiscordStageChannel} channel The voice channel
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
static isVoiceEmpty(channel: VoiceChannel): boolean {
|
||||
static isVoiceEmpty(channel: VoiceChannel | StageChannel): boolean {
|
||||
return channel.members.filter((member) => !member.user.bot).size === 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue