A Discord permission name resolver for Pycord
Project description
alianator
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file alianator-3.2.1.tar.gz
.
File metadata
- Download URL: alianator-3.2.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1030-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a72b7ebc61d6dfab0f0705dbd9d9787296b404b37c2f8935e3400dec656040d6 |
|
MD5 | 8ab255e0291b2c8d84ca67c1330ff910 |
|
BLAKE2b-256 | c399bc9caeacc4d0694d8344c12e345fb85568b8cd9e4b87404f10b83309d159 |
File details
Details for the file alianator-3.2.1-py3-none-any.whl
.
File metadata
- Download URL: alianator-3.2.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1030-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df14b91d867e79cb2a3687adf4b9f7f3974a391e9c29fcea266c3fa054fe508 |
|
MD5 | b24c315156ceed8ba50d012de878973c |
|
BLAKE2b-256 | a8fc468ceca3239c6be5d3c78ea9a9850a55f9605e1e2aa9648df0b634b37094 |