Jump to content
McKay Development

Rockbob

Member
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Rockbob's Achievements

  1. Yeah you're right. The problem was loading the existing pollData on start. On my other server (different project, manager version 1.18.1. The one with the problem just got a full update on all modules) I'm initially loading the pollData in a try/catch function if omitted by the constructor. this.pollData = this.options.pollData || function() { try { JSON.parse(fs.readFileSync('./bots/pollData/' + this.botName + '.txt')); } catch (e) { fs.writeFileSync('./bots/pollData/' + this.botName + '.txt', ''); } }; Which works over there. Since I C+P the whole Bot Object initialization I didn't look into this at all. This loads the file correctly on my production but not on the fully updated one. Passing this as pollData to the manager initialization puts the value as [Function]. Therefore on next poll, the data gets cloned by your manager and the real pollData gets attached, resulting in the messup. As said in OP, too tunelled on the wrong part of the code. Thread can be closed. Thanks for pointing me in the right direction =)
  2. Hey, I'm currently rewriting my bots due to all those new goodies which been developed in the last year (shoutouts to McKay and everyone working on these). Currently debugging everything and saw that calling JSON.stringify on pollData returns undefined. Had a look at the original pollData and dug a little into the JSON.stringify manual. The manual's saying, that the method will return undefined if a part of the data is a function. Always thought that it would simply omit the function. (tested pre submitting: yep, everything I tried resulted in omitting the Function when calling stringify on the object). Either way, Im at a loss here. Here's a Screenshot of the pollData (this is pre stringifying and right at the beginning of the pollData): and here's my event handler: prototype._onPollData = function onPollDataCallback(data) { var that = this; try{ var write = JSON.stringify(data); }catch (e){ console.log(e); //pls lemme find some } console.log(util.inspect(data, false, null)); fs.writeFile('./bots/pollData/' + that.botName + '.json', JSON.stringify(data), function(err) { if (err){ console.log(err); } return; }); }; I guess that I simply am screwing up somewhere and am just to tunneled to see it but wanted to make sure, if that [Function] really belongs there. Cheers
×
×
  • Create New...