!addcom in discord passes discord objects when triggered on twitch

When creating commands in discord via !addcom with emotes in the command string, they’re evaluated as discord objects rather than being resolved/converted back to the twitch emotes that the moderator is inputting.

imgur gallery showing isssue

If you want it to support both, you need to use a combination of $(eval) and $(provider) https://docs.nightbot.tv/commands/variables/provider . The reason it passes the discord resolvable is because that’s how Discord treats it.

I don’t need it to support both, I need an input method that’s twitch compatible that can be used from discord because at the moment there’s no way to use twitch emotes from discord without passing the discord object. Even if I attempt to use an $(eval) if I setup the command on discord it will pass the discord object rather than the string I’m typing. If something looks like <:foo:[[:num:]]+> you should automatically be pulling the foo part when being run on twitch instead of passing the full object reference.

If you’d like a regex that works: <:(.*):[0-9]+>

This works on the first match, I’m too much of a noob with js to provide a proper regex that works across repeated matches:

var test = "Nightbot: <:ml7OLAF:453284677957189632> <:ml7Lurk:474609392197697547>";
var regex = / <:(.*):[0-9]+> /gm;
console.log(test.replace(regex, ' $1 '));


Have you tried splitting the input into an array using a whitespace delimiter/separator and running a replace() on each item? For example if you wanted to create !addcom2 as an alias of !addcom that cleans up the input as you mentioned before:

!addcom !addcom2 -a=!addcom -cd=5 $(eval a=decodeURIComponent(`$(querystring)`).split(` `);for(i=0;i<a.length;i++){a[i]=a[i].replace(/<:(.*):[0-9]+>/gm,`$1`);}a.join(` `))

It won’t work if your input has two discord emotes crammed together with no space in between but I highly doubt you’d have an input like that in the first place since Twitch chat wouldn’t be able to identify emotes crammed together.

It still seems to me that if nightbot “supports” both twitch and discord, it should auto-convert between them without having to do any weird acrobatics or training the mods to use the “correct” version of !addcom especially when the emotes are linked between twitch and discord. (our twitch added commands don’t output discord-compatible emotes either)

1 Like

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