Commit Graph
100 Commits
Author SHA1 Message Date
Rapptz 4dd5cc2bc9 Pass proxy information to interactions and webhooks
Fix #7918
2022-05-05 12:07:09 -04:00
Rapptz 1df3ed861c Fix broken HTTPClient.recreate code to actually clear session 2022-05-05 11:42:50 -04:00
Rapptz 0502c6a0d2 Fix two styling nits with fmt: off 2022-05-05 11:35:26 -04:00
Rapptz fbd57ffa58 Add FAQ entry for disabling all items in a View on timeout 2022-05-05 08:52:24 -04:00
Rapptz 2bfbd1a979 Prefer code-block directive over :: in faq.rst 2022-05-05 08:52:24 -04:00
Rapptz 9793fba338 [commands] Add support for discord.Attachment converters 2022-05-05 01:54:59 -04:00
Rapptz d8846570ae Remove unnecessary type ignore
Despite this except branch is no longer guarded, the exceptional
case could still happen if an Object is passed or if a future channel
type leads to breakage
2022-05-05 01:46:19 -04:00
Rapptz ccc737eb07 [commands] Add support for with_app_command in hybrid commands
This allows the user to make a text-only command without it registering
as an application command
2022-05-05 01:46:19 -04:00
Rapptz b9b6dc960f Add aiohttp[speedups] dependencies to discord.py[speed] 2022-05-04 07:09:45 -04:00
Rapptz d56f5150fa Fix oversight of edit parameters not being keyword only 2022-05-04 05:02:42 -04:00
Rapptz 4733a499a5 Fix documentation build for Client.get_partial_messageable 2022-05-03 11:02:12 -04:00
Rapptz b7ac0a02ca Fix documentation of PartialMessageable.jump_url 2022-05-03 10:57:51 -04:00
Rapptz c22b6dc2cd Add guild property to DMChannel, GroupChannel, and PartialMessageable
This improves generic duck typing programming by allowing narrowing
the types by just checking for a None guild attribute.
2022-05-03 10:55:29 -04:00
Rapptz 8699d2139a Improve generic duck type programming with PartialMessageable
This adds jump_url, permissions_for, and created_at. Luckily, most
cases of this type being constructed already have the guild_id at
creation time.
2022-05-03 10:49:52 -04:00
Rapptz eee65ac39b [commands] Pass permissions v2 information to HybridGroup 2022-05-02 19:08:25 -04:00
Rapptz 79d34fbe78 Change Select.type to use a Literal 2022-05-02 08:22:25 -04:00
Rapptz 6771f3dc99 Remove extraneous channel assignment 2022-05-02 06:54:54 -04:00
Rapptz 66c48c2d0e Add support for checks with autocomplete
Fixes #7969
2022-05-01 20:21:32 -04:00
Rapptz d774b4ac7a Add back tuple __slots__ for AllChannels 2022-05-01 20:10:56 -04:00
Rapptz 11d4dfd8fa Update app_commands validation regex to match newest documentation 2022-05-01 20:01:46 -04:00
Rapptz ca33824ba2 Change AllChannels.id into a property rather than a slot 2022-05-01 19:41:45 -04:00
Rapptz 7f210c90f4 Return a named tuple with message from ForumChannel.create_thread 2022-05-01 19:32:11 -04:00
Rapptz a704666ce3 Add support for app_commands decorators for Group subclasses 2022-05-01 19:10:59 -04:00
Rapptz e8a2eeea06 [commands] Rename Cog.app_command_group to Cog.app_command
This allows it to be consistent with hybrid commands
2022-05-01 19:04:53 -04:00
Rapptz 5f0cf58b2e Revert "Run parent command checks before calling autocomplete callback"
This reverts commit 5e98626d41.

Fix #7978
2022-05-01 18:54:22 -04:00
Rapptz 0551214be1 [commands] Properly set default guilds for group to None instead of [] 2022-05-01 15:44:18 -04:00
Rapptz e873b8294a [commands] Properly set group parent for hybrid commands in cogs 2022-05-01 15:01:30 -04:00
Rapptz d39f9851a7 Add qualified_name for app_commands 2022-05-01 14:01:21 -04:00
Rapptz f4c5d37c8f [commands] Rework Cog + Group inheritance to requite GroupCog
This is an attempt to fix the MRO issues present in the current
implementation. The previous implementation of using both Cog and
app_commands.Group in the inheritance chain caused issues with things
such as walk_commands due to it potentially shadowing the app_commands
version of the call.

In this particular case it's better to use composition instead of
inheritance to avoid these bugs entirely. Especially as more things are
added that could conflict with each other.
2022-05-01 14:01:21 -04:00
Rapptz 5e98626d41 Run parent command checks before calling autocomplete callback
Fixes #7969
2022-04-30 19:53:27 -04:00
Rapptz 6ee56fe964 Fix remaining --verifytypes related errors 2022-04-30 19:43:53 -04:00
Rapptz 5536ef1eea Update to pyright 1.1.242 2022-04-30 19:37:01 -04:00
Rapptz 8be103d6bb Install requests in CI 2022-04-30 18:55:45 -04:00
Rapptz 0851e03f00 Allow creating a news channel in create_text_channel 2022-04-30 07:12:16 -04:00
Rapptz 06df0d7931 Address latest breaking change in creating forum posts 2022-04-29 12:39:12 -04:00
Rapptz ef20264b1c Allow creating an Intent through a passed integer value 2022-04-29 10:50:22 -04:00
Rapptz 9e3375f3fc Fix infinite recursion in TextChannel.type 2022-04-29 10:00:33 -04:00
Rapptz a0dfdb9b1d Fix multiple view instances not dispatching in app commands responses
Due to a quirk in InteractionResponse.send_message not returning a
message, all messages sent with an associated View would end up having
no message_id set. When multiple instances of a View are responded to
in a slash command context, this meant that the newest one would
override the storage of the older one. Ultimately leading to the first
view instance causing interaction failures.

Since fetching the original message is an unacceptable solution to the
problem due to incurred requests, the next best thing is to store an
intermediate interaction_id as a stop gap to differentiate between
the multiple instances. This change however, came with its own set of
complications.

Due to the interaction_id being an intermediate stop gap, the
underlying storage of the view store had to be changed to accommodate
the different way of accessing the data. Mainly, the interaction_id
key had to be quick to swap and remove to another key. This solution
attempts to change the interaction_id interim key with
a full fledged message_id key when it receives one if it's possible.

Note that the only way to obtain the interaction_id back from the
component interaction is to retrieve it from the MessageInteraction
data structure. This is because using the interaction_id of the button
press would be a different interaction ID than the one set as an
interim key. As a consequence, this stop gap only works for application
command based interactions. I am not aware of this bug manifesting in
component based interactions.

This patch also fixes a bug with ViewStore.remove_view not working due
to a bug being suppressed by a type: ignore comment. It also removes
the older __verify_integrity helper method since clean-up is already
done through View.stop() or View timeout.

Hopefully in the near future, the `/callback` endpoint will return
actual message data and this stop gap fix will no longer be necessary.
2022-04-28 12:24:57 -04:00
Rapptz e53daaba35 Properly namespace MISSING in the documentation 2022-04-28 10:56:31 -04:00
Rapptz 204f941e96 Display permissions v2 decorators in the documentation 2022-04-28 10:50:00 -04:00
Rapptz ab64a2eae9 Fix typing of guilds kwargs to take Sequence instead of List 2022-04-28 10:48:57 -04:00
Rapptz acd4a0856e Add Interaction.extras for extraneous data 2022-04-28 07:59:43 -04:00
Rapptz 500bf77103 Document and export MISSING sentinel 2022-04-28 07:52:23 -04:00
Rapptz a14b43f2fd Fix documentation links being broken 2022-04-28 00:53:51 -04:00
Rapptz 3b3d4d3880 Add support for setting and receiving permissions v2
Closes #7592

This does not include audit log changes or the remaining endpoints.
That will come in a different commit.
2022-04-28 00:23:36 -04:00
Rapptz e198a0e7e6 Avoid re-creating View children on edit
The older code attempted to be clever and sync component additions and
removals with what the message edit is doing. In some cases, this led
to the re-creation of those components causing lost attributes to be
dropped such as `_rendered_row` which would mess up handling of view
weights.

Instead of recreating the children list every time and keeping track
of additions and removals, this change just updates the old state with
the new state while ignoring any new or removed additions. This should
work fine in theory due to additions or removals already being present
before editing the View instance in the first place.

Closes #7231 #7511
2022-04-27 01:24:10 -04:00
Rapptz 69b12b97c0 Sync abc.User protocol with more shared methods
This isn't *all* of them but it's a sizeable portion
2022-04-23 03:00:46 -04:00
Rapptz f045b7d63c Fix BanEntry not being exported despite being documented 2022-04-23 01:53:21 -04:00
Rapptz 5fcd4e411f [commands] Add support for typing.Annotated 2022-04-22 06:31:02 -04:00
Rapptz ab33551553 Fix type hints on GuildChannel.set_permissions 2022-04-22 04:50:10 -04:00
Rapptz 832d2c0542 [commands] Fix certain annotations being allowed in hybrid commands
Union types were not properly constrained and callable types were
too eagerly being converted
2022-04-21 04:13:32 -04:00
Rapptz 405c445093 [commands] Unwrap transformers when considering them as converters 2022-04-21 03:19:11 -04:00
Rapptz 5357b9319b [commands] Ignore delete_after for ephemeral interaction sends 2022-04-21 02:07:37 -04:00
Rapptz de941ababe Add Colour.from_str factory method
This moves the command extension parsing code over to the main library
since it can be potentially useful for others.
2022-04-20 06:49:28 -04:00
Rapptz 84e6b9283d [commands] Fix delete_after not working with interaction Context.send 2022-04-19 22:14:11 -04:00
Rapptz cd0d6749ea [commands] Fix Context.reply not working with expired interactions 2022-04-19 22:09:53 -04:00
Rapptz 1d97a35385 [commands] Fix hybrid commands not respecting default annotations 2022-04-19 12:08:22 -04:00
Rapptz 987235d564 Only call async setup if the loop sentinel hasn't been changed 2022-04-19 04:27:52 -04:00
Rapptz 6113f856b6 [commands] Dispatch command events for hybrid commands 2022-04-19 01:40:16 -04:00
Rapptz 2e02f618f0 Add support for enum values that aren't int, str, or float
This coerces them into string options to allow them to be transformed
in the actual code.
2022-04-18 20:15:45 -04:00
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