5

我正在尝试创建一个向随机松弛用户发送直接消息的机器人。我要完成的第一步是 console.logging 用户列表。

这是我到目前为止所拥有的:

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);
  })
});

当我直接向机器人发送消息时marco,它会回复polo[Function]记录。如何记录一些真实数据?我试过bot.api.users.list.members了,但它记录为undefined. 谢谢你。

4

1 回答 1

4

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.

于 2017-04-01T21:39:20.410 回答