NightDev Community Forums

Need help with alias arguments

I’m using Restream to stream Beat Saber to twitch, Mixer, and others. There is a command that only works on twitch: "!bsr ". 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: ] !bsr ". 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.

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(` `)||` `)
1 Like

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:` `)
1 Like

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:

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 :smiley:

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.