303 Commits

Author SHA1 Message Date
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
Jonah Lawrence
862eba1e59
Add filename and description kwargs for to_file 2022-04-14 19:04:05 -04:00
apple502j
f77078278a
Update system_content for channel_follow_add message 2022-04-06 02:08:20 -04:00
UltimateSppy765
d5d9a532b2
Update docs to reflect Text in Voice related changes 2022-04-03 17:40:51 -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
7696342d76 Add missing __slots__ to MessageInteraction 2022-04-02 01:24:56 -04:00
Rapptz
e79895d824 Add Message.interaction and MessageInteraction type
Fix #7819
2022-04-01 11:15:15 -04:00
Jonah Lawrence
1372ef407c
Keep description in Attachment.to_file 2022-03-31 00:29:34 -04:00
Jonah Lawrence
37bbfdce95
Add context_menu_command Message type 2022-03-30 19:13:00 -04:00
Kellen
4fd2d5fdfd
Remove redundant imports and variables 2022-03-29 02:50:34 -04:00
jack1142
5ffa3e85de
Update comments after # type: ignore to be compatible with PEP 484 2022-03-27 22:26:34 -04:00
Haruka
cda1f0a4ef
Allow receiving messages from voice channels 2022-03-25 04:24:19 -04:00
Stocker
5fa32540a4
Change Message to subclass PartialMessage 2022-03-20 15:18:24 -04:00
BeatButton
7389707847
Only send allowed_mentions if content changed 2022-03-20 02:55:48 -04:00
z03h
5d6905a1bc
Update clean_content/channel_mentions for threads 2022-03-19 04:46:55 -04:00
Josh
e01d4a31eb
Replace invariant container types with wider types where applicable 2022-03-17 07:26:01 -04:00
Rapptz
1fba54ce97 Reword DeletedMessageReference docstring to be clearer 2022-03-16 05:12:26 -04:00
ChesterWOV
ca4db68686
Fix grammar issue for Message.add_reaction docs 2022-03-14 22:51:28 -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
chromacoat dreamkey
095aaa9ad1
Change wording of InvalidArgument removal in docs 2022-03-11 23:25:43 -05:00
Eric Schneider
ef92170a9d
Fix Message.edit ignoring suppress kwarg 2022-03-10 18:56:42 -05:00
Stocker
e15415413b
Add missing parameters to certain methods
- slowmode_delay and reason in Message.create_thread
- slowmode_delay in TextChannel.create_thread
- reason in Guild.edit_widget
2022-03-06 23:00:50 -05:00
Stocker
12d4de52a8
Add Attachment.ephemeral 2022-03-06 22:59:15 -05:00
m-etroo
e3de172ba9
Fix incorrect wording in Message.edit docstring
'role' -> 'message'
2022-03-06 19:04:52 -05:00
Josh
147948af9b
Use typing.Self throughout library 2022-03-01 07:53:24 -05:00
Josh
2b69b5d545
Remove discord.InvalidArgument
This uses TypeError and ValueError instead.
2022-02-26 01:44:49 -05:00
Rapptz
8d52ddaff6 Fix remaining type errors in main package
This doesn't fix the type errors in the ext packages though.
2022-02-22 04:19:46 -05:00
Nadir Chowdhury
3cf000d467
Type up gateway payloads 2022-02-21 22:09:40 -05:00
Rapptz
f2600995e8 Fix NameError due to missing import 2022-02-20 11:04:50 -05:00
Rapptz
88b520b5ab Reformat code using black
Segments where readability was hampered were fixed by appropriate
format skipping directives. New code should hopefully be black
compatible. The moment they remove the -S option is probably the moment
I stop using black though.
2022-02-20 08:04:58 -05:00
jack1142
686f233954
Add missing information about in-place edits in Message.edit 2022-02-19 22:35:52 -05:00
Josh
dede5539ee
Add support for editing message attachments 2022-02-19 22:02:53 -05:00
jack1142
dc19c6c7d5
Add positional-only arguments in more places 2022-02-19 20:28:01 -05:00
Alex Nørgaard
2e5da07180
Fix unknown DMChannel in MessageReference.resolved.channel
Threads would cause the message reference to resolve to a DMChannel
2022-02-18 20:26:13 -05:00
Josh
ce01033e06
Allow PartialMessage.channel to be a PartialMessageable 2022-02-18 08:31:07 -05:00
Rapptz
770a5fee9c Remove PartialMessage.edit duplicated code
Now that Message.edit returns the message this duplication is no longer
needed.
2022-02-18 07:48:43 -05:00
Rapptz
9c066a8cf6 Refactor internal message sending and editing parameter passing
This reduces some repetition in many functions and is ripped out of
the webhook code. This also removes the unused HTTP functions for
interaction responses since those belong in the webhook code rather
than the HTTPClient.
2022-02-18 07:47:59 -05:00
Josh
08bee0eeb6
Add support for file/attachment descriptions 2022-02-18 05:23:02 -05:00
James Gayfer
4aafa39e8c
Update thread permissions
Discord has renamed / repurposed "Use Public Threads" and "Use Private
Threads", as well as added a new permission "Send Messages in Threads".

For more information, see:
  https://github.com/discord/discord-api-docs/pull/3672
2021-08-26 15:53:21 -04:00
Rapptz
8306b9f6af Add type hint for suppress parameter 2021-08-23 23:51:40 -04:00
Rapptz
490bbffc93 Remove in-place edits and return fresh instances instead
Fixes #4098
2021-08-23 23:46:50 -04:00
Rapptz
8bbb8f6db9 Use getattr for default_auto_archive_duration in Message.create_thread
Some channel types do not have this attribute so a fallback is
necessary to prevent the attribute access from erroring.
2021-08-23 23:44:20 -04:00
Stocker
d8b06ca7f2
Fix message.py typehints 2021-08-23 23:43:57 -04:00
James Gayfer
489e5f3288
Use channel default auto archive duration
Currently creating a new thread uses a default auto archive duration of
1440 minutes, or 1 day.

Rather than prescribing our own default, we can use the default auto
archive duration that is set on the channel. This ensures that newly
created threads will respect the default auto archive duration as
prescribed by the user.
2021-08-18 05:12:40 -04:00
Rapptz
3b4c6269be Fix documentation for Message.is_system
Also fixes some formatting
2021-08-18 01:01:24 -04:00
AkshuAgarwal
6b6bcb92e6
Fix missing or broken versionadded in docstrings
This also documents BadFlagArgument.flag
2021-08-18 00:45:02 -04:00
SYCKGit
f7a3ea90b8
Add other message types exclusions to Message.is_system
Message.is_system was checking if self.type is MessageType.default
but now there are other MessageTypes that are not system messages
2021-08-18 00:42:48 -04:00
Rapptz
1e17b7fcea Rename start_thread to create_thread for consistency 2021-08-12 00:30:50 -04:00
Rapptz
1279510194 Add support for PartialMessageable instances
This allows library users to send messages to channels without fetching
it first.
2021-08-10 09:24:49 -04:00