Skip to content

Commit

Permalink
feat(spotify): toggle queue when offline (#4004)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Jul 27, 2020
1 parent 2f3dbb0 commit c67db2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions locales/en/ui/integrations/spotify.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"title": "Fetch current song when stream is offline",
"help": "It's advised to have this disabled to avoid reach API limits"
},
"queueWhenOffline": {
"title": "Queue songs when stream is offline",
"help": "It's advised to have this disabled to avoid queueing when you are just listening music"
},
"clientId": "clientId",
"clientSecret": "clientSecret",
"redirectURI": "redirectURI",
Expand Down
7 changes: 5 additions & 2 deletions src/bot/integrations/spotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Spotify extends Integration {
songRequests = true;
@settings()
fetchCurrentSongWhenOffline = false;
@settings()
queueWhenOffline = false;

@settings('output')
format = '$song - $artist';
Expand Down Expand Up @@ -369,11 +371,12 @@ class Spotify extends Integration {
@command('!spotify')
@default_permission(null)
async main (opts: CommandOptions): Promise<CommandResponse[]> {
/*if (!(api.isStreamOnline)) {
error(`${chalk.bgRed('SPOTIFY')}: stream is offline.`);
if (!api.isStreamOnline && !this.queueWhenOffline) {
error(`${chalk.bgRed('SPOTIFY')}: stream is offline and you have disabled queue when offline.`);
return [];
} // don't do anything on offline stream*/
if (!this.songRequests) {
error(`${chalk.bgRed('SPOTIFY')}: song requests are disabled.`);
return [];
}
if (!this.client) {
Expand Down
1 change: 1 addition & 0 deletions src/bot/systems/customcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class CustomCommands extends System {
let atLeastOnePermissionOk = false;
for (const cmd of commands) {
if (!cmd.command.enabled) {
atLeastOnePermissionOk = true; // continue if command is disabled
warning(`Custom command ${cmd.command.command} (${cmd.command.id}) is disabled!`);
continue;
}
Expand Down

0 comments on commit c67db2a

Please sign in to comment.