How to setup !song command in StreamElements?
Introduction of individual APIs
1. API link (song) - This API provides current name of song
2. API link (autor) - This API provides names of authors of current song
3. API link (autor + písnička) - This API provides name of song + name of authors + link to spotify in format: "Song: Author1, Author2 - Link to spotify"
4. API link (custom format) - This API allows you to return any formated text using variables
4.1 Example text with variables can look like:
This is my current song: %song% from %author%. Spotify link: %link%
- %song% - name of song
- %author% - name of author/authors separated by comma
- %link% - link to spotify
4.2 Text which we want to enter after ?format= is recommended to encode, because symbols like : can cause problems. For this case we can use for example: https://www.urlencoder.org/
4.3 Encoded text after ?format= can look like this:
This%20is%20my%20current%20song%3A%20%25song%25%20from%20%25author%25.%20Spotify%20link%3A%20%25link%25
4.4 Final link:
http://localhost:5173/formated/c15f7983-0ff3-4b0d-b52c-0d19b413a066?format=This%20is%20my%20current%20song%3A%20%25song%25%20from%20%25author%25.%20Spotify%20link%3A%20%25link%25
5. Adding to StreamElements
Go to chat commands
Select custom commands
Add new command
Enter name of command
Enter message. If you us API with custom format, then you don't need to enter any message besides API request, but if you want to use for example API with song + author, then you can enter here some text.
- API (author + song) - We want bot to write for example: "Current song: Faded: Alan Walker - https://spotify.com/...." so in Response type we enter this:
Current song: ${customapi.LINK}
Instead of LINK we enter copied link from dashboard, for example: http://localhost:5173/full/c15f7983-0ff3-4b0d-b52c-0d19b413a066
- API (custom format) - Here we can leave everything on our API, which will format your message, so in the Response Typúe you can directly enter ${customapi.LINK}:
${customapi.http://localhost:5173/formated/c15f7983-0ff3-4b0d-b52c-0d19b413a066?format=This%20is%20my%20current%20song%3A%20%25song%25%20from%20%25author%25.%20Spotify%20link%3A%20%25link%25}
Link corresponds to section 4.4 in this article
Activate command and you are done