alianator is a tool to help Pycord and discord.py users easily resolve user-facing aliases for Discord permission flags.
Project description
alianator
alianator is a tool that helps Pycord and discord.py users easily resolve user-facing aliases for Discord permission flags.
Installation
$ pip install alianator
alianator doesn't include either Pycord or discord.py as a dependency; instead, it allows you to use whichever of the two libraries you prefer. alianator does not and will not support other Discord API wrappers, such as Nextcord, Hikari, or disnake.
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 permission 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 None
.
import alianator
import discord
# Resolving from a discord.Permissions object
perms = discord.Permissions.general()
aliases = alianator.resolve(perms, mode=True)
print(aliases)
# ['Manage Channels', 'Manage Server', 'View Audit Log', 'Read Messages', 'View Guild Insights', 'Manage Roles', 'Manage Webhooks', 'Manage Emojis and Stickers']
# Resolving from an integer
perms = 3072
aliases = alianator.resolve(perms, mode=True)
print(aliases)
# ['Read Messages', 'Send Messages']
# Resolving from a string
perms = "send_tts_messages"
aliases = alianator.resolve(perms, mode=True)
print(aliases)
# ['Send Text-To-Speech Messages']
# Resolving from a tuple
perms = ("moderate_members", True)
aliases = alianator.resolve(perms, mode=True)
print(aliases)
# ['Timeout Members']
# Resolving from a list of strings
perms = ["manage_guild", "manage_emojis"]
aliases = alianator.resolve(perms, mode=True)
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, mode=True)
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-1.0.0.tar.gz
.
File metadata
- Download URL: alianator-1.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b681bba3e98471bec94eebd25b306730ac34d18b6052fbdac02c1aeee4d4d3d |
|
MD5 | 12bab4fd5669f2416235a2a4820681dd |
|
BLAKE2b-256 | 9c87e04df9ee43f1b570f7a764ac89cd70bee990f3e981ee11a41758bd7b804c |
File details
Details for the file alianator-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: alianator-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93f05669ed07145d1065af6157f9137359d4f696eb993f4f9986b5c4e5b68e5d |
|
MD5 | 21208c71cc80ba7c18aa9c692001e324 |
|
BLAKE2b-256 | 4638da84fdc3576d37e40b55810a4563e851957166a6921d0594f14ddd61fbcc |