Is there any way to consume a message event ( on("chat:message", function(msg) {...}); )? Or alternatively, is there a way to remove specific messages from the chat history? What I'm trying to do is expand the functionality of the dice roller with a repeat-dice ability. Specifically, I want to be able to make macros/abilities for AoE powers in D&D4, which roll to-hit separately but a single damage roll for all targets hit. I'm working with inline rolls at the moment, because that's what my friends and I have been using most extensively. The repetition works, but the chat shows the original message text (along with extraneous die roll[s]) in addition to the final product. The one option I see at the moment is simply using API messages rather than general messages, but then if I use queries to make the number of rolls variable (the primary purpose of the exercise!), the line[s] with the query is output last. The code I've been using, which doesn't consume anything: on("chat:message", function(msg) { var repeatInlineRolls = msg.content.match(/\$\[\[\d+?[^\[\]]*?\]\]\{\d+?\}/gm); if(repeatInlineRolls != null) { var finalMsg = msg.content; for(var i = 0; i < repeatInlineRolls.length; i++) { var repeat = repeatInlineRolls[i].substring(repeatInlineRolls[i].lastIndexOf('{')+1, repeatInlineRolls[i].lastIndexOf('}')); var roll = msg.inlinerolls[i].expression; var fullRoll = ''; for(var r = 0; r < repeat; r++) { fullRoll += '[[' + roll + ']], '; } fullRoll = fullRoll.substring(0, fullRoll.lastIndexOf(',')); finalMsg = finalMsg.replace(repeatInlineRolls[i], fullRoll); } sendChat(msg.who, finalMsg); } }); The regex finds text in the format "$[[0]]{0}"; by the time the code flow reaches this point, inline rolls have been indexed and appear as "$[[0]]" in the message content. My repeating syntax simply adds "{0}" directly after the inline roll. There are two main problems. One, the original message isn't consumed. If a player enters: Rolling d20+8 three times: [[d20+8]]{3} The result is something to the effect of:
Rolling d20 three times: [20]{3}
Rolling d20 three times: [9], [25], [17]
The second problem comes from multiple lines and queries. With a macro of:
/me does a thing! To lots of dudes!
[[d20+8]]{?{Targets}} vs. AC
Hit: [[d8+4]] fire damage
I get a result of:
Brian does a thing! To lots of dudes!
[17]{3} vs. AC
Hit: [10] fire damage
[28], [14], [14] vs. AC
I can alter the API code to work with API calls (and strip the ! off the front before posting the sendChat ), which does prevent both problems. However, the macro becomes extremely ugly, and it doesn't seem like a good idea to be sending API calls that aren't for anything except consuming the chat:
!/me does a thing! To lots of dudes!
![[d20+8]]{?{Targets}} vs. AC
!
!Hit: [[d8+4]] fire damage
Side note: sendChat(msg.who, ...) doesn't seem to post the message entirely correctly. The name is correct, but the background is grey instead of blue (as though the message was sent by a different player, rather than myself), and my gravatar does not appear in the chat. I thought it was simply an issue of posting as a character named "Brian (GM)" vs. posting as myself , but even when I hard-coded the speakingAs variable to my name and player ID it didn't seem to work (in fact, the name of the posting character was "Brian (GM)|-Abc123" etc. -- I tried a few variations).