ah... for that you'll want to encode (or double encode) those characters. I use Aaron's handy function for this... const HE = (() => { const esRE = (s) => s.replace(/(\\|\/|\[|\]|\(|\)|\{|\}|\?|\+|\*|\||\.|\^|\$)/g, '\\$1'); const e = (s) => `&${s};`; const entities = { '<': e('lt'), '>': e('gt'), "'": e('#39'), '@': e('#64'), '{': e('#123'), '|': e('#124'), '}': e('#125'), '[': e('#91'), ']': e('#93'), '"': e('quot'), '*': e('#42') }; const re = new RegExp(`(${Object.keys(entities).map(esRE).join('|')})`, 'g'); return (s) => s.replace(re, (c) => (entities[c] || c)); })(); Then just feed whatever needs encoding to that function: let outputmsg = '/w <charname> [Click To Bless](!cmaster --add,condition=bless,duration=10,-1 {&select @{target|token_id}})';
sendChat('',HE(outputmsg)); If something needs to be double encoded, just feed the output of the function to itself: sendChat('',HE(HE(outputmsg))); EDIT: You might only need to encode the command line portion of that line (because you want the brackets that establish the button syntax to be processed... so your usage might look more like: let outputmsg = `/w <charname> [Click To Bless](${HE('!cmaster --add,condition=bless,duration=10,-1 {&select @{target|token_id}})')}`; Air-coded, again, but that should be right.