55 Commits

Author SHA1 Message Date
Rapptz
446c502995 Change lowercase detection to work with CJK languages
str.islower() does not properly work with characters in the Lo category
so CJK languages fail the check.

Fix #7698
2022-03-15 23:37:54 -04:00
Rapptz
8ced1143e3 Change missing application ID error to be more descriptive 2022-03-15 07:22:44 -04:00
Rapptz
27dd986858 Forbid Choice annotations being used with autocomplete parameters
Since the Choice are synthetic, the library doesn't have a
pre-populated list of choices to know what to use as the resulting
value.
2022-03-15 07:09:41 -04:00
Rapptz
698d1e12a1 Add CommandTree.error decorator to set on_error dynamically 2022-03-15 06:57:25 -04:00
Rapptz
20aa6f866d Fix CommandTree removal and getter overloads 2022-03-15 03:34:04 -04:00
Rapptz
f015b59e43 Add CommandTree.walk_commands and Group.walk_commands 2022-03-15 03:24:20 -04:00
Rapptz
5bc085ebab Properly set root parent before copying a command's binding 2022-03-15 03:24:20 -04:00
Rapptz
aa006f345a Add more special methods to Namespace for ease of use.
* __getattr__ would allow it to no longer AttributeError while
  simultaneously letting linters and type checkers understand that
  this is a bag of dynamic attributes.
* __contains__ allows checking for the existence of an attribute
* __getitem__ allows accessing a value even if its name is not a valid
  Python identifier.
2022-03-14 22:49:47 -04:00
Rapptz
f0a47f5a40 Allow single element Literal in app commands
Fix #7690
2022-03-14 21:17:00 -04:00
Stocker
5aa696ccfa
Fix typing issues and improve typing completeness across the library
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
Co-authored-by: Josh <josh.ja.butt@gmail.com>
2022-03-13 23:52:10 -04:00
Rapptz
5e9097179b Add CommandTree.copy_global_to method for quick development 2022-03-12 21:32:35 -05:00
Rapptz
42beec9fa9 Fix bug when app commands would not have a module attribute set on copy 2022-03-12 20:55:08 -05:00
Rapptz
d63fd578c2 Change TextChannel annotation channel_types to include news channels 2022-03-12 20:51:32 -05:00
Rapptz
6def5c9131 Allow specifying float default values for app commands 2022-03-12 09:41:28 -05:00
Rapptz
1d1bba1f90 Support app_commands.guilds decorator for context menu commands 2022-03-12 09:28:46 -05:00
Rapptz
0ef369c0fa [commands] Automatically unload top level app commands in extensions 2022-03-12 09:24:26 -05:00
Rapptz
a672455ca9 Fix some context menu commands not being registered in guild contexts
This happened when there weren't any application commands due to a typo
stemming from a copy paste error.

Fixes #7650
2022-03-12 08:39:57 -05:00
Rapptz
9fd63ad7f3 Fix Optional type hints not respecting explicitly set defaults 2022-03-12 02:03:17 -05:00
Rapptz
333849e5a3 Unbind bound methods passed to Command constructor
Fixes #7600
2022-03-11 10:26:16 -05:00
Rapptz
140a827190 Fix default guilds for commands not being respected
Pesky little typo

Fix #7641
2022-03-11 08:33:37 -05:00
Rapptz
740c156cd8 Allow Optional transformers to work at runtime 2022-03-11 08:06:11 -05:00
Rapptz
bbf7a7981b Ensure all choices are the same type as the parameter type
Fixes #7625
2022-03-11 07:29:11 -05:00
Rapptz
377561844d Raise an error if a child command has default guilds set 2022-03-11 07:18:34 -05:00
Rapptz
f54c4ca54e Validate application command names 2022-03-11 06:40:28 -05:00
Rapptz
26c6b4d449 Use new differentiator for guild and global commands
Fixes #7602
2022-03-10 20:10:49 -05:00
Rapptz
02fcc814e1 Allow passing guild_ids in constructors of Command and Group
Fixes #7626
2022-03-10 19:31:27 -05:00
Rapptz
f6453d9439 Fix free functions being passed a binding in autocomplete callbacks
Fix #7624
2022-03-10 19:26:00 -05:00
Arthur
8502978649
Check the global scope when dispatching context menus 2022-03-10 18:51:14 -05:00
Rapptz
a6ae7ec196 Raise error if two trees are registered to the same connection state 2022-03-09 20:35:07 -05:00
Rapptz
446bfa78b0 [commands] Allow Cog and app_commands interopability
This changeset allows app commands defined inside Cog to work as
expected. Likewise, by deriving app_commands.Group and Cog you can
make the cog function as a top level command on Discord.
2022-03-09 20:26:54 -05:00
Rapptz
5741ad9368 Change default guild IDs attribute to persist on copy 2022-03-09 20:26:54 -05:00
Rapptz
0d126c594c Use descriptor protocol to obtain attribute name instead of a dict 2022-03-09 20:26:54 -05:00
Rapptz
303d33bb08 Support Group with app_commands.guilds decorator 2022-03-09 20:26:54 -05:00
Rapptz
9d27855755 Update attributes of instantiated Group to point to the Command copy 2022-03-09 20:26:54 -05:00
Rapptz
25b4bc277b Add app_commands.guilds to set the guilds of a command in another way
This is mostly preparation for interopability with commands.Cog as this
would allow authors to specify the guilds for their cog defined
commands.
2022-03-08 00:48:24 -05:00
Rapptz
5fb1b933cf Add Group.commands property 2022-03-08 00:07:39 -05:00
Rapptz
e6a87e0782 Add support for adding app commands locally to many guilds
This affects the context_menu and command decorators as well. Removing
and syncing do not support multiple guild IDs.
2022-03-07 21:52:58 -05:00
Steve C
65a1c1014b
Fix TypeError in Range transformer from None value 2022-03-07 17:39:37 -05:00
HigherOrderLogic
4ad6146069
Fix doc typo in Group docstring 2022-03-07 17:36:38 -05:00
Stocker
2eec900e98
Add the Command.callback and ContextMenu.callback properties 2022-03-06 23:02:44 -05:00
Steve C
8bbeee3464
Expose app_commands.autocomplete 2022-03-06 19:04:05 -05:00
Rapptz
13e102b6b9 Add default parameter to CommandTree.sync
I'm not sure how I feel about this, since explicitly passing
guild=None seems better.
2022-03-05 22:02:33 -05:00
Rapptz
7ac4f3007b Fix missing type imports in context menu verification 2022-03-05 21:43:14 -05:00
Rapptz
5c9605fc1b Fix Message context menus not working 2022-03-05 21:15:49 -05:00
Rapptz
aa74238053 Reorganise documentation for interactions 2022-03-04 21:17:27 -05:00
Rapptz
f435d160dd Add Interaction.client property 2022-03-01 08:11:22 -05:00
Rapptz
6110fe5b1c Add fallback overloads for CommandTree 2022-03-01 07:54:14 -05:00
Rapptz
ae1aaac5a7 Add support for autocomplete 2022-03-01 05:42:44 -05:00
Rapptz
4e04dbdec7 Add support for choice option parameters
This implements it in three different ways:

* The first is using typing.Literal for quick and easy ones
* The second is using enum.Enum for slightly more complex ones
* The last is using a Choice type hint with a decorator to pass
  a list of choices.

This should hopefully cover most use cases.
2022-03-01 05:42:44 -05:00
Rapptz
e5e5b61ad0 Add support for range validation in options 2022-03-01 05:42:44 -05:00