Need help with alias arguments

Asked Mar 24, 2020·9 replies·Last activity 6 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

I'm using Restream to stream Beat Saber to twitch, Mixer, and others. There is a command that only works on twitch: "!bsr <song name>". The details don't matter so much, the problem is when Restream's chat bot relays that command from Mixer to Twitch, it outputs: "[Mixer: <username>] !bsr <song name>". So what I need to do is have Nightbot see that, then remove everything before the actual command.

I was able to get this to work only in cases where the song name is one word, by creating a command "[mixer: " and outputting, '$(2) $(3)' or '!bsr $(3)'. If I do- '!bsr $(3) $(4) $(5)' ..., but then I get a bunch of "null"s that mess it up. And if I use $(query), then I'm sure you know what happens, it's close but not quite there.

Please help, thank you.

9 replies

I found a js regex command that will format this correctly but I don't know how to implement it:

var str = "[Mixer: Smerle] !bsr be wild";
var txt = str.replace(/.*(?=!bsr)/i,"");
return txt;

Is an example, with the text to be replaced stated explicitly, but obviously that won't work either

This code will remove the first two words after [Mixer:

$(eval decodeURIComponent(`$(querystring)`).split(` `).slice(2).join(` `)||` `)

Thank you so much, this works perfectly. However, it works too perfectly, as in this repeats every message sent from mixer, is it possible to only have it run if it sees a '!' or '!bsr'?

Fixed.

$(eval a=decodeURIComponent(`$(querystring)`).split(` `);b=a.slice(2).join(` `);a[1]==`!bsr`&&b?b:` `)

Hi. Thank you for helping me, I know I'm probably being a pain but there is still one issue with it, it doesn't include the '!bsr' in the output text. Maybe there is something I'm supposed to add to the code to make it work? It does work if I include $(2) before the code, but then it still repeats anything that was said, even if it is not '!bsr'. Again, sorry for being a pain lol, we are so close 😛

stuck_out_tongue.png

I think it is removing the first two words after [mixer:, but it only should remove the first word after that, since the second word is the actual command that needs to be run '!bsr'. And also only to run if '!bsr' is the 2nd word (it looks like that part is working perfectly already)

Actually I fixed it. Just had to change slice(2) to slice(1). Thanks again you are awesome :D

smiley.png

Found out how to match any command starting with '!' instead of just '!bsr', glad I didn't have to ask you again lol. Here is the final code, in case anyone in the future comes across this exact same problem:

$(eval a=decodeURIComponent(\$(querystring)\).split(\ \);b=a.slice(1).join(\ \);a[1].substring(0,1)==\!\&&b?b:\ \)

Thanks again for your help!

I fixed it, my fault, definitely all done now thank you so much again.

Didn't find your answer? The community is on Discord.

Ask on Discord