Skip to main content

A Discord permission name resolver for Pycord

Project description

alianator

PyPI - Python Version PyPI GitHub release (latest SemVer) PyPI - License Black

alianator is a Discord permission name resolver for Pycord. It takes Discord's API permission flags (e.g. manage_guild) and resolves them to their user-facing aliases (e.g. Manage Server).

Installation

$ pip install alianator

Pycord is not included as a dependency of alianator, but nonetheless must be installed for it to work. If alianator is unable to import the discord namespace, it will raise an ImportError.

Usage

alianator can resolve aliases from discord.Permissions objects, integers, strings, tuples, lists of strings, and lists of tuples.

import alianator

alianator.resolve(arg, mode=mode)

The optional mode flag can be used to specify which permissions should be resolved. If mode is True, only granted permissions will be resolved; if mode is False, only denied permissions will be resolved; if mode is None, all permissions will be resolved. If mode is not explicitly specified, it will default to True.

import alianator
import discord

# Resolving from a discord.Permissions object
perms = discord.Permissions.general()
aliases = alianator.resolve(perms)
print(aliases)
# ['Manage Channels', 'Manage Server', 'View Audit Log', 'Read Messages', 'View Server Insights', 'Manage Roles', 'Manage Webhooks', 'Manage Emojis and Stickers']


# Resolving from an integer
perms = 3072
aliases = alianator.resolve(perms)
print(aliases)
# ['View Channel', 'Send Messages and Create Posts']


# Resolving from a string
perms = "send_tts_messages"
aliases = alianator.resolve(perms)
print(aliases)
# ['Send Text-To-Speech Messages']


# Resolving from a tuple
perms = ("moderate_members", True)
aliases = alianator.resolve(perms)
print(aliases)
# ['Timeout Members']


# Resolving from a list of strings
perms = ["manage_guild", "manage_emojis"]
aliases = alianator.resolve(perms)
print(aliases)
# ['Manage Server', 'Manage Emojis and Stickers']


# Resolving from a list of tuples
perms = [("use_slash_commands", True), ("use_voice_activation", True)]
aliases = alianator.resolve(perms)
print(aliases)
# ['Use Application Commands', 'Use Voice Activity']

That's about all there is to it. alianator does one thing and does it well.

License

alianator is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alianator-4.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

alianator-4.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file alianator-4.0.1.tar.gz.

File metadata

  • Download URL: alianator-4.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1033-azure

File hashes

Hashes for alianator-4.0.1.tar.gz
Algorithm Hash digest
SHA256 3be7bb448c868a901252b10f4c7e519ace2f78ad10ff0d87cdd4f5b704e3e9e2
MD5 27480a5d480bf5dbd2cc8a582d0e843b
BLAKE2b-256 d7fe856f5ac8218507a9f9a0536f681f51c930eb9116ab7a8ee1fe46b6557df3

See more details on using hashes here.

File details

Details for the file alianator-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: alianator-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1033-azure

File hashes

Hashes for alianator-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 95e43560c3322fc360c0719405c6414d85278205a1328afc3e06cebec4d2fe11
MD5 8286f5eeddfaab2cd3569c7dd1eab4d7
BLAKE2b-256 af74f8bb7edc30d52e1b1c97cf1b7d9b3566e89091e355558f6ebc7e2861bcdf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page