Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for message_delete_bulk event #990

Merged
merged 2 commits into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions interactions/api/gateway/client.py
Expand Up @@ -413,6 +413,7 @@ def _dispatch_event(self, event: str, data: dict) -> None:
"ChannelPins",
"MessageReaction",
"MessageReactionRemove",
"MessageDelete",
# Extend this for everything that should not be cached
]:
id = None
Expand Down Expand Up @@ -487,6 +488,8 @@ def __modify_guild_cache():
if id:
old_obj = _cache.pop(id)
self._dispatch.dispatch(f"on_{name}", old_obj)
elif "_delete_bulk" in name:
self._dispatch.dispatch(f"on_{name}", obj)
EdVraz marked this conversation as resolved.
Show resolved Hide resolved

else:
self._dispatch.dispatch(f"on_{name}", obj)
Expand Down
16 changes: 16 additions & 0 deletions interactions/api/models/gw.py
Expand Up @@ -39,6 +39,7 @@
"ChannelPins",
"ThreadMembers",
"ThreadList",
"MessageDelete",
"MessageReactionRemove",
"MessageReaction",
"GuildIntegrations",
Expand Down Expand Up @@ -760,6 +761,21 @@ class Presence(ClientSerializerMixin):
client_status: ClientStatus = field(converter=ClientStatus)


@define()
class MessageDelete(DictSerializerMixin):
"""
A class object representing the gateway event ``MESSAGE_DELETE_BULK``.

:ivar List[Snowflake] ids: The message IDs of the event.
:ivar Snowflake channel_id: The channel ID of the event.
:ivar Optional[Snowflake] guild_id?: The guild ID of the event.
"""

ids: List[Snowflake] = field(converter=convert_list(Snowflake))
channel_id: Snowflake = field(converter=Snowflake)
guild_id: Optional[Snowflake] = field(converter=Snowflake, default=None)


@define()
class MessageReaction(DictSerializerMixin):
"""
Expand Down