Commit Graph
100 Commits
Author SHA1 Message Date
Rapptz 2b3cc8fe10 Add Member.display_icon to get the rendered member icon 2022-04-18 17:26:30 -04:00
Rapptz 80aa45ed31 [commands] Skip ws before processing arguments in Greedy transformer 2022-04-15 03:21:36 -04:00
Rapptz 4fb1309e2a [commands] Mock interaction context prefix
Most user-level code probably expects the prefix to be valid and not
None, so mocking it to ensure it's at least a string is probably for
the best.
2022-04-14 19:12:16 -04:00
Rapptz 9ff90d7863 Copy internal attributes for command decorator state
This allows for copies to not clear the state the decorators had
set prior.
2022-04-14 17:45:27 -04:00
Rapptz e541be0427 Fix tests from failing 2022-04-14 06:46:33 -04:00
Rapptz bc07a02f68 [commands] Fix type hints for hybrid command decorators 2022-04-14 05:14:48 -04:00
Rapptz 4951231a7c Remove command parameter from Group.on_error callback
Similar to the CommandTree.on_error removal, this one can be retrieved
using Interaction.command
2022-04-13 22:45:06 -04:00
Rapptz ce15df4275 [commands] Allow commands.Range inside typing.Union or typing.Optional 2022-04-13 22:43:11 -04:00
Rapptz cdf442bc32 Fix signature detection in CommandTree.error decorator 2022-04-13 22:30:39 -04:00
Rapptz 3f4fb91328 Change CommandTree.on_error to only take two parameters
The command that failed can be retrieved using Interaction.command
so having it as a parameter doesn't make much sense.
2022-04-13 22:29:27 -04:00
Rapptz 83fae4f0fa Add CommandTree.clear_commands 2022-04-13 22:20:05 -04:00
Rapptz 8a1800bd12 [commands] Add support for setting a fallback slash subcommand
This allows the group callback to be invoked as a slash subcommand
2022-04-13 20:30:11 -04:00
Rapptz e9ff6b4be8 [commands] Fix broken documentation references 2022-04-13 18:49:39 -04:00
Rapptz 5c61f2af48 [commands] Add ForumChannelConverter to the converter mapping 2022-04-13 17:45:54 -04:00
Rapptz 141d9f4c71 [commands] Add ForumChannelConverter converter 2022-04-13 17:44:03 -04:00
Rapptz d98ee567d4 Add Guild.forums property
Ran an informal poll in the official server and this name won over the
alternative Guild.forum_channels property name
2022-04-13 17:40:16 -04:00
Rapptz 7a52aa3764 [commands] Force HybridGroup to always have invoke_without_command 2022-04-13 17:14:21 -04:00
Rapptz 49f330b4a3 Fix Thread.jump_url docstring 2022-04-13 17:12:44 -04:00
Rapptz b476757720 [commands] Fix type hints for checks, hooks, and error handlers 2022-04-13 03:07:58 -04:00
Rapptz 737ff5beaf Update Pyright to 1.1.237 2022-04-13 02:30:00 -04:00
Rapptz 242d3f7ab7 [commands] Add Bot.hybrid_group and Bot.hybrid_command decorators 2022-04-12 21:17:00 -04:00
Rapptz daa32e3463 Use pyright CI action and remove --verbose from black 2022-04-12 20:51:02 -04:00
Rapptz 1931b0eb75 [commands] Ensure hybrid app command receives copied wrapper command 2022-04-12 20:15:11 -04:00
Rapptz 393fdde037 [commands] Add support for Greedy for hybrid commands 2022-04-12 20:15:11 -04:00
Rapptz 1004cf2059 [commands] Unconditionally replace default if it's set
Handles degenerate `x: int = commands.param(default=10)` case
2022-04-12 20:15:11 -04:00
Rapptz 70d2522e7e [commands] Unwrap CommandInvokeError if the cause is CommandError 2022-04-12 20:15:11 -04:00
Rapptz 3bb4d3bd6d Allow internal library enums to be used as an annotation 2022-04-12 20:15:11 -04:00
Rapptz 65418414ea [commands] Refactor parameter replacement to be less brittle
If a parameter works as-is as a transformer or a built-in then it
will always be taken rather. This way, the custom behaviour is done
as a fallback in case it doesn't work natively with app commands.

This also allows things that are hybrid transformers and converters
to work transparently.
2022-04-12 20:15:11 -04:00
Rapptz 896932faf1 [commands] Add Range converter
This allows hybrid commands to also have a range annotation
2022-04-12 20:15:11 -04:00
Rapptz 3c4b22b623 [commands] Fix transformers no longer working as annotation 2022-04-12 20:15:10 -04:00
Rapptz 9d05f55ddb [commands] Fix Optional handling when the inner type is a converter 2022-04-12 20:15:10 -04:00
Rapptz f072edfdfc [commands] Properly support commands.param in hybrid commands 2022-04-12 20:15:10 -04:00
Rapptz fa3a4c109b [commands] Fix Context.reply not working for hybrid commands 2022-04-12 20:15:10 -04:00
Rapptz d61561f2e8 [commands] Add support for autocomplete for hybrid commands 2022-04-12 20:15:10 -04:00
Rapptz 52fcaed79b [commands] Reassign app_command attribute on copy
Prior to this change it would re-create the HybridAppCommand on copy
which had the consequence of clearing parameter related changes.
2022-04-12 20:15:10 -04:00
Rapptz 1232a1d2fd [commands] Properly call after_hooks in hybrid commands 2022-04-12 20:15:10 -04:00
Rapptz c1892131a6 [commands] Fix Context docstring missing Interaction ref 2022-04-12 20:15:10 -04:00
Rapptz 840eb577d4 [commands] Add initial implementation of hybrid commands
Hybrid commands allow a regular command to also double as a slash
command, assuming it meets the subset required to function.
2022-04-12 20:15:10 -04:00
Rapptz c568ed8cdc Pin Pyright to 1.1.235 2022-04-10 22:49:30 -04:00
Rapptz 29d4c26466 Upgrade WebhookMessage.channel to Thread if available 2022-04-10 18:15:02 -04:00
Rapptz 538ba0d076 Update Webhook.channel typing to include VoiceChannel as well 2022-04-10 18:11:44 -04:00
Rapptz c284145f18 Add and remove some versionadded directives 2022-04-10 17:12:56 -04:00
Rapptz 6a49dfcc0f Fix crash with WEBHOOKS_UPDATE channel_id being nullable 2022-04-10 03:47:03 -04:00
Rapptz 30cc00c9a4 Explicitly specify public threads when creating them in forums
The endpoint seems to fail otherwise
2022-04-06 23:27:27 -04:00
Rapptz a8b26b9257 Allow pinning a thread using Thread.edit 2022-04-06 23:21:17 -04:00
Rapptz 92eb9d7d8e Fix documentation for ChannelFlags.pinned 2022-04-06 23:06:58 -04:00
Rapptz 67a58d10ae Change Fetch -> Retrieve for last_message documentation 2022-04-06 23:02:58 -04:00
Rapptz 23f6876492 Add initial support for forum channels
Closes #7652
2022-04-06 23:02:58 -04:00
Rapptz f07885973f Provide callback name where applicable in validation
Fix #7850
2022-04-06 08:57:04 -04:00
Rapptz abeea73734 Fix remaining things not explicitly passing the intents kwarg 2022-04-05 23:15:40 -04:00
Rapptz b32b78de45 [commands] Fix missing or inferred type hints in parameters.py 2022-04-05 22:47:21 -04:00
Rapptz 76cc2c2272 Require passing intents to Client and its subclasses 2022-04-05 22:32:14 -04:00
Rapptz c68ea67213 Properly handle inheritance overriding in View subclasses 2022-04-05 09:41:48 -04:00
Rapptz 629f36e7d7 [commands] Add fallback behaviour to the default parameter instances
This allows users to explicitly override the default annotation for
CurrentAuthor and CurrentChannel since they're wider than what most
users would expect
2022-04-05 06:40:31 -04:00
Rapptz f15f601779 [commands] Check if an application command starts with bot_ or cog_ 2022-04-05 06:06:35 -04:00
Rapptz b823a4bab1 [commands] Only update annotation if an explicit override is given 2022-04-05 06:02:28 -04:00
Rapptz c582940401 Remove ancient IDENTIFY key that is no longer used 2022-04-05 05:22:00 -04:00
Rapptz dbcdf69eb1 [commands] Raise appropriate exception for no guild found 2022-04-04 21:49:11 -04:00
Rapptz 8b50ac8a31 [commands] Don't set a converter for the defaults provided 2022-04-04 21:47:03 -04:00
Rapptz 66155faf00 [commands] Fix documentation not being properly formatted 2022-04-04 18:10:43 -04:00
Rapptz b561024163 Fix WebhookState not handling reaction emoji
Fix #7842
2022-04-04 00:49:36 -04:00
Rapptz 907d5e0ee7 Document Forbidden exception in CommandTree.sync 2022-04-03 22:57:54 -04:00
Rapptz 1458251736 Change View.children to be a property
This allows users to call remove_item in a loop. Likewise, it prevents
the footgun of doing children.append(...) which does not uphold the
invariants with the weight system.
2022-04-03 20:13:42 -04:00
Rapptz 58db635229 Fix parameter validation in Guild.query_members 2022-04-03 08:07:01 -04:00
Rapptz 3ef8f77e81 Add proper nsfw support for vocal guild channels 2022-04-03 07:50:10 -04:00
Rapptz 298bd7492c Run pyright as part of the CI process
This doesn't do verifytypes yet due to a bug in Pyright
2022-04-02 11:47:34 -04:00
Rapptz 52e16573f5 Remove unused imports and make exports explicit
This allows Pyright to actually catch these errors, which would be
useful for CI purposes in the future.
2022-04-02 11:38:39 -04:00
Rapptz f7a79ff8d7 Avoid calling PartialMessage.__init__ in Message.__init__
This prevents Message creation from crashing due to the public
interface's type checks potentially breaking future compatibility.
2022-04-02 11:15:54 -04:00
Rapptz 2aca705b95 Add support for sending messages and managing webhooks in VoiceChannel 2022-04-02 11:14:03 -04:00
Rapptz b049cf77f2 Add reason to Thread.delete_messages and Thread.purge 2022-04-02 10:36:39 -04:00
Rapptz 994660faad [commands] Fix unknown generic type in tree_cls 2022-04-02 05:53:33 -04:00
Rapptz 7696342d76 Add missing __slots__ to MessageInteraction 2022-04-02 01:24:56 -04:00
Rapptz 5c14149873 Fix filename spoiler stripping method
lstrip does not work as expected
2022-04-01 15:25:03 -04:00
Rapptz f47568ee71 Document Guild.bans breaking change in the migrating guide 2022-04-01 11:47:27 -04:00
Rapptz e79895d824 Add Message.interaction and MessageInteraction type
Fix #7819
2022-04-01 11:15:15 -04:00
Rapptz a5f1c2f592 Take into consideration member timeouts in permission calculations 2022-04-01 09:32:54 -04:00
Rapptz 25ad5b675c Ensure explicitly set parents on nested groups are respected
This had a multiple layer bug that needed to be squashed. The first
issue was that setting `parent=...` inside a `Group` wouldn't actually
add the `Group` into the `parent` children mapping. This meant that
it didn't actually end up copying the children when it came time to
within e.g. a Cog.

The second issue was that even if it was added into the children
listing, it wouldn't properly set the attribute.

This commit fixes both of these issues.

Fix #7818
2022-04-01 09:13:27 -04:00
Rapptz c671308211 Validate app command parameter renames 2022-04-01 07:02:37 -04:00
Rapptz 6986733833 Revert "Validate Option names similar to slash command names"
This reverts commit 6ef2043b10.
2022-04-01 06:58:11 -04:00
Rapptz ca9fd355e8 Fix typo in Guild.bans docstring 2022-04-01 00:26:33 -04:00
Rapptz 9acf1db076 Support ban endpoint pagination 2022-04-01 00:09:02 -04:00
Rapptz 6ef2043b10 Validate Option names similar to slash command names 2022-04-01 00:09:02 -04:00
Rapptz 5096846c4e Allow None to be passed for Member.timeout 2022-04-01 00:09:02 -04:00
Rapptz 24f8f8d4a7 Rename MaxCommandsReached to CommandLimitReached 2022-03-31 23:10:13 -04:00
Rapptz a0618ef791 Clarify documentation certain tree methods 2022-03-31 10:31:48 -04:00
Rapptz 34b2ff40b6 Change ValueError on max commands reached to a more specific exception 2022-03-31 09:34:48 -04:00
Rapptz 705c79df59 Remove second mapping used for parameter rename lookup
Just keying into param.display_name should be enough
2022-03-31 08:58:53 -04:00
Rapptz dfc92c223c Fix application commands not always sending the proper parameter name 2022-03-31 08:55:20 -04:00
Rapptz 170ab7b2bb Improve error when an invalid slash command name is given 2022-03-31 04:12:09 -04:00
Rapptz 29668c51ae [commands] Revert back to older help command implementation
The newer implementation did not play nicely with spawned tasks and
accessing HelpCommand.context, which was a frequent pain point when
writing paginated help commands.
2022-03-31 02:46:42 -04:00
Rapptz b4fbb08818 Allow runtime modification of timeout expiry at runtime
This is done through setting View.timeout while it's running
2022-03-31 01:54:13 -04:00
Rapptz ff24c5229e Add iterator special method for Namespace
Fix #7812
2022-03-30 21:45:30 -04:00
Rapptz b1fb5ed3d7 Fix autocomplete not working with renamed parameters
Fix #7810
2022-03-30 19:46:27 -04:00
Rapptz e515378076 Remove annotation on row property in subclasses 2022-03-29 23:04:34 -04:00
Rapptz 3215cb65e2 Raise if custom_id is not a str 2022-03-29 23:04:34 -04:00
Rapptz b7b992375d Add examples for new cooldown checks 2022-03-29 06:02:41 -04:00
Rapptz 9f83eb6032 Add application command cooldown decorators
Fix #7790
2022-03-29 00:46:42 -04:00
Rapptz 74b5e0ceb1 Implement some built in checks for app_commands
A lot of these implementations are adapted from the equivalent
ext.commands checks. These only implement the common ones that could
not solely be done by Discord in the future.
2022-03-28 16:36:29 -04:00
Rapptz def035bf9a Remove StoreChannel and any references to it 2022-03-28 00:09:19 -04:00
Rapptz 0a7eb6b021 Only verify if context menus pass a length check
According to Discord this is the check that is actually done
2022-03-27 23:32:36 -04:00