Browse Source

Fix docs linking and new pyright version type errors

pull/10109/head
dolfies 2 years ago
parent
commit
23b8a3d49e
  1. 6
      discord/abc.py
  2. 1
      discord/application.py
  3. 15
      discord/client.py
  4. 2
      discord/ext/commands/converter.py
  5. 4
      discord/http.py
  6. 11
      discord/invite.py
  7. 2
      discord/promotions.py
  8. 10
      discord/state.py
  9. 7
      docs/api.rst

6
discord/abc.py

@ -1505,13 +1505,17 @@ class GuildChannel:
Invite creation failed. Invite creation failed.
~discord.NotFound ~discord.NotFound
The channel that was passed is a category or an invalid channel. The channel that was passed is a category or an invalid channel.
ValueError
``target_type`` is not a creatable invite target type.
Returns Returns
-------- --------
:class:`~discord.Invite` :class:`~discord.Invite`
The invite that was created. The invite that was created.
""" """
if target_type is InviteTarget.unknown: if target_type not in (None, InviteTarget.unknown, InviteTarget.stream, InviteTarget.embedded_application):
raise ValueError('target_type parameter must be InviteTarget.stream, or InviteTarget.embedded_application')
if target_type == InviteTarget.unknown:
target_type = None target_type = None
data = await self._state.http.create_invite( data = await self._state.http.create_invite(

1
discord/application.py

@ -1846,6 +1846,7 @@ class PartialApplication(Hashable):
payload: PartialUserPayload = { payload: PartialUserPayload = {
'id': team.id, 'id': team.id,
'username': f'team{team.id}', 'username': f'team{team.id}',
'global_name': None,
'public_flags': UserFlags.team_user.value, 'public_flags': UserFlags.team_user.value,
'discriminator': '0000', 'discriminator': '0000',
'avatar': None, 'avatar': None,

15
discord/client.py

@ -1159,7 +1159,7 @@ class Client:
if activities is None and not self.is_closed(): if activities is None and not self.is_closed():
activity = getattr(state.settings, 'custom_activity', None) activity = getattr(state.settings, 'custom_activity', None)
activities = (activity,) if activity else activities activities = (activity,) if activity else activities
return activities or () return activities or tuple()
@property @property
def activity(self) -> Optional[ActivityTypes]: def activity(self) -> Optional[ActivityTypes]:
@ -1193,7 +1193,7 @@ class Client:
if activities is None and not self.is_closed(): if activities is None and not self.is_closed():
activity = getattr(state.settings, 'custom_activity', None) activity = getattr(state.settings, 'custom_activity', None)
activities = (activity,) if activity else activities activities = (activity,) if activity else activities
return activities or () return activities or tuple()
@property @property
def allowed_mentions(self) -> Optional[AllowedMentions]: def allowed_mentions(self) -> Optional[AllowedMentions]:
@ -2100,15 +2100,16 @@ class Client:
state = self._connection state = self._connection
type = invite.type type = invite.type
if message := invite._message: kwargs = {}
kwargs = {'message': message} if not invite._message:
else:
kwargs = { kwargs = {
'guild_id': getattr(invite.guild, 'id', MISSING), 'guild_id': getattr(invite.guild, 'id', MISSING),
'channel_id': getattr(invite.channel, 'id', MISSING), 'channel_id': getattr(invite.channel, 'id', MISSING),
'channel_type': getattr(invite.channel, 'type', MISSING), 'channel_type': getattr(invite.channel, 'type', MISSING),
} }
data = await state.http.accept_invite(invite.code, type, state.session_id or utils._generate_session_id(), **kwargs) data = await state.http.accept_invite(
invite.code, type, state.session_id or utils._generate_session_id(), message=invite._message, **kwargs
)
return Invite.from_incomplete(state=state, data=data, message=invite._message) return Invite.from_incomplete(state=state, data=data, message=invite._message)
async def delete_invite(self, invite: Union[Invite, str], /) -> Invite: async def delete_invite(self, invite: Union[Invite, str], /) -> Invite:
@ -5067,7 +5068,7 @@ class Client:
"""|coro| """|coro|
Gets the suggested pomelo username for your account. Gets the suggested pomelo username for your account.
This username can be used with :meth:`edit` to migrate your account This username can be used with :meth:`~discord.ClientUser.edit` to migrate your account
to Discord's `new unique username system <https://discord.com/blog/usernames>`_ to Discord's `new unique username system <https://discord.com/blog/usernames>`_
.. note:: .. note::

2
discord/ext/commands/converter.py

@ -387,7 +387,7 @@ class PartialMessageConverter(Converter[discord.PartialMessage]):
return None return None
return guild._resolve_channel(channel_id) return guild._resolve_channel(channel_id)
return ctx.bot.get_channel(channel_id) # type: ignore return ctx.bot.get_channel(channel_id)
async def convert(self, ctx: Context[BotT], argument: str) -> discord.PartialMessage: async def convert(self, ctx: Context[BotT], argument: str) -> discord.PartialMessage:
guild_id, message_id, channel_id = self._get_id_matches(ctx, argument) guild_id, message_id, channel_id = self._get_id_matches(ctx, argument)

4
discord/http.py

@ -2257,9 +2257,9 @@ class HTTPClient:
guild_id: Snowflake = MISSING, guild_id: Snowflake = MISSING,
channel_id: Snowflake = MISSING, channel_id: Snowflake = MISSING,
channel_type: ChannelType = MISSING, channel_type: ChannelType = MISSING,
message: Message = MISSING, message: Optional[Message] = None,
): # TODO: response type ): # TODO: response type
if message is not MISSING: # Invite Button Embed if message: # Invite Button Embed
props = ContextProperties.from_invite_button_embed( props = ContextProperties.from_invite_button_embed(
guild_id=getattr(message.guild, 'id', None), guild_id=getattr(message.guild, 'id', None),
channel_id=message.channel.id, channel_id=message.channel.id,

11
discord/invite.py

@ -661,16 +661,17 @@ class Invite(Hashable):
""" """
state = self._state state = self._state
type = self.type type = self.type
if message := self._message: kwargs = {}
kwargs = {'message': message} if not self._message:
else:
kwargs = { kwargs = {
'guild_id': getattr(self.guild, 'id', MISSING), 'guild_id': getattr(self.guild, 'id', MISSING),
'channel_id': getattr(self.channel, 'id', MISSING), 'channel_id': getattr(self.channel, 'id', MISSING),
'channel_type': getattr(self.channel, 'type', MISSING), 'channel_type': getattr(self.channel, 'type', MISSING),
} }
data = await state.http.accept_invite(self.code, type, state.session_id or _generate_session_id(), **kwargs) data = await state.http.accept_invite(
return Invite.from_incomplete(state=state, data=data, message=message) self.code, type, state.session_id or _generate_session_id(), message=self._message, **kwargs
)
return Invite.from_incomplete(state=state, data=data, message=self._message)
async def accept(self) -> Invite: async def accept(self) -> Invite:
"""|coro| """|coro|

2
discord/promotions.py

@ -138,7 +138,7 @@ class Promotion(Hashable):
return f'<Promotion id={self.id} title={self.outbound_title!r}>' return f'<Promotion id={self.id} title={self.outbound_title!r}>'
def _update(self, data: Union[PromotionPayload, ClaimedPromotionPayload]) -> None: def _update(self, data: Union[PromotionPayload, ClaimedPromotionPayload]) -> None:
promotion: PromotionPayload = data.get('promotion', data) # type: ignore promotion: PromotionPayload = data.get('promotion', data)
self.id: int = int(promotion['id']) self.id: int = int(promotion['id'])
self.trial_id: Optional[int] = _get_as_snowflake(promotion, 'trial_id') self.trial_id: Optional[int] = _get_as_snowflake(promotion, 'trial_id')

10
discord/state.py

@ -812,7 +812,7 @@ class ConnectionState:
self._users[user_id] = user self._users[user_id] = user
return user return user
def create_user(self, data: Union[UserPayload, PartialUserPayload]) -> User: def create_user(self, data: Union[UserPayload, PartialUserPayload], cache: bool = False) -> User:
user_id = int(data['id']) user_id = int(data['id'])
if user_id == self.self_id: if user_id == self.self_id:
return self.user # type: ignore return self.user # type: ignore
@ -1176,7 +1176,7 @@ class ConnectionState:
for pm in data.get('private_channels', []) + extra_data.get('lazy_private_channels', []): for pm in data.get('private_channels', []) + extra_data.get('lazy_private_channels', []):
factory, _ = _private_channel_factory(pm['type']) factory, _ = _private_channel_factory(pm['type'])
if 'recipients' not in pm: if 'recipients' not in pm:
pm['recipients'] = [temp_users[int(u_id)] for u_id in pm.pop('recipient_ids')] pm['recipients'] = [temp_users[int(u_id)] for u_id in pm.pop('recipient_ids')] # type: ignore
self._add_private_channel(factory(me=user, data=pm, state=self)) # type: ignore self._add_private_channel(factory(me=user, data=pm, state=self)) # type: ignore
# Disloses # Disloses
@ -1897,7 +1897,7 @@ class ConnectionState:
channel, _ = self._get_guild_channel(message) channel, _ = self._get_guild_channel(message)
# channel will be the correct type here # channel will be the correct type here
message = Message(channel=channel, data=message, state=self) message = Message(channel=channel, data=message, state=self) # type: ignore
if self._messages is not None: if self._messages is not None:
self._messages.append(message) self._messages.append(message)
@ -2056,7 +2056,7 @@ class ConnectionState:
mdata = item['member'] mdata = item['member']
member = Member(data=mdata, guild=guild, state=self) member = Member(data=mdata, guild=guild, state=self)
if mdata.get('presence') is not None: if mdata.get('presence') is not None:
member._presence_update(mdata['presence'], empty_tuple) # type: ignore member._presence_update(mdata['presence'], empty_tuple)
members.append(member) members.append(member)
guild._member_list.append(member) if should_parse else None guild._member_list.append(member) if should_parse else None
@ -2102,7 +2102,7 @@ class ConnectionState:
else: else:
member = Member(data=mdata, guild=guild, state=self) member = Member(data=mdata, guild=guild, state=self)
if mdata.get('presence') is not None: if mdata.get('presence') is not None:
member._presence_update(mdata['presence'], empty_tuple) # type: ignore member._presence_update(mdata['presence'], empty_tuple)
to_add.append(member) to_add.append(member)

7
docs/api.rst

@ -3638,13 +3638,6 @@ of :class:`enum.Enum`.
Represents the default avatar with the colour pink. Represents the default avatar with the colour pink.
See also :attr:`Colour.pink` See also :attr:`Colour.pink`
.. versionadded:: 2.3
.. attribute:: pink
Represents the default avatar with the color pink.
This is not currently used in the client.
.. class:: StickerType .. class:: StickerType
Represents the type of sticker. Represents the type of sticker.

Loading…
Cancel
Save