Ok, so, I think I've figured out the trigger for it (which also means I've got a simplest code) and there are some changes to what I said above. If I send a noarchive message during the sandbox spin up (such as a message on(ready)) it can then trigger the error. In the below code, if I load up the script the message in on(ready) is sent. I can send archived or not archived messages just fine at this point. If I reload the sandbox though, the message in on(ready) is sent again and then the chat also sends the API chat command message for the last chat triggered noarchive message which then triggers the associated noarchive message to be sent again (which of course results in a new message id). At this point, any noarchive message sent by the API will result in this behavior. var BaseScript = BaseScript || (function() {
'use strict';
var HandleInput = function(msg_orig) {
var msg = _.clone(msg_orig),
args;
log('&{template:'+msg.rolltemplate+'}'+msg.content);
log(msg);
if (msg.type !== 'api' || !playerIsGM(msg.playerid)){
return;
}
if(_.has(msg,'inlinerolls')){//calculates inline rolls
msg.content = _.chain(msg.inlinerolls)
.reduce(function(m,v,k){
m['$[['+k+']]']=v.results.total || 0;
return m;
},{})
.reduce(function(m,v,k){
return m.replace(k,v);
},msg.content)
.value();
}
args = msg.content.split(/\s+/);//splits the message contents into discrete arguments
switch(args[0]) {
case '!naFalse':
sendChat('BaseScript','This message is stored in the chat log (noarchive:false)');
break;
case '!naTrue1':
sendChat('BaseScript','This message is not stored in the chat log (noarchive:true)',null,{noarchive:true});
break;
case '!naTrue2':
sendChat('BaseScript','**This message is also not stored in the chat log (noarchive:true)**',null,{noarchive:true});
break;
}
},
RegisterEventHandlers = function() {
on('chat:message', HandleInput);
};
return {
RegisterEventHandlers: RegisterEventHandlers
};
}());
on("ready",function(){
'use strict';
sendChat('BaseScript','***This message was sent from on(ready) (noarchive:true)***',null,{noarchive:true});
BaseScript.RegisterEventHandlers();
});
Let me know if you need anything else and I apologize for not noticing that it was actually receiving the API command for the associated messages before, probably would have made troubleshooting easier. TL;DR:Steps to recreate: Save the above script on(ready) message will be sent trigger one of the noarchive messages via the chat commands reload the API sandbox on(ready) message will be sent wait a second or two API receives the chat command that you sent to trigger a noarchive message before the sandbox reloaded triggered noarchive message is sent If you only trigger non-archived messages with api commands, the behavior does not show up