UI

This is the most important part in this libary, because this class has most of the features you need.

Note

In this documentation, Components and Slash are initalized and accesable by ui.slash and ui.components attributes

UI

class discord_ui.UI(client, override_dpy=True, slash_options={'auto_sync': True, 'parse_method': 4, 'sync_on_cog': True, 'wait_sync': 1}, auto_defer=False)

The main extension for the package to use slash commands and message components

client: discord.ext.commands.Bot

The discord bot client

override_dpy: bool
Whether some of discord.py’s default methods should be overriden with this libary’s; Default True

For more information see https://github.com/discord-py-ui/discord-ui/blob/main/discord_ui/override.py

slash_options: dict, optional

Settings for the slash command part; Default {parse_method: ParseMethod.AUTO, wait_sync: 1}

parse_method: int, optional

How the received interaction argument data should be treated; Default ParseMethod.AUTO

auto_sync: bool, optional

Whether the libary should sync the slash commands automatically; Default True

sync_on_cog: bool, optional

Whether the slashcommands should be updated whenever a new cog is added or removed; Default True

wait_sync: float, optional

How many seconds will be waited until the commands are going to be synchronized; Default 1

auto_defer: Tuple[bool, bool]

Settings for the auto-defer; Default (True, False)

[0]: Whether interactions should be deferred automatically

[1]: Whether the deferration should be hidden (True) or public (False)

components: discord_ui.client.Components

For using message components

slash: discord_ui.client.Slash

For using slash commands

Parse-Methods

class discord_ui.ParseMethod

Methods of how the interaction argument data should be treated

  • RAW [0]

    Returns the raw value which was received

  • RESOLVE [1]

    Uses the resolved data which will be delivered together with the received interaction

  • FETCH [2]

    Fetches all the ids of the received data with an api call

  • CACHE [3]

    Uses the internal bot cache to get the data

Warning

The cache method uses the .get_guild, .get_channel… methods, which needs to have some intents enabled (more information)

  • AUTO [4]

    This will try all methods beginning (RESOLVE, FETCH, CACHE, RAW) and changes to the next method whenever an exception occurs