Represents a role of the guild.

Constructors

  • Constructs a new Role object.

    Parameters

    • client: Client

      The client instance managing this role.

    • data: any

      The raw data from the API representing the role.

    Returns Role

Properties

color: number
flags: number
hoist: boolean
icon?: string
id: string
managed: boolean
mentionable: boolean
name: string
permissions: string
position: number
tags?: any
unicodeEmoji?: string

Methods

  • Creates a new role in the guild with the specified options.

    This function accepts either a RolePayload instance or a plain options object to create and send a role creation request. It validates the options, prepares the payload, and then sends the request to create the role. Finally, it returns a promise that resolves to the newly created role's data.

    Parameters

    • options: object | RolePayload

      The role creation options, which can be an instance of RolePayload or a plain object with role data.

    Returns Promise<Role>

    A promise that resolves to the newly created Role instance.

    If there is an issue with the provided options or the API request.

  • Deletes the specified role from the guild.

    This method sends a request to the Discord API to permanently delete a role identified by its ID within the guild. Once deleted, the role cannot be recovered, and users assigned to this role will lose all permissions associated with it.

    Returns Promise<void>

    A promise that resolves when the role has been successfully deleted.

    Throws an error if the deletion request fails. This may occur due to insufficient permissions, if the role does not exist, or if the guild is not accessible.

  • Edits the properties of the role with the specified options.

    This method sends a request to the Discord API to update the role's attributes identified by its ID within the guild. The updated role data will be reflected in the current instance after the operation is successful.

    Parameters

    • options: object | RolePayload

      The options for editing the role, which can be an instance of RolePayload or a plain object with role data.

    Returns Promise<Role>

    A promise that resolves to the updated Role instance.

    If there is an issue with the provided options or the API request fails, such as insufficient permissions or invalid data.