Closed PatricNox closed 2 years ago
Ever figured out that problem? Getting similar results.
ubuntu@ubuntu:~/twitch-spotify-request-bot$ yarn start yarn run v1.22.17 $ node dist/index.js internal/modules/cjs/loader.js:905 throw err; ^
Error: Cannot find module '@/spotify' Require stack:
- /home/ubuntu/twitch-spotify-request-bot/dist/index.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.Module._load (internal/modules/cjs/loader.js:746:27) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:101:18) at Object.
(/home/ubuntu/twitch-spotify-request-bot/dist/index.js:32:19) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/home/ubuntu/twitch-spotify-request-bot/dist/index.js' ] } error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@codexual unfortunately not, I had to change all @
to ..
(etc depending on file location) to hackfix it for now
Hey, sorry it took so long to get to this. Looks like TypeScript paths are a bit finicky so I'm just going to remove them, let me know if this commit works for you https://github.com/MarcDonald/twitch-spotify-request-bot/commit/cc5d518e38882486124a5f0808b7ee511b2fb068
So the bot is running sort of. The files hasn't been updated after running
git clone https://github.com/MarcDonald/twitch-spotify-request-bot.git
So I modded the files that you modded via https://github.com/MarcDonald/twitch-spotify-request-bot/commit/cc5d518e38882486124a5f0808b7ee511b2fb068 then it was able to run next command
yarn
then
yarn build && yarn start
Then I am presented with
Authorizing with Spotify No credentials found, performing new authorization Click or go to the following link and give this app permissions
https://accounts.spotify.com/authorize?client_id=SECRECT SPOTIFY CODE GOES HERE - OBV I EDITED IT OUT&response_type=code&redirect_uri=http://localhost:8000/spotifyAuth&scope=user-modify-playback-state%20playlist-read-private%20playlist-modify-public%20playlist-modify-private&state=
Auth server is listening on 8000
Problem is when I paste in the URL into my web browser to AUTH the app (on a separate computer coz I am running this script on my Ras Pi). Its redirected to
Which isn't a problem if I was running a web browser/gui on the raspi but its a ubuntu server. So I replaced "http://localhost" to "http://example.com" into the .env file. And modded my "/etc/hosts" file (and on my windows machine host file) to
Ubuntu
127.0.0.1 example.com
Windows
192.168.x.x example.com
So now I can have a proper loopback setup. So now I can visit the URL and it registered it properly. Think it's worth noting in the Doc's if people are going to self host if their ISP doesn't allow "loopbacks" :P
https://accounts.spotify.com/authorize?client_id=SECRECT SPOTIFY CODE GOES HERE - OBV I EDITED IT OUT&response_type=code&redirect_uri=http://example.com:8000/spotifyAuth&scope=user-modify-playback-state%20playlist-read-private%20playlist-modify-public%20playlist-modify-private&state=
--- So with that bit a troubleshooting out of the way, the bot is now running... But now when running the cmd in Twitch chat
!sr https://open.spotify.com/track/53BZ6XygAoubR5DU5w38Vq?si=d8d50810729e4524
I am presented with in Twitch chat
Codexual: !sr https://open.spotify.com/track/53BZ6XygAoubR5DU5w38Vq?si=d8d50810729e4524 Codesexual: Fail: Real Muthaphuckkin' G's not added to queue Codesexual: Fail: Real Muthaphuckkin' G's not added to playlist
And Console output
Attempting to add 53BZ6XygAoubR5DU5w38Vq Error: Unable to add song to queue - An error occurred while communicating with Spotify's Web API. Details: Player command failed: No active device found NO_ACTIVE_DEVICE. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Okay I am assuming no music is playing since "NO_ACTIVE_DEVICE", so play a random song
Codexual: !sr https://open.spotify.com/track/5ByAIlEEnxYdvpnezg7HTX?si=858e8ed849da4a59 Codesexual: Success: Juicy - 2005 Remaster added to queue Codesexual: Fail: Juicy - 2005 Remaster not added to playlist
Console output
Attempting to add 5ByAIlEEnxYdvpnezg7HTX Added Juicy - 2005 Remaster to queue <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Now it works, but Spofity has to be active (playing some song) to even take commands and be added to the queue. And secondly it displays a secondary message "Codesexual: Fail: Juicy - 2005 Remaster not added to playlist" saying it failed. So it's confusing if the song has been added or not when it says Success then Fail but obv it added it to the queue.
And a suggestion, it would be easier on the viewer if they can "!sr name here" instead of searching for a link on spotify
Codexual: !sr Justin Bieber Codesexual: Fail (no link): No Spotify link detected
And a !play, !pause, !stop, !remove name of song here. Would be sick to see this bot work with channel points as well! (I could setup another bot to act on my behalf and have it done from the windows side to control spotify directly but yeah). If any of this is possible that is.
On a side note if you don't know, I cannot deploy this on heroku.com, coz when I do it pops up with a Red error message saying it Violates TOS and won't let me go further. Just an FYI.
The "NO_ACTIVE_DEVICE" it's a common issue, the Spotify API can't detect from what device you want to play music (only if you haven't played music from a device since the last 30 minutes), so you need to "create" a device by playing something with any Spotify client from the different platforms. There is a way to create a device using the API (as I understand) but this node app isn't intended to be a music player, so this doesn't apply, making this impossible.
Something is iffy with the alias, @, as it compilles through rsc but still gives these issues if used by
yarn dev
.