From 5be3ba497e8e9f8e7079c34a6b8468aa070d52a0 Mon Sep 17 00:00:00 2001 From: Schuyler Duveen Date: Mon, 30 Jul 2018 09:43:04 -0400 Subject: [PATCH] send token with logout --- skills/slash_commands.js | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/skills/slash_commands.js b/skills/slash_commands.js index 83272c4..c4ff992 100644 --- a/skills/slash_commands.js +++ b/skills/slash_commands.js @@ -296,23 +296,28 @@ function getFlags(controller, bot, message, cb) { } function logOut(controller, bot, message){ - let user = message.user_id - // console.log(user) - var userChannels = [] - bot.api.channels.list({token:bot.config.token}, function(err,response){ - response.channels.forEach((item) => { - if(item.members.includes(user)){ - userChannels.push(item.id) - // console.log("channels: "+ userChannels) - } - }) - userChannels.forEach((channel)=> { - bot.api.channels.leave({token:bot.config.bot.app_token, channel: channel, user: user}, function(err,response){ - // console.log(err, response) - }) - }) - bot.replyPublic(message, 'You have logged out! Thank you so much for volunteering your time - you are so appreciated!') - }) + let user = message.user_id + // console.log(user) + var userChannels = [] + bot.api.channels.list( + {token:bot.config.bot.app_token}, + (err,response) => { + response.channels.forEach((item) => { + if(item.members.includes(user)){ + userChannels.push(item.id) + // console.log("channels: "+ userChannels) + } + }) + userChannels.forEach((channel) => { + bot.api.channels.leave({ + token:bot.config.bot.app_token, + channel: channel, + user: user}, (err,response) => { + // console.log(err, response) + }) + }) + bot.replyPublic(message, 'You have logged out! Thank you so much for volunteering your time - you are so appreciated!') + }) }