Made setToken async
This commit is contained in:
parent
ddcb71c018
commit
d68fb60756
@ -237,10 +237,10 @@ export async function refreshToken(): Promise<boolean> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setSpotifyToken(options: SpotifyDataOptions) {
|
export async function setSpotifyToken(options: SpotifyDataOptions) {
|
||||||
spotifyData = options;
|
spotifyData = options;
|
||||||
spotifyData.file = false;
|
spotifyData.file = false;
|
||||||
refreshToken();
|
await refreshToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SpotifyTrack, SpotifyAlbum, SpotifyPlaylist };
|
export { SpotifyTrack, SpotifyAlbum, SpotifyPlaylist };
|
||||||
|
|||||||
@ -39,14 +39,23 @@ interface tokenOptions {
|
|||||||
* }
|
* }
|
||||||
* }) // YouTube Cookies
|
* }) // YouTube Cookies
|
||||||
*
|
*
|
||||||
|
* await play.setToken({
|
||||||
|
* spotify : {
|
||||||
|
* client_id: 'ID',
|
||||||
|
client_secret: 'secret',
|
||||||
|
refresh_token: 'token',
|
||||||
|
market: 'US'
|
||||||
|
* }
|
||||||
|
* }) // Await this only when setting data for spotify
|
||||||
|
*
|
||||||
* play.setToken({
|
* play.setToken({
|
||||||
* useragent: ['Your User-agent']
|
* useragent: ['Your User-agent']
|
||||||
* }) // Use this to avoid 429 errors.
|
* }) // Use this to avoid 429 errors.
|
||||||
* ```
|
* ```
|
||||||
* @param options {@link tokenOptions}
|
* @param options {@link tokenOptions}
|
||||||
*/
|
*/
|
||||||
export function setToken(options: tokenOptions) {
|
export async function setToken(options: tokenOptions) {
|
||||||
if (options.spotify) setSpotifyToken(options.spotify);
|
if (options.spotify) await setSpotifyToken(options.spotify);
|
||||||
if (options.soundcloud) setSoundCloudToken(options.soundcloud);
|
if (options.soundcloud) setSoundCloudToken(options.soundcloud);
|
||||||
if (options.youtube) setCookieToken(options.youtube);
|
if (options.youtube) setCookieToken(options.youtube);
|
||||||
if (options.useragent) setUserAgent(options.useragent);
|
if (options.useragent) setUserAgent(options.useragent);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user