How to verify if the user belongs to the slack channel

17 Views Asked by At

I' working on a /command using Python. The command works, however I don't want all the users to able to use that /command. I only want the users authorized to use the slack channel able to use that /command, if not display an error. How can I check if the given user is belongs to the slack channel? Thank you very much!

I was trying the below but didn't work.

@app.command("/test")
def open_modal(ack, body,client, command, logger):
    # Acknowledge the command request
    ack()

    channelID = "ZYX0ABC1235"
    
    canpost = app.command.channel_id == channelID
    if !canpost:
        respond({
            text: "Looks like you aren't authorized to use /close-ticket in this channel!",
        })
        return
    else:
        # Call views_open with the built-in client
        client.views_open(#rest of the code works)
            
0

There are 0 best solutions below