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, 'delete_unused': False, '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
- Whether some of discord.py’s default methods should be overriden with this libary’s; Default
- slash_options:
dict, optional Settings for the slash command part; Default {parse_method: ParseMethod.AUTO, delete_unused: False, wait_sync: 1}
parse_method:int, optionalHow the received interaction argument data should be treated; Default
ParseMethod.AUTOauto_sync:bool, optionalWhether the libary should sync the slash commands automatically; Default
Truedelete_unused:bool, optionalWhether the commands that are not registered by this slash ui should be deleted in the api; Default
Falsesync_on_cog:bool, optionalWhether the slashcommands should be updated whenever a new cog is added or removed; Default
Truewait_sync:float, optionalHow 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
- client:
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