Skip to content

tanjun.permissions#

Functions used to calculate permissions in Tanjun.

ALL_PERMISSIONS module-attribute #

ALL_PERMISSIONS = all_permissions()

All of all the known permissions based on the linked version of Hikari.

DM_PERMISSIONS module-attribute #

DM_PERMISSIONS = ADD_REACTIONS | VIEW_CHANNEL | SEND_MESSAGES | EMBED_LINKS | ATTACH_FILES | READ_MESSAGE_HISTORY | USE_EXTERNAL_EMOJIS | USE_EXTERNAL_STICKERS | USE_APPLICATION_COMMANDS

Bitfield of the permissions which are accessibly within DM channels.

calculate_everyone_permissions #

calculate_everyone_permissions(everyone_role, /, *, channel=None)

Calculate a guild's default permissions within the guild or for a specific channel.

Parameters:

  • everyone_role (Role) –

    The guild's default @everyone role.

  • channel (Optional[PermissibleGuildChannel], default: None ) –

    The channel to calculate the permissions for.

    If this is left as None then this will just calculate the default permissions on a guild level.

Returns:

calculate_permissions #

calculate_permissions(member, guild, roles, /, *, channel=None)

Calculate the permissions a member has within a guild.

Parameters:

  • member (Member) –

    Object of the member to calculate the permissions for.

  • guild (Guild) –

    Object of the guild to calculate their permissions within.

  • roles (Mapping[Snowflake, Role]) –

    Mapping of snowflake IDs to objects of the roles within the target guild.

  • channel (Optional[PermissibleGuildChannel], default: None ) –

    Object of the channel to calculate the member's permissions in.

    If this is left as None then this will just calculate their permissions on a guild level.

Returns:

  • Permissions

    Value of the member's permissions either within the guild or specified guild channel.

fetch_everyone_permissions async #

fetch_everyone_permissions(client, guild_id, /, *, channel=None)

Calculate the permissions a guild's default @everyone role has within a guild or for a specific channel.

Note

This callback will fallback to REST requests if cache lookups fail or are not possible.

Parameters:

  • client (Client) –

    The Tanjun client to use for lookups.

  • guild_id (Snowflake) –

    ID of the guild to calculate the default permissions for.

  • channel (Optional[SnowflakeishOr[GuildChannel]], default: None ) –

    The channel to calculate the permissions for.

    If this is left as None then this will just calculate the default permissions on a guild level.

Returns:

fetch_permissions async #

fetch_permissions(client, member, /, *, channel=None)

Calculate the permissions a member has within a guild.

Note

This callback will fallback to REST requests if cache lookups fail or are not possible.

Parameters:

  • client (Client) –

    The Tanjun client to use for lookups.

  • member (Member) –

    The object of the member to calculate the permissions for.

  • channel (Optional[SnowflakeishOr[GuildChannel]], default: None ) –

    The object or ID of the channel to get their permissions in. If left as None then this will return their base guild permissions.

Returns: