From c9781ec009981b91845c3f97dcdb79e89eb0c382 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 5 Jan 2017 01:24:24 -0500 Subject: [PATCH] save after removing item from list --- skills/sample_taskbot.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/skills/sample_taskbot.js b/skills/sample_taskbot.js index 120fa44..70c51b6 100644 --- a/skills/sample_taskbot.js +++ b/skills/sample_taskbot.js @@ -103,14 +103,23 @@ module.exports = function(controller) { var item = user.tasks.splice(number,1); - // reply with a strikethrough message... - bot.reply(message, '~' + item + '~'); - - if (user.tasks.length > 0) { - bot.reply(message, 'Here are our remaining tasks:\n' + generateTaskList(user)); - } else { - bot.reply(message, 'Your list is now empty!'); - } + controller.storage.users.save(user, function(err,saved) { + + if (err) { + bot.reply(message, 'I experienced an error adding your task: ' + err); + } else { + // reply with a strikethrough message... + bot.reply(message, '~' + item + '~'); + + if (user.tasks.length > 0) { + bot.reply(message, 'Here are our remaining tasks:\n' + generateTaskList(user)); + } else { + bot.reply(message, 'Your list is now empty!'); + } + } + + }); + } }); }