Nightbot Replace For Duel

I don’t know if there is already a topic for replace, but I have a !duel command that has the user challenge another viewer and I wanted to add more outcomes than the 400 character limit. I used a pastebin to add more outcomes but I can’t figure out how to get the command to tag user and touser.
https://pastebin.com/9EaiNMgF - Pastebin
I tried to user !commands add !duel -cd=5 $(eval var duel = “$(urlfetch https://pastebin.com/9EaiNMgF) “.split(”,”); duel[Math.floor(Math.random() * (duel.length - 1))]:wink:
How do I get Nightbot to replace the words user and touser in the pastebin to $(touser) and $(user) so it tags whoever uses it?

@BigBallerNationLA

Use JavaScipt’s replace() method to replace each instance of touser with $(touser) and user with $(user). Also make sure to use the raw paste link. Copy and paste this into chat:

!commands add -cd=5 !duel $(eval a=`$(urlfetch json https://pastebin.com/raw/9EaiNMgF)`.split(`,`);a[Math.floor(Math.random()*a.length)].replace(/touser/g,`$(touser)`).replace(/user/g,`$(user)`))
1 Like

Thank you so much. Works great!

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