Skip to content

Commit 4bdfd5e

Browse files
committed
update nowplaying to check where to grab artist info from
1 parent 0ccff22 commit 4bdfd5e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/bot/commands/nowplaying.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const getNowPlayingTrack = async (): Promise<string | null> => {
3838
)
3939

4040
if (!response.ok) {
41-
log.bot.error(response)
41+
log.bot.error(await response.text())
4242
return null
4343
}
4444

@@ -50,7 +50,12 @@ const getNowPlayingTrack = async (): Promise<string | null> => {
5050
if (data.item && data.item.type === 'track') {
5151
const track = data.item as Track
5252
const title = track.name
53-
const artist = track.album.artists[0].name
53+
let artist: string
54+
if (track.album.artists.length) {
55+
artist = track.album.artists[0].name
56+
} else {
57+
artist = track.artists[0].name
58+
}
5459
return `“${title}” by ${artist}`
5560
}
5661
}

0 commit comments

Comments
 (0)