alianator


Namealianator JSON
Version 3.2.1 PyPI version JSON
download
home_pagehttps://github.com/celsiusnarhwal/alianator
SummaryA Discord permission name resolver for Pycord
upload_time2023-01-16 18:07:09
maintainer
docs_urlNone
authorcelsius narhwal
requires_python>=3.8,<4.0
licenseMIT
keywords discord permissions aliases pycord
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # alianator

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/alianator?logo=python&logoColor=white&style=for-the-badge)](https://pypi.org/project/alianator)
[![PyPI](https://img.shields.io/pypi/v/alianator?logo=pypi&color=green&logoColor=white&style=for-the-badge)](https://pypi.org/project/alianator)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/celsiusnarhwal/alianator?logo=github&color=orange&logoColor=white&style=for-the-badge)](https://github.com/celsiusnarhwal/alianator/releases)
[![PyPI - License](https://img.shields.io/pypi/l/alianator?color=03cb98&style=for-the-badge)](https://github.com/celsiusnarhwal/alianator/blob/master/LICENSE)

alianator is a Discord permission name resolver for [Pycord](https://github.com/Pycord-Development/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

```bash
$ pip install alianator
```

[Pycord](https://github.com/Pycord-Development/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.

```python
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`.

```python
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](https://github.com/celsiusnarhwal/alianator/blob/master/LICENSE.md).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/celsiusnarhwal/alianator",
    "name": "alianator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "discord,permissions,aliases,pycord",
    "author": "celsius narhwal",
    "author_email": "celsiusnarhwal@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c3/99/bc9caeacc4d0694d8344c12e345fb85568b8cd9e4b87404f10b83309d159/alianator-3.2.1.tar.gz",
    "platform": null,
    "description": "# alianator\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/alianator?logo=python&logoColor=white&style=for-the-badge)](https://pypi.org/project/alianator)\n[![PyPI](https://img.shields.io/pypi/v/alianator?logo=pypi&color=green&logoColor=white&style=for-the-badge)](https://pypi.org/project/alianator)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/celsiusnarhwal/alianator?logo=github&color=orange&logoColor=white&style=for-the-badge)](https://github.com/celsiusnarhwal/alianator/releases)\n[![PyPI - License](https://img.shields.io/pypi/l/alianator?color=03cb98&style=for-the-badge)](https://github.com/celsiusnarhwal/alianator/blob/master/LICENSE)\n\nalianator is a Discord permission name resolver for [Pycord](https://github.com/Pycord-Development/pycord). \nIt takes Discord's API permission flags (e.g. `manage_guild`) and resolves them to their user-facing aliases (e.g. `Manage Server`).\n\n## Installation\n\n```bash\n$ pip install alianator\n```\n\n[Pycord](https://github.com/Pycord-Development/pycord) is not included as a dependency of alianator, but nonetheless must \nbe installed for it to work. If alianator is unable to import the `discord` namespace, it will raise an `ImportError`.\n\n## Usage\n\nalianator can resolve aliases from `discord.Permissions` objects, integers, strings, tuples, lists of strings, and lists\nof tuples.\n\n```python\nimport alianator\n\nalianator.resolve(arg, mode=mode)\n```\n\nThe optional `mode` flag can be used to specify which permissions should be resolved. If `mode` is `True`, only granted\npermissions will be resolved; if `mode` is `False`, only denied permissions will be resolved; if `mode` is `None`, all\npermissions will be resolved. If `mode` is not explicitly specified, it will default to `True`.\n\n```python\nimport alianator\nimport discord\n\n# Resolving from a discord.Permissions object\nperms = discord.Permissions.general()\naliases = alianator.resolve(perms)\nprint(aliases)\n# ['Manage Channels', 'Manage Server', 'View Audit Log', 'Read Messages', 'View Server Insights', 'Manage Roles', 'Manage Webhooks', 'Manage Emojis and Stickers']\n\n\n# Resolving from an integer\nperms = 3072\naliases = alianator.resolve(perms)\nprint(aliases)\n# ['View Channel', 'Send Messages and Create Posts']\n\n\n# Resolving from a string\nperms = \"send_tts_messages\"\naliases = alianator.resolve(perms)\nprint(aliases)\n# ['Send Text-To-Speech Messages']\n\n\n# Resolving from a tuple\nperms = (\"moderate_members\", True)\naliases = alianator.resolve(perms)\nprint(aliases)\n# ['Timeout Members']\n\n\n# Resolving from a list of strings\nperms = [\"manage_guild\", \"manage_emojis\"]\naliases = alianator.resolve(perms)\nprint(aliases)\n# ['Manage Server', 'Manage Emojis and Stickers']\n\n\n# Resolving from a list of tuples\nperms = [(\"use_slash_commands\", True), (\"use_voice_activation\", True)]\naliases = alianator.resolve(perms)\nprint(aliases)\n# ['Use Application Commands', 'Use Voice Activity']\n```\n\nThat's about all there is to it. alianator does one thing and does it well.\n\n## License\n\nalianator is released under the [MIT License](https://github.com/celsiusnarhwal/alianator/blob/master/LICENSE.md).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Discord permission name resolver for Pycord",
    "version": "3.2.1",
    "split_keywords": [
        "discord",
        "permissions",
        "aliases",
        "pycord"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8fc468ceca3239c6be5d3c78ea9a9850a55f9605e1e2aa9648df0b634b37094",
                "md5": "b24c315156ceed8ba50d012de878973c",
                "sha256": "8df14b91d867e79cb2a3687adf4b9f7f3974a391e9c29fcea266c3fa054fe508"
            },
            "downloads": -1,
            "filename": "alianator-3.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b24c315156ceed8ba50d012de878973c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5468,
            "upload_time": "2023-01-16T18:07:07",
            "upload_time_iso_8601": "2023-01-16T18:07:07.665953Z",
            "url": "https://files.pythonhosted.org/packages/a8/fc/468ceca3239c6be5d3c78ea9a9850a55f9605e1e2aa9648df0b634b37094/alianator-3.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c399bc9caeacc4d0694d8344c12e345fb85568b8cd9e4b87404f10b83309d159",
                "md5": "8ab255e0291b2c8d84ca67c1330ff910",
                "sha256": "a72b7ebc61d6dfab0f0705dbd9d9787296b404b37c2f8935e3400dec656040d6"
            },
            "downloads": -1,
            "filename": "alianator-3.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8ab255e0291b2c8d84ca67c1330ff910",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 5019,
            "upload_time": "2023-01-16T18:07:09",
            "upload_time_iso_8601": "2023-01-16T18:07:09.235808Z",
            "url": "https://files.pythonhosted.org/packages/c3/99/bc9caeacc4d0694d8344c12e345fb85568b8cd9e4b87404f10b83309d159/alianator-3.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-16 18:07:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "celsiusnarhwal",
    "github_project": "alianator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "alianator"
}
        
Elapsed time: 0.03756s