Restricting access
Occasionally, you might wish to restrict bot commands to administrators of your Slack team. A good example is a bot that controls a project's deploy process. This can be immensely powerful but perhaps not something that you want every user to have access to. Only administrators (also known as admins) should have the authority to access such functions. Admins are special users who have administrative powers over the Slack team. Luckily, restricting such access is easy with the is_admin
property attached to a user object.
In the following example, we'll restrict the uptime
command demonstrated in the previous topic to admin users, notifying the restricted user that they can't use that command:
slack.on(RTM_EVENTS.MESSAGE, (message) => { let user = slack.dataStore.getUserById(message.user) if (user && user.is_bot) { return; } let channel = slack.dataStore.getChannelGroupOrDMById(message.channel); if (message.text) { let msg =...