Skip to content

tanjun.permissions#

Functions used to calculate permissions in Tanjun.

ALL_PERMISSIONS module-attribute #

ALL_PERMISSIONS: typing.Final[hikari.Permissions] = hikari.Permissions.all_permissions()

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

DM_PERMISSIONS module-attribute #

DM_PERMISSIONS: typing.Final[hikari.Permissions] = hikari.Permissions.ADD_REACTIONS | hikari.Permissions.VIEW_CHANNEL | hikari.Permissions.SEND_MESSAGES | hikari.Permissions.EMBED_LINKS | hikari.Permissions.ATTACH_FILES | hikari.Permissions.READ_MESSAGE_HISTORY | hikari.Permissions.USE_EXTERNAL_EMOJIS | hikari.Permissions.USE_EXTERNAL_STICKERS | hikari.Permissions.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.

PARAMETER DESCRIPTION
everyone_role

The guild's default @everyone role.

TYPE: hikari.Role

channel

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.

TYPE: typing.Optional[hikari.PermissibleGuildChannel] DEFAULT: None

RETURNS DESCRIPTION
hikari.Permissions

The calculated permissions.

calculate_permissions #

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

Calculate the permissions a member has within a guild.

PARAMETER DESCRIPTION
member

Object of the member to calculate the permissions for.

TYPE: hikari.Member

guild

Object of the guild to calculate their permissions within.

TYPE: hikari.Guild

roles

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

TYPE: collections.Mapping[hikari.Snowflake, hikari.Role]

channel

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.

TYPE: typing.Optional[hikari.PermissibleGuildChannel] DEFAULT: None

RETURNS DESCRIPTION
hikari.Permission

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.

PARAMETER DESCRIPTION
client

The Tanjun client to use for lookups.

TYPE: tanjun.Client

guild_id

ID of the guild to calculate the default permissions for.

TYPE: hikari.Snowflake

channel

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.

TYPE: typing.Optional[hikari.SnowflakeishOr[hikari.GuildChannel]] DEFAULT: None

RETURNS DESCRIPTION
hikari.Permissions

The calculated permissions.

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.

PARAMETER DESCRIPTION
client

The Tanjun client to use for lookups.

TYPE: tanjun.Client

member

The object of the member to calculate the permissions for.

TYPE: hikari.Member

channel

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

TYPE: typing.Optional[hikari.SnowflakeishOr[hikari.GuildChannel]] DEFAULT: None

RETURNS DESCRIPTION
hikari.Permissions

The calculated permissions.