I'm trying to create a bot that sends a direct message to a random slack user. The first step I am trying to accomplish is console.logging the list of users.
Here is what I have so far:
controller.hears('marco', 'direct_message', function(bot, message) {
bot.api.users.list({user: message.user}, function(err, list){
bot.reply(message, "polo");
console.log(bot.api.users.list);
})
});
When I direct message the bot marco
, it replies polo
and [Function]
is logged. How am able to log some real data? I tried bot.api.users.list.members
, but it logs as undefined
. Thank you.
If you want to list ALL users, you are using a correct API call, just remove the params from it ({}
instead of {user: message.user}
).
Docs: users.list
If you want to get information about a specific user from your team, you should use the following API call: bot.api.users.info({ user: USER_ID }, function (err, response) { ... });
Docs: users.info
There's also a test section in the Slack docs ('Tester' tab) so that you can try out what the API calls will return for your actual users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With