VinylBot banner

VinylBot

15 devlogs
18h 59m 40s

The bot has two main functionalities:

  1. Spotify Control via Discord
    Users can control Spotify directly from Discord using simple commands (e.g., play, pause, skip, etc.).
  2. Music Guessing Game
    The bot plays a 15-second snippet of a song. Use…

The bot has two main functionalities:

  1. Spotify Control via Discord
    Users can control Spotify directly from Discord using simple commands (e.g., play, pause, skip, etc.).
  2. Music Guessing Game
    The bot plays a 15-second snippet of a song. Users must guess the correct title in chat. The first to answer correctly earns points.
    The system also includes a server-wide leaderboard, win streak tracking, and unlockable badges.
This project uses AI

Just for debugging, the idea is completely mine and also a great part of the code. I really find helpful using github copilot for fixing minor bugs and getting infos about problems.
I also used AI to complete my README

Demo Repository

Loading README...

F3rro32

I’m sorry guys, I wasn’t able to fulfill my idea. The bot remains just local.
I’m so sorry for this, I wanted to fix this, but it’s impossible. Now I can say it: I lost the battle with yt.

Attachment
0
F3rro32

I’m really sorry, but I think I’ll have to resign. I thought I could win the battle with youtube, using tools like https://github.com/YunzheZJU/youtube-po-token-generator and cookies generator, but that’s impossible. Yotube just won the battle.
I’ll have to give up on the deployment. While writing this, I really meant this words.
But now, now I have an idea. An idea, like the ones who come at night at 2AM.
Stay tuned because I will not surrender.

Attachment
0
F3rro32

I’m completing my project, it will only take a few days and then you will have the product working.
For the deploy I decided to use https://railway.com/ with firestore for data.
I had to migrate the file database.js to firestore.js, to sync data on firestore. I decided that the leaderboard will be global, not server-wide.
I also had to fix some minor bugs, due to the change to firestore.
Stay tuned

Attachment
0
F3rro32

Since the game is now working properly, I’m working on fixing the code and refactoring it.
I’m commeting some parts missing comments and fixing some small bugs.
I’m also improving some things in the code, like for example I added two commands (and two fields to the gameState), called /stats, /streak.
I’m also improving a bit the gameplay. I added some hints, which are given after 15 sec without anyone guessing the song.
I’m happy since everything is working, even if I changed approach so many times and I had to start some things From Zero (like the album by Linking Park).
Stay tuned, ’cause the bot is about to be public.

Attachment
Attachment
0
F3rro32

Here we go. Finally the game is working pretty well.
Now you can start the game, it goes well, it recognizes who wins. I also added some controls to not play the same song twice.
I also started adding some nice things.
I added some nice badges, based on the points a user get.
if (points < 5) return { emoji: '🌑', name: 'Novice', tier: 1 }; if (points < 10) return { emoji: '💿', name: 'Scout', tier: 2 }; if (points < 20) return { emoji: '📀', name: 'Guitarist', tier: 3 }; if (points < 50) return { emoji: '🔥', name: 'Maestro', tier: 4 }; if (points < 100) return { emoji: '💎', name: 'Legend', tier: 5 }; return { emoji: '🏆', name: 'Immortal', tier: 6};
I also added some nice fields for each user. Now you also have a streak, a max Streak and nice things like that.

Attachment
Attachment
0
F3rro32

Guess what, I changed another time approach, but that’s okay, since now the bot is working.
I have had a few problems with docker for allowing the /auth, but I was able to fix it somehow.
As you see in the screenshot, now it starts playing a song, and you can guess it. Of couse if you guess it right, you get point in the database (I still have to fix some things, but the main logic is working).
I also added a “cleaning” to the strings of the names of the songs. As you see in the image, Come Together by Beatles, comes with a long title, also containing “- Remastered 2009”. I clean every time the string, so you just have to put in the “main” name.
I’ll now address the technical changes. This is how the game goes:
/quiz_start artist:Beatles

spotify.searchArtist(){ id: '3WrFJ7ztbogyGnTHbHJFl2', name: 'The Beatles' }

spotify.getArtistTopTracks()[ 'Let It Be', 'Hey Jude', 'Come Together', ... ]

Random choice → 'Hey Jude'

YouTube.searchSong('Hey Jude The Beatles')→ gets the yt URL

createAudioStream(url) → stream audio 20/30 sec

Bot enter the voice channel and starts playing the song

RoundHandler listens for the messages coming from the chat (internal of the voice channel)

User writes "Hey Jude"checkGuess()true → point in the db!

nextRound() → new random

Attachment
0
F3rro32

I was finally able to make the bot connect with discord and then entry the voice channel. That’s a great accomplishment, since I had had a lot of problems with this. I’m so happy it finally worked.
Basically, what I did was adding some permissions to the bot (without them the VOICE_SERVER_UPDATE packet wasn’t working). I also started using docker. With docker I can change versions easily, since some libraries aren’t as updated as node is.
I’m so glad I finally managed to make this happen.
Now I just have to make the last thing happen, the music has to play. For now it isnt working, but I’ll find soon a solution.

Attachment
0
F3rro32

I’m so happy since I’m encountering so many difficulties. I can’t even count them, they’re too many. I had another problem and I had to change approach. I abandoned the spotify quiz_idea, because, with actual spotify API, I had to add a user to the “whitelist” on spotify_apps; the max was 5 users, so not working for me.
I decided to use yt, for getting the audios. I decided to download just 20 sec of the song (using also ffmpeg) and then reproduce it. I first tried usign yt-dlp, but it wasn’t working. So I changed another time approach, and tried using @distube/ytsr. Nothing changed. I have to search for something else, but I’m positive.
A positive aspect is that I didn’t have to change many files. I just had to add a file for managing the interaction with the API, which I called YouTubeSearch.js. Then I just had to fix and replace some methods in GameManager.js and in RoundHandler, along with fixing the commands.
I’m founding a lot of problems, but I think I’ll be able to complete my idea, sooner or later.

Attachment
0
F3rro32

Here’s a little update.
I was able to fix some minor problems. It’s really tough so far this part (the debugging part), since it’s the first time I make a bot. It’s challenging, but I like proving myself so I’ll try harder and harder every day till finishing this project.
The first thing I fixed, was the scopes of the bot on the https://discord.com/developers. It’s so easy to forget even a single permission; nothing works.
Then I fixed some minor bugs in the code, for example client.once('ready') this is now deprecated and become client.once('clientReady'). Small things, that matters so much in the entire project.
I then fixed other small bugs.
At least now when I try the command /quiz_start, the server responds, and the permissions are correct; unfortunately there’s still some issues, but I’m going to fix them soon.
Bye bye from vinylBot kitchen

Attachment
0
F3rro32

Added Scorer.js and RoundHandler.js
The first just manages the temporarly scores of a game. Then it will be determined the winner, who’ll be given a point in the db.
The RoundHandler.js has just two methods (startRound, stopRound); basically it manages all actions in a round.
Updated the intents on https://discord.com/developers/applications.
For now the “music bot”, the one who just controls spotify , works pretty well. The “quiz bot” instead doesn’t work at all, so I’ll fix it.
I like encountering this kind of problems. They’re stimulating and help improve.
Stay tuned, cause we are closer to the end.

Attachment
Attachment
0
F3rro32

I’ve implemented the gameManager, which contains 4 functions for managing the entire game.
I then started coding the quiz.js. It contains the commands for the quiz; it’s similar to the spotify.js that I’ve made before.
The commands it will contain are:
/quiz_start <playlist_name> -> starts the game (for now I’ll accept only a playlist. I’ll figure out other options, such as artists, genres and other things like that, for now accept this :))
/quiz_stop -> stops the game
/quiz_skip -> skips the round (no one knows the answer so you just skip)
/leaderboard -> shows the leaderboard

Attachment
1

Comments

F3rro32
F3rro32 11 days ago

Btw, the code in the image isn’t finished, it’s the spotify js copied. I just changed the names and options. I’ll fix the behavior later.

F3rro32

I found a big issue, and I feel like it’s not the first I’ll find. My idea was to make a bot like jockie music, so when you “call it” it comes in your voice channel, plays the song, and you have to guess it.
It turns out it’s really difficult to do something like this with spotify, since it doesn’t allow “complete usage”.
My idea was using previews. Spotify allows to play a preview of the song (just 30 seconds). It’s enough for me, so I’m really lucky.
I wanted to restart everything, but to not waste my code, I decided that it will have two functionalities; the first, as the main idea, is the game, the second is that you can control your spotify (you must have PREMIUM) via ds commands, like the one I posted on the prev devlog.
I hope everything goes well :)

Attachment
0
F3rro32

Made spotify js, with all commands.
The commands are:
/auth –> send the link to authenticate
/logout –> logs out
/play <song_name> –> plays a determinate song
/pause –> pauses the song
/resume –> resume the song
/skip –> goes to the next song
/previous –> goes to the previous song
/volume <volume_level> –> change the SPOTIFY volume
/nowplaying –> shows the current track

It wasn’t so difficult, since I tried to give recognizable names to the funcs and attributes, so it was easier to code this part.
I tried it out (for now it’s just local), and it worked really well.
Stay tuned, cause the main part is coming

Attachment
Attachment
0
F3rro32

I did the client.js. I’m happy I did it since it’s one of the most complex in the whole project.
It manages all spotify logic, impling authentication OAuth, token refresh, research and control of reproduction.
Stay tuned for further updates.

Attachment
0
F3rro32

Init of project. Created the structure.
Completed index.js and tokenStore.js
Stay tuned for updates

Attachment
Attachment
0