dislash.py


Namedislash.py JSON
Version 0.3.9 PyPI version JSON
download
home_pagehttps://github.com/EQUENOS/dislash.py
SummaryA python wrapper for discord slash commands.
upload_time2021-02-26 08:55:59
maintainer
docs_urlNone
authorEQUENOS
requires_python>=3.6, <4
license
keywords python discord slash commands api discord-api discord-py slash-commands
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dislash.py

[![Discord](https://discord.com/api/guilds/808030843078836254/embed.png)](https://discord.gg/gJDbCw8aQy)
[![PyPi](https://img.shields.io/pypi/v/dislash.py.svg)](https://pypi.org/project/dislash.py)
[![Python](https://img.shields.io/pypi/pyversions/dislash.py.svg)](https://pypi.python.org/pypi/dislash.py)

An extending library for [discord.py](https://github.com/Rapptz/discord.py) that allows to build awesome slash-commands.

⭐ Star us on GitHub - we do really need your feedback and help!

📄 Slash commands is a new discord API feature that allows to build user-friendly commands.
Once "`/`" is pressed on keyboard, the entire list of slash-commands pops up.
The list includes hints and short descriptions which makes exploring your bot much easier.

📄 This library is basically a python wrapper that makes the process of creating slash-commands much easier.



# Installation

Run any of these commands in terminal:
```
pip install dislash.py
```
```
python -m pip install dislash.py
```



# Features

* Supports automatic registration of slash-commands
* Supports manual and automatic sharding
* Convenient decorator-based interface
* OOP-based slash-command constructor



# Examples
💡 This library does require **[discord.py](https://github.com/Rapptz/discord.py)** installed.


## Creating a slash-command
In this example registration is automatic.
If you want to register slash-commands separately, see examples below.

```python
from discord.ext import commands
from dislash import slash_commands
from dislash.interactions import *

client = commands.Bot(command_prefix="!")
slash = slash_commands.SlashClient(client)
test_guilds = [12345, 98765]

@slash.command(
    name="hello", # Defaults to function name
    description="Says hello",
    guild_ids=test_guilds # If not specified, the command is registered globally
    # Global registration takes more than 1 hour
)
async def hello(inter):
    await inter.reply("Hello!")

client.run("BOT_TOKEN")
```


## Registering a slash-command

This example only shows how to register a slash-command.

```python
from discord.ext import commands
from dislash import slash_commands
from dislash.interactions import *

client = commands.Bot(command_prefix="!")
slash = slash_commands.SlashClient(client)
test_guild_ID = 12345

@slash.event
async def on_ready():
    sc = SlashCommand(
        name="random",
        description="Returns a random number from the given range",
        options=[
            Option(
                name="start",
                description="Enter a number",
                required=True,
                type=Type.INTEGER
            ),
            Option(
                name="end",
                description="Enter a number",
                required=True,
                type=Type.INTEGER
            )
        ]
    )
    await slash.register_global_slash_command(sc)
    # Discord API uploads GLOBAL commands for more than 1 hour
    # That's why I highly recommend .register_guild_slash_command for testing:
    await slash.register_guild_slash_command(test_guild_id, sc)

client.run("BOT_TOKEN")
```
You should register a slash-command only once in order to make it work. You can always edit it if you want, using `.edit_global_slash_command` / `.edit_guild_slash_command` methods.


## Responding to a slash-command

It's assumed that you've already registered the command.

```python
from random import randint
from discord.ext import commands
from dislash import slash_commands
from dislash.interactions import *

client = commands.Bot(command_prefix="!")
slash = slash_commands.SlashClient(client)

@slash.command()
async def random(interaction):
    # interaction is instance of `interactions.Interaction`
    # It's pretty much the same as "ctx" from discord.py
    # except <message> attribute is replaced by <data>
    a = interaction.data.get('start')
    b = interaction.data.get('end')
    if b < a: a, b = b, a
    await interaction.reply(randint(a, b))

lient.run("BOT_TOKEN")
```



# Links
> **[Documentation](https://dislashpy.readthedocs.io/en/latest)**

> **[PyPi](https://pypi.org/project/dislash.py)**

> **[Our Discord](https://discord.gg/gJDbCw8aQy)**


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/EQUENOS/dislash.py",
    "name": "dislash.py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6, <4",
    "maintainer_email": "",
    "keywords": "python,discord,slash,commands,api,discord-api,discord-py,slash-commands",
    "author": "EQUENOS",
    "author_email": "equenos1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/32/29/971106a989986a6b4a1863a1227678b871e37e3511a988bc101a6f11394c/dislash.py-0.3.9.tar.gz",
    "platform": "",
    "description": "# dislash.py\n\n[![Discord](https://discord.com/api/guilds/808030843078836254/embed.png)](https://discord.gg/gJDbCw8aQy)\n[![PyPi](https://img.shields.io/pypi/v/dislash.py.svg)](https://pypi.org/project/dislash.py)\n[![Python](https://img.shields.io/pypi/pyversions/dislash.py.svg)](https://pypi.python.org/pypi/dislash.py)\n\nAn extending library for [discord.py](https://github.com/Rapptz/discord.py) that allows to build awesome slash-commands.\n\n\u2b50 Star us on GitHub - we do really need your feedback and help!\n\n\ud83d\udcc4 Slash commands is a new discord API feature that allows to build user-friendly commands.\nOnce \"`/`\" is pressed on keyboard, the entire list of slash-commands pops up.\nThe list includes hints and short descriptions which makes exploring your bot much easier.\n\n\ud83d\udcc4 This library is basically a python wrapper that makes the process of creating slash-commands much easier.\n\n\n\n# Installation\n\nRun any of these commands in terminal:\n```\npip install dislash.py\n```\n```\npython -m pip install dislash.py\n```\n\n\n\n# Features\n\n* Supports automatic registration of slash-commands\n* Supports manual and automatic sharding\n* Convenient decorator-based interface\n* OOP-based slash-command constructor\n\n\n\n# Examples\n\ud83d\udca1 This library does require **[discord.py](https://github.com/Rapptz/discord.py)** installed.\n\n\n## Creating a slash-command\nIn this example registration is automatic.\nIf you want to register slash-commands separately, see examples below.\n\n```python\nfrom discord.ext import commands\nfrom dislash import slash_commands\nfrom dislash.interactions import *\n\nclient = commands.Bot(command_prefix=\"!\")\nslash = slash_commands.SlashClient(client)\ntest_guilds = [12345, 98765]\n\n@slash.command(\n    name=\"hello\", # Defaults to function name\n    description=\"Says hello\",\n    guild_ids=test_guilds # If not specified, the command is registered globally\n    # Global registration takes more than 1 hour\n)\nasync def hello(inter):\n    await inter.reply(\"Hello!\")\n\nclient.run(\"BOT_TOKEN\")\n```\n\n\n## Registering a slash-command\n\nThis example only shows how to register a slash-command.\n\n```python\nfrom discord.ext import commands\nfrom dislash import slash_commands\nfrom dislash.interactions import *\n\nclient = commands.Bot(command_prefix=\"!\")\nslash = slash_commands.SlashClient(client)\ntest_guild_ID = 12345\n\n@slash.event\nasync def on_ready():\n    sc = SlashCommand(\n        name=\"random\",\n        description=\"Returns a random number from the given range\",\n        options=[\n            Option(\n                name=\"start\",\n                description=\"Enter a number\",\n                required=True,\n                type=Type.INTEGER\n            ),\n            Option(\n                name=\"end\",\n                description=\"Enter a number\",\n                required=True,\n                type=Type.INTEGER\n            )\n        ]\n    )\n    await slash.register_global_slash_command(sc)\n    # Discord API uploads GLOBAL commands for more than 1 hour\n    # That's why I highly recommend .register_guild_slash_command for testing:\n    await slash.register_guild_slash_command(test_guild_id, sc)\n\nclient.run(\"BOT_TOKEN\")\n```\nYou should register a slash-command only once in order to make it work. You can always edit it if you want, using `.edit_global_slash_command` / `.edit_guild_slash_command` methods.\n\n\n## Responding to a slash-command\n\nIt's assumed that you've already registered the command.\n\n```python\nfrom random import randint\nfrom discord.ext import commands\nfrom dislash import slash_commands\nfrom dislash.interactions import *\n\nclient = commands.Bot(command_prefix=\"!\")\nslash = slash_commands.SlashClient(client)\n\n@slash.command()\nasync def random(interaction):\n    # interaction is instance of `interactions.Interaction`\n    # It's pretty much the same as \"ctx\" from discord.py\n    # except <message> attribute is replaced by <data>\n    a = interaction.data.get('start')\n    b = interaction.data.get('end')\n    if b < a: a, b = b, a\n    await interaction.reply(randint(a, b))\n\nlient.run(\"BOT_TOKEN\")\n```\n\n\n\n# Links\n> **[Documentation](https://dislashpy.readthedocs.io/en/latest)**\n\n> **[PyPi](https://pypi.org/project/dislash.py)**\n\n> **[Our Discord](https://discord.gg/gJDbCw8aQy)**\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A python wrapper for discord slash commands.",
    "version": "0.3.9",
    "split_keywords": [
        "python",
        "discord",
        "slash",
        "commands",
        "api",
        "discord-api",
        "discord-py",
        "slash-commands"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "bc31887095317f23b4784c428ec23d88",
                "sha256": "19ff7f7aee1f52347fea5d26fe623396a22dd5a5d81e91e9fccab8e20cae2eae"
            },
            "downloads": -1,
            "filename": "dislash.py-0.3.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bc31887095317f23b4784c428ec23d88",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6, <4",
            "size": 15865,
            "upload_time": "2021-02-26T08:55:57",
            "upload_time_iso_8601": "2021-02-26T08:55:57.901948Z",
            "url": "https://files.pythonhosted.org/packages/f8/ba/024057b36017df55bd63aa948beea26c75995077a201cdfaf299d0a077e8/dislash.py-0.3.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "7badf13515d4be977ac256fa725a72b9",
                "sha256": "9317ef1a93ab5de254ebd0df17d4748a578b83fbd4b51038d2c44429ac688c79"
            },
            "downloads": -1,
            "filename": "dislash.py-0.3.9.tar.gz",
            "has_sig": false,
            "md5_digest": "7badf13515d4be977ac256fa725a72b9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6, <4",
            "size": 16841,
            "upload_time": "2021-02-26T08:55:59",
            "upload_time_iso_8601": "2021-02-26T08:55:59.270571Z",
            "url": "https://files.pythonhosted.org/packages/32/29/971106a989986a6b4a1863a1227678b871e37e3511a988bc101a6f11394c/dislash.py-0.3.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-02-26 08:55:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "EQUENOS",
    "error": "Could not fetch GitHub repository",
    "lcname": "dislash.py"
}
        
Elapsed time: 0.20956s