ncdis


Namencdis JSON
Version 1.7.0 PyPI version JSON
download
home_pagehttps://github.com/EQUENOS/dislash.py
SummaryA python wrapper for message components and application commands.
upload_time2022-12-01 14:04:13
maintainer
docs_urlNone
authorEQUENOS
requires_python>=3.6, <4
licenseMIT
keywords python discord slash commands api discord-api discord-py slash-commands message-components buttons select-menus context-menus
VCS
bugtrack_url
requirements discord.py
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Warning

This library is no longer maintained in favor of **[disnake](https://github.com/DisnakeDev/disnake)**. Disnake is an updated version of discord.py with the latest API features implemented. The syntax for slash commands is very convenient so we really recommend using disnake if you're planning to switch to slash commands before April 2022.

If you have any questions, join [Our Discord Server](https://discord.gg/gJDbCw8aQy)


<img src="https://cdn.discordapp.com/attachments/808032994668576829/813135069661102110/dislash_emb_crop.png" align="left" width="50" title="dislash.py">
<h1>dislash.py</h1>


[![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 message components and slash commands.


# Note about the future of discord.py

Since discord.py will no longer stay up to date, we decided to create a fork: **[disnake](https://github.com/DisnakeDev/disnake)**. It has all features of dpy 2.0 + application commands.

* [GitHub repo](https://github.com/EQUENOS/disnake)
* [Discord server](https://discord.gg/gJDbCw8aQy)


# Table Of Contents

1. [Installation](#installation)
2. [Features](#features)
3. [Examples](#examples)
4. [Creating a slash command](#creating-a-slash-command)
5. [Creating Buttons](#creating-buttons)
6. [Creating Menus](#creating-menus)
7. [Creating context menus](#creating-context-menus)
8. [Links](#links)
9. [Downloads](#downloads)


# 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
* Works with discord.py <=1.7.3, >=2.0.0a



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


## Creating a slash command

```python
from discord.ext import commands
from dislash import InteractionClient

bot = commands.Bot(command_prefix="!")
inter_client = InteractionClient(bot, test_guilds=[12345, 98765])
# If 'test_guilds' param isn't specified, the commands are registered globally.
# Global registration takes up to 1 hour.

@inter_client.slash_command(
    name="hello", # Defaults to the function name
    description="Says hello",
    guild_ids=test_guilds
)
async def hello(inter):
    await inter.reply("Hello!")

bot.run("BOT_TOKEN")
```


## Creating buttons

This example shows how to send a message with buttons.

```python
from discord.ext import commands
from dislash import InteractionClient, ActionRow, Button, ButtonStyle

bot = commands.Bot(command_prefix="!")
inter_client = InteractionClient(bot)

@bot.command()
async def test(ctx):
    # Make a row of buttons
    row_of_buttons = ActionRow(
        Button(
            style=ButtonStyle.green,
            label="Green button",
            custom_id="green"
        ),
        Button(
            style=ButtonStyle.red,
            label="Red button",
            custom_id="red"
        )
    )
    # Send a message with buttons
    msg = await ctx.send(
        "This message has buttons!",
        components=[row_of_buttons]
    )
    # Wait for someone to click on them
    def check(inter):
        return inter.message.id == msg.id
    inter = await ctx.wait_for_button_click(check)
    # Send what you received
    button_text = inter.clicked_button.label
    await inter.reply(f"Button: {button_text}")

bot.run("BOT_TOKEN")
```


## Creating menus

This example shows how to send a message with a menu.

```python
from discord.ext import commands
from dislash import InteractionClient, SelectMenu, SelectOption

bot = commands.Bot(command_prefix="!")
inter_client = InteractionClient(bot)

@bot.command()
async def test(ctx):
    msg = await ctx.send(
        "This message has a select menu!",
        components=[
            SelectMenu(
                custom_id="test",
                placeholder="Choose up to 2 options",
                max_values=2,
                options=[
                    SelectOption("Option 1", "value 1"),
                    SelectOption("Option 2", "value 2"),
                    SelectOption("Option 3", "value 3")
                ]
            )
        ]
    )
    # Wait for someone to click on it
    inter = await msg.wait_for_dropdown()
    # Send what you received
    labels = [option.label for option in inter.select_menu.selected_options]
    await inter.reply(f"Options: {', '.join(labels)}")

bot.run("BOT_TOKEN")
```


## Creating context menus

This example shows how to create context menus and interact with them.

```python
from discord.ext import commands
from dislash import InteractionClient

bot = commands.Bot(command_prefix="!")
inter_client = InteractionClient(bot)

@inter_client.user_command(name="Press me")
async def press_me(inter):
    # User commands are visible in user context menus
    # They can be global or per guild, just like slash commands
    await inter.respond("Hello there!")

@inter_client.message_command(name="Resend")
async def resend(inter):
    # Message commands are visible in message context menus
    # inter is instance of ContextMenuInteraction
    await inter.respond(inter.message.content)

bot.run("BOT_TOKEN")
```



# Links
- **[Documentation](https://dislashpy.readthedocs.io/en/latest)**
- **[PyPi](https://pypi.org/project/dislash.py)**
- **[Our Discord](https://discord.gg/gJDbCw8aQy)**


# Downloads


[![Downloads](https://pepy.tech/badge/dislash.py)](https://pepy.tech/project/dislash.py)
[![Downloads](https://pepy.tech/badge/dislash.py/month)](https://pepy.tech/project/dislash.py)
![Downloads](https://pepy.tech/badge/dislash.py/week)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/EQUENOS/dislash.py",
    "name": "ncdis",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6, <4",
    "maintainer_email": "",
    "keywords": "python,discord,slash,commands,api,discord-api,discord-py,slash-commands,message-components,buttons,select-menus,context-menus",
    "author": "EQUENOS",
    "author_email": "equenos1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/40/5c3aa0d26a59980a5699f895607936ca32046c437e7490c3f7c11c5788b9/ncdis-1.7.0.tar.gz",
    "platform": null,
    "description": "# Warning\n\nThis library is no longer maintained in favor of **[disnake](https://github.com/DisnakeDev/disnake)**. Disnake is an updated version of discord.py with the latest API features implemented. The syntax for slash commands is very convenient so we really recommend using disnake if you're planning to switch to slash commands before April 2022.\n\nIf you have any questions, join [Our Discord Server](https://discord.gg/gJDbCw8aQy)\n\n\n<img src=\"https://cdn.discordapp.com/attachments/808032994668576829/813135069661102110/dislash_emb_crop.png\" align=\"left\" width=\"50\" title=\"dislash.py\">\n<h1>dislash.py</h1>\n\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 message components and slash commands.\n\n\n# Note about the future of discord.py\n\nSince discord.py will no longer stay up to date, we decided to create a fork: **[disnake](https://github.com/DisnakeDev/disnake)**. It has all features of dpy 2.0 + application commands.\n\n* [GitHub repo](https://github.com/EQUENOS/disnake)\n* [Discord server](https://discord.gg/gJDbCw8aQy)\n\n\n# Table Of Contents\n\n1. [Installation](#installation)\n2. [Features](#features)\n3. [Examples](#examples)\n4. [Creating a slash command](#creating-a-slash-command)\n5. [Creating Buttons](#creating-buttons)\n6. [Creating Menus](#creating-menus)\n7. [Creating context menus](#creating-context-menus)\n8. [Links](#links)\n9. [Downloads](#downloads)\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* Works with discord.py <=1.7.3, >=2.0.0a\n\n\n\n# Examples\n\ud83d\udca1 This library requires **[discord.py](https://github.com/Rapptz/discord.py)**.\n\n\n## Creating a slash command\n\n```python\nfrom discord.ext import commands\nfrom dislash import InteractionClient\n\nbot = commands.Bot(command_prefix=\"!\")\ninter_client = InteractionClient(bot, test_guilds=[12345, 98765])\n# If 'test_guilds' param isn't specified, the commands are registered globally.\n# Global registration takes up to 1 hour.\n\n@inter_client.slash_command(\n    name=\"hello\", # Defaults to the function name\n    description=\"Says hello\",\n    guild_ids=test_guilds\n)\nasync def hello(inter):\n    await inter.reply(\"Hello!\")\n\nbot.run(\"BOT_TOKEN\")\n```\n\n\n## Creating buttons\n\nThis example shows how to send a message with buttons.\n\n```python\nfrom discord.ext import commands\nfrom dislash import InteractionClient, ActionRow, Button, ButtonStyle\n\nbot = commands.Bot(command_prefix=\"!\")\ninter_client = InteractionClient(bot)\n\n@bot.command()\nasync def test(ctx):\n    # Make a row of buttons\n    row_of_buttons = ActionRow(\n        Button(\n            style=ButtonStyle.green,\n            label=\"Green button\",\n            custom_id=\"green\"\n        ),\n        Button(\n            style=ButtonStyle.red,\n            label=\"Red button\",\n            custom_id=\"red\"\n        )\n    )\n    # Send a message with buttons\n    msg = await ctx.send(\n        \"This message has buttons!\",\n        components=[row_of_buttons]\n    )\n    # Wait for someone to click on them\n    def check(inter):\n        return inter.message.id == msg.id\n    inter = await ctx.wait_for_button_click(check)\n    # Send what you received\n    button_text = inter.clicked_button.label\n    await inter.reply(f\"Button: {button_text}\")\n\nbot.run(\"BOT_TOKEN\")\n```\n\n\n## Creating menus\n\nThis example shows how to send a message with a menu.\n\n```python\nfrom discord.ext import commands\nfrom dislash import InteractionClient, SelectMenu, SelectOption\n\nbot = commands.Bot(command_prefix=\"!\")\ninter_client = InteractionClient(bot)\n\n@bot.command()\nasync def test(ctx):\n    msg = await ctx.send(\n        \"This message has a select menu!\",\n        components=[\n            SelectMenu(\n                custom_id=\"test\",\n                placeholder=\"Choose up to 2 options\",\n                max_values=2,\n                options=[\n                    SelectOption(\"Option 1\", \"value 1\"),\n                    SelectOption(\"Option 2\", \"value 2\"),\n                    SelectOption(\"Option 3\", \"value 3\")\n                ]\n            )\n        ]\n    )\n    # Wait for someone to click on it\n    inter = await msg.wait_for_dropdown()\n    # Send what you received\n    labels = [option.label for option in inter.select_menu.selected_options]\n    await inter.reply(f\"Options: {', '.join(labels)}\")\n\nbot.run(\"BOT_TOKEN\")\n```\n\n\n## Creating context menus\n\nThis example shows how to create context menus and interact with them.\n\n```python\nfrom discord.ext import commands\nfrom dislash import InteractionClient\n\nbot = commands.Bot(command_prefix=\"!\")\ninter_client = InteractionClient(bot)\n\n@inter_client.user_command(name=\"Press me\")\nasync def press_me(inter):\n    # User commands are visible in user context menus\n    # They can be global or per guild, just like slash commands\n    await inter.respond(\"Hello there!\")\n\n@inter_client.message_command(name=\"Resend\")\nasync def resend(inter):\n    # Message commands are visible in message context menus\n    # inter is instance of ContextMenuInteraction\n    await inter.respond(inter.message.content)\n\nbot.run(\"BOT_TOKEN\")\n```\n\n\n\n# Links\n- **[Documentation](https://dislashpy.readthedocs.io/en/latest)**\n- **[PyPi](https://pypi.org/project/dislash.py)**\n- **[Our Discord](https://discord.gg/gJDbCw8aQy)**\n\n\n# Downloads\n\n\n[![Downloads](https://pepy.tech/badge/dislash.py)](https://pepy.tech/project/dislash.py)\n[![Downloads](https://pepy.tech/badge/dislash.py/month)](https://pepy.tech/project/dislash.py)\n![Downloads](https://pepy.tech/badge/dislash.py/week)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python wrapper for message components and application commands.",
    "version": "1.7.0",
    "split_keywords": [
        "python",
        "discord",
        "slash",
        "commands",
        "api",
        "discord-api",
        "discord-py",
        "slash-commands",
        "message-components",
        "buttons",
        "select-menus",
        "context-menus"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "0947e19f74615ac52337e4760e605f5f",
                "sha256": "d81327e6e6eb058ff3f631c30e05aa152578dc0252ac3fa39c90501931ca0b19"
            },
            "downloads": -1,
            "filename": "ncdis-1.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0947e19f74615ac52337e4760e605f5f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6, <4",
            "size": 46402,
            "upload_time": "2022-12-01T14:04:13",
            "upload_time_iso_8601": "2022-12-01T14:04:13.315329Z",
            "url": "https://files.pythonhosted.org/packages/9d/40/5c3aa0d26a59980a5699f895607936ca32046c437e7490c3f7c11c5788b9/ncdis-1.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-01 14:04:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "EQUENOS",
    "github_project": "dislash.py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "discord.py",
            "specs": []
        }
    ],
    "lcname": "ncdis"
}
        
Elapsed time: 0.09944s