Music stream - Download command

It’s Twitch’s chat in full page, haha! On YouTube your stream has to be launched for Nightbot to watch your chat, this isn’t the case on Twitch.

If you want you can come test your command in my chat, however you’ll need a Twitch account.
I added the !download command with your data in case you come in.
To test it:

  1. play a song that isn’t yours on Spotify
  2. call !download, it should answer: This song isn't from Ikson.
  3. play a song that is yours on Spotify, but for which you don’t have a download link for yet
  4. call !download, it should answer: There is no link to download SONG yet.
  5. play a song of yours on Spotify for which you have a download link
  6. all !download, it should answer: Download SONG here: LINK

Yup, we’re hitting the characters limit… Ugh…
The characters limit is different for Twitch and YouTube, and Nightbot’s Message field reflects that so users can’t add commands that are longer than the character limit, to make sure the message is sent. Since most people only write text in the Message field it’s a nifty feature, however, when you work with JS, this can be very limiting as it limits the length of your code, which in most cases isn’t the length of the message Nighbot will post.

I’ll test the way to bypass the limitation before posting an update here.

Ah okay got you, I’m starting to understand the issue. Perhaps there’s some kind of tool that can shorten the text whilst keeping the information? Like an url shortener or similar

Found this: https://jscompress.com

This works in some cases, but not in ours, anyway, the solution we’re looking at here is pretty simple:

This is the code of the command:

$(eval a=`$(lastfm IksonOfficial "{{artist}}|{{title}}")`.split(`|`); d=`$(urlfetch json https://pastebin.com/raw/K4eyYK2y)`.split(`|`); $(urlfetch https://pastebin.com/raw/XXXXXXXX))

Replace XXXXXXXX with the paste ID of the new paste we’ll create, it should include:

if(a[0].toLowerCase()==`Ikson`.toLowerCase()){if(d.includes(a[1])){`Download ${a[1]} here: ${d[d.indexOf(a[1])+1]}`}else{`There is no link to download ${a[1]} yet.`}}else{`This song isn't from Ikson.`}

That makes the main command under 200 characters, 184 to be exact, which is under the YouTube chat character limit, to compare, for Twitch it’s 500, but Nightbot is capped at 400.

Now regarding the issue we have with Lastfm, first make sure your username is IksonOfficial, because by looking at Ikson Official, we in fact look at Ikson as Nightbot ditches the second part, that’s why we’re getting a song you never played before. I think it’s IksonOfficial because I went on Lastfm and when I go to your profile that’s the URL I get. But Lastfm still returns an error, so I would suggest to double check your Privacy Settings on Lastfm and make sure Hide recent listening information isn’t ticked in: Settings > Privacy > Recent listening.

Just pasted: $(eval a=$(lastfm Iksonofficial "{{artist}}|{{title}}").split(|); d=$(urlfetch json https://pastebin.com/raw/K4eyYK2y).split(|); $(urlfetch https://pastebin.com/raw/PpGCpXNS)) to the message window. But changed the capitalized O as it should be Iksonofficial

Yes, and it should work now! However, create your own paste as PpGCpXNS will expire tomorrow.

Ok what’s the purpose of the second paste? I know the first one included is the one I created.

The second paste includes all the extra code needed to give the different answers, since we have to bypass the 200 characters limit somehow.

Jump to the message I’m talking about by clicking on the arrow pointing towards the top at the top right of the embed.

Ah ok, got it! I’ll create my own paste and copy paste the text you had included within https://pastebin.com/raw/PpGCpXNS to it.

Yes, that works too!

Just did that and made sure to get the raw paste as well. Will try this now and report back. Thanks !

You can make sure the command works properly by doing the following

Worked now! Thanks a ton for the help! Anything I can shoutout in the description for you?

There’s actually a few other features I’m looking to integrate as well, like voting for track changing etc. But I think that’ll be easier to find on Google. No one had done this specific thing from what I could find so, complicated things :slight_smile:

Awesome! You’re very much welcome, the pleasure is mine! It was really exciting to work on this as it was something new and an idea that I found really interesting since I could use something like that in the future as well! When it comes to the shoutout, I appreciate the thought, but my SoundCloud is totally private for now, and I have yet to upload on Spotify either, I’m looking forward finishing a few tracks I like before starting to release some stuff again. Anyway, my artist name is the one I use on Twitch or here.

Regarding your other features, feel free to look on the forums, or open another topic if you don’t find any answering your needs. For example I think a vote to skip a track was already done, or can be done, I’m just not sure yet how I would go about it, but other people on the forum might have an idea.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.