Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

Latest commit

 

History

History
67 lines (38 loc) · 1.32 KB

checks.rst

File metadata and controls

67 lines (38 loc) · 1.32 KB
.. currentmodule:: dislash


Slash command checks

Introduction

This section contains documentation of decorator-based checks that dislash.py has.

Here's a possible use case:

import dislash
from discord.ext import commands

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

@inter_client.slash_command(description="A command for admins")
@dislash.has_permissions(administrator=True)
async def hello(inter):
    await inter.reply("Hello, administrator!")

bot.run("BOT_TOKEN")

If you want to respond with something like "You're missing permissions!", you should add an error handler using on_slash_command_error(inter, error) event, learn more about it here: :ref:`on_slash_command_error`

Checks

.. autofunction:: check

.. autofunction:: check_any

.. autofunction:: cooldown

.. autofunction:: has_role

.. autofunction:: has_any_role

.. autofunction:: has_permissions

.. autofunction:: has_guild_permissions

.. autofunction:: dm_only

.. autofunction:: guild_only

.. autofunction:: is_owner

.. autofunction:: is_nsfw

.. autofunction:: bot_has_role

.. autofunction:: bot_has_any_role

.. autofunction:: bot_has_permissions

.. autofunction:: bot_has_guild_permissions