Skip to content

Commands can only be used by certain users / roles / users with specific permissions #3

@Alon-L

Description

@Alon-L

Just like the permissions field for command configuration, there will be another field:

{
  name: 'help',
  aliases: ['h', 'help!'],
  permissions: ['SEND_MESSAGES'],
  access: {
    roles: ['ROLE ID'],
    users: ['USER ID'],
    permissions: ['SEND_MESSAGES'], // Any user with the SEND_MESSAGES permission will be able to use this command
  }
}

The bot will also throw an InvalidUserAccess error, which the user will be able to catch using:

try {
  ...
} catch(err) {
  if (err instanceof InvalidUserAccess) {
     ...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions