Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a51f9dd23 | |||
c34612dd71 | |||
e4750c7105 |
@ -39,8 +39,11 @@ if TYPE_CHECKING:
|
|||||||
from .message import Message
|
from .message import Message
|
||||||
from .partial_emoji import PartialEmoji
|
from .partial_emoji import PartialEmoji
|
||||||
from .member import Member
|
from .member import Member
|
||||||
|
from .threads import Thread
|
||||||
|
|
||||||
|
|
||||||
|
from .enums import ChannelType, try_enum
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'RawMessageDeleteEvent',
|
'RawMessageDeleteEvent',
|
||||||
'RawBulkMessageDeleteEvent',
|
'RawBulkMessageDeleteEvent',
|
||||||
@ -49,6 +52,7 @@ __all__ = (
|
|||||||
'RawReactionClearEvent',
|
'RawReactionClearEvent',
|
||||||
'RawReactionClearEmojiEvent',
|
'RawReactionClearEmojiEvent',
|
||||||
'RawIntegrationDeleteEvent',
|
'RawIntegrationDeleteEvent',
|
||||||
|
'RawThreadDeleteEvent',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -276,3 +280,31 @@ class RawIntegrationDeleteEvent(_RawReprMixin):
|
|||||||
self.application_id: Optional[int] = int(data['application_id'])
|
self.application_id: Optional[int] = int(data['application_id'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.application_id: Optional[int] = None
|
self.application_id: Optional[int] = None
|
||||||
|
|
||||||
|
class RawThreadDeleteEvent(_RawReprMixin):
|
||||||
|
"""Represents the payload for a :func:`on_raw_thread_delete` event.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
----------
|
||||||
|
thread_id: :class:`int`
|
||||||
|
The ID of the thread that was deleted.
|
||||||
|
thread_type: :class:`discord.ChannelType`
|
||||||
|
The channel type of the deleted thread.
|
||||||
|
guild_id: :class:`int`
|
||||||
|
The ID of the guild the thread was deleted in.
|
||||||
|
parent_id: :class:`int`
|
||||||
|
The ID of the channel the thread was belonged to.
|
||||||
|
thread: Optional[:class:`discord.Thread`]
|
||||||
|
The thread, if it could be found in the internal cache.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__slots__ = ('thread_id', 'thread_type', 'parent_id', 'guild_id', 'thread')
|
||||||
|
|
||||||
|
def __init__(self, data) -> None:
|
||||||
|
self.thread_id: int = int(data['id'])
|
||||||
|
self.thread_type: ChannelType = try_enum(ChannelType, data['type'])
|
||||||
|
self.guild_id: int = int(data['guild_id'])
|
||||||
|
self.parent_id: int = int(data['parent_id'])
|
||||||
|
self.thread: Optional[Thread] = None
|
||||||
|
@ -851,8 +851,10 @@ class ConnectionState:
|
|||||||
_log.debug('THREAD_DELETE referencing an unknown guild ID: %s. Discarding', guild_id)
|
_log.debug('THREAD_DELETE referencing an unknown guild ID: %s. Discarding', guild_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
thread_id = int(data['id'])
|
raw = RawThreadDeleteEvent(data)
|
||||||
thread = guild.get_thread(thread_id)
|
raw.thread = thread = guild.get_thread(raw.thread_id)
|
||||||
|
self.dispatch('raw_thread_delete', raw)
|
||||||
|
|
||||||
if thread is not None:
|
if thread is not None:
|
||||||
guild._remove_thread(thread) # type: ignore
|
guild._remove_thread(thread) # type: ignore
|
||||||
self.dispatch('thread_delete', thread)
|
self.dispatch('thread_delete', thread)
|
||||||
|
26
docs/api.rst
26
docs/api.rst
@ -718,7 +718,11 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
|||||||
|
|
||||||
.. function:: on_thread_delete(thread)
|
.. function:: on_thread_delete(thread)
|
||||||
|
|
||||||
Called whenever a thread is deleted.
|
Called whenever a thread is deleted. If the thread could
|
||||||
|
not be found in the internal cache this event will not be called.
|
||||||
|
Threads will not be in the cache if they are archived.
|
||||||
|
|
||||||
|
If you need this information use :func:`on_raw_thread_delete` instead.
|
||||||
|
|
||||||
Note that you can get the guild from :attr:`Thread.guild`.
|
Note that you can get the guild from :attr:`Thread.guild`.
|
||||||
|
|
||||||
@ -729,6 +733,18 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
|||||||
:param thread: The thread that got deleted.
|
:param thread: The thread that got deleted.
|
||||||
:type thread: :class:`Thread`
|
:type thread: :class:`Thread`
|
||||||
|
|
||||||
|
.. function:: on_raw_thread_delete(payload)
|
||||||
|
|
||||||
|
Called whenever a thread is deleted. Unlike :func:`on_thread_delete` this
|
||||||
|
is called regardless of the thread being in the internal thread cache or not.
|
||||||
|
|
||||||
|
This requires :attr:`Intents.guilds` to be enabled.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
|
:param payload: The raw event payload data.
|
||||||
|
:type payload: :class:`RawThreadDeleteEvent`
|
||||||
|
|
||||||
.. function:: on_thread_member_join(member)
|
.. function:: on_thread_member_join(member)
|
||||||
on_thread_member_remove(member)
|
on_thread_member_remove(member)
|
||||||
|
|
||||||
@ -3902,6 +3918,14 @@ RawIntegrationDeleteEvent
|
|||||||
.. autoclass:: RawIntegrationDeleteEvent()
|
.. autoclass:: RawIntegrationDeleteEvent()
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
RawThreadDeleteEvent
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. attributetable:: RawThreadDeleteEvent
|
||||||
|
|
||||||
|
.. autoclass:: RawThreadDeleteEvent()
|
||||||
|
:members:
|
||||||
|
|
||||||
PartialWebhookGuild
|
PartialWebhookGuild
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user