Browse Source

Rebase to latest upstream

pull/10109/head
dolfies 3 years ago
parent
commit
008f79adee
  1. 2
      .github/workflows/lint.yml
  2. 3
      discord/state.py
  3. 2
      discord/threads.py
  4. 19
      discord/webhook/async_.py

2
.github/workflows/lint.yml

@ -37,7 +37,7 @@ jobs:
- name: Install pyright - name: Install pyright
run: | run: |
npm install -g pyright npm install -g pyright@1.1.235
- name: Run pyright - name: Run pyright
run: | run: |

3
discord/state.py

@ -1980,7 +1980,8 @@ class ConnectionState:
_log.debug('WEBHOOKS_UPDATE referencing an unknown guild ID: %s. Discarding', data['guild_id']) _log.debug('WEBHOOKS_UPDATE referencing an unknown guild ID: %s. Discarding', data['guild_id'])
return return
channel = guild.get_channel(int(data['channel_id'])) channel_id = utils._get_as_snowflake(data, 'channel_id')
channel = guild.get_channel(channel_id) # type: ignore # None is okay here
if channel is not None: if channel is not None:
self.dispatch('webhooks_update', channel) self.dispatch('webhooks_update', channel)
else: else:

2
discord/threads.py

@ -543,7 +543,7 @@ class Thread(Messageable, Hashable):
Specifies the slowmode rate limit for user in this thread, in seconds. Specifies the slowmode rate limit for user in this thread, in seconds.
A value of ``0`` disables slowmode. The maximum value possible is ``21600``. A value of ``0`` disables slowmode. The maximum value possible is ``21600``.
reason: Optional[:class:`str`] reason: Optional[:class:`str`]
The reason for editing the thread. Shows up on the audit log. The reason for editing this thread. Shows up on the audit log.
Raises Raises
------- -------

19
discord/webhook/async_.py

@ -46,7 +46,7 @@ from ..asset import Asset
from ..partial_emoji import PartialEmoji from ..partial_emoji import PartialEmoji
from ..http import Route, handle_message_parameters, HTTPClient from ..http import Route, handle_message_parameters, HTTPClient
from ..mixins import Hashable from ..mixins import Hashable
from ..channel import PartialMessageable from ..channel import TextChannel, PartialMessageable
from ..file import File from ..file import File
__all__ = ( __all__ = (
@ -69,7 +69,7 @@ if TYPE_CHECKING:
from ..http import Response from ..http import Response
from ..guild import Guild from ..guild import Guild
from ..emoji import Emoji from ..emoji import Emoji
from ..channel import TextChannel from ..channel import TextChannel, VoiceChannel
from ..abc import Snowflake from ..abc import Snowflake
import datetime import datetime
from ..types.webhook import ( from ..types.webhook import (
@ -744,8 +744,8 @@ class BaseWebhook(Hashable):
return self._state and self._state._get_guild(self.guild_id) return self._state and self._state._get_guild(self.guild_id)
@property @property
def channel(self) -> Optional[TextChannel]: def channel(self) -> Optional[Union[VoiceChannel, TextChannel]]:
"""Optional[:class:`TextChannel`]: The text channel this webhook belongs to. """Optional[Union[:class:`VoiceChannel`, :class:`TextChannel`]]: The channel this webhook belongs to.
If this is a partial webhook, then this will always return ``None``. If this is a partial webhook, then this will always return ``None``.
""" """
@ -1156,7 +1156,16 @@ class Webhook(BaseWebhook):
def _create_message(self, data, *, thread: Snowflake): def _create_message(self, data, *, thread: Snowflake):
state = _WebhookState(self, parent=self._state, thread=thread) state = _WebhookState(self, parent=self._state, thread=thread)
# state may be artificial (unlikely at this point...) # state may be artificial (unlikely at this point...)
channel = self.channel or PartialMessageable(state=self._state, id=int(data['channel_id'])) # type: ignore if thread is MISSING:
channel = self.channel or PartialMessageable(state=self._state, id=int(data['channel_id'])) # type: ignore
else:
channel = self.channel
if isinstance(channel, TextChannel):
channel = channel.get_thread(thread.id)
if channel is None:
channel = PartialMessageable(state=self._state, id=int(data['channel_id'])) # type: ignore
# state is artificial # state is artificial
return WebhookMessage(data=data, state=state, channel=channel) # type: ignore return WebhookMessage(data=data, state=state, channel=channel) # type: ignore

Loading…
Cancel
Save