diff --git a/discord/abc.py b/discord/abc.py index 9f30fbb68..d0b6236ca 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -1505,13 +1505,17 @@ class GuildChannel: Invite creation failed. ~discord.NotFound The channel that was passed is a category or an invalid channel. + ValueError + ``target_type`` is not a creatable invite target type. Returns -------- :class:`~discord.Invite` 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 data = await self._state.http.create_invite( diff --git a/discord/application.py b/discord/application.py index 98b062277..bcfe28f5e 100644 --- a/discord/application.py +++ b/discord/application.py @@ -1846,6 +1846,7 @@ class PartialApplication(Hashable): payload: PartialUserPayload = { 'id': team.id, 'username': f'team{team.id}', + 'global_name': None, 'public_flags': UserFlags.team_user.value, 'discriminator': '0000', 'avatar': None, diff --git a/discord/client.py b/discord/client.py index f21c4c483..7264902e9 100644 --- a/discord/client.py +++ b/discord/client.py @@ -1159,7 +1159,7 @@ class Client: if activities is None and not self.is_closed(): activity = getattr(state.settings, 'custom_activity', None) activities = (activity,) if activity else activities - return activities or () + return activities or tuple() @property def activity(self) -> Optional[ActivityTypes]: @@ -1193,7 +1193,7 @@ class Client: if activities is None and not self.is_closed(): activity = getattr(state.settings, 'custom_activity', None) activities = (activity,) if activity else activities - return activities or () + return activities or tuple() @property def allowed_mentions(self) -> Optional[AllowedMentions]: @@ -2100,15 +2100,16 @@ class Client: state = self._connection type = invite.type - if message := invite._message: - kwargs = {'message': message} - else: + kwargs = {} + if not invite._message: kwargs = { 'guild_id': getattr(invite.guild, 'id', MISSING), 'channel_id': getattr(invite.channel, 'id', 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) async def delete_invite(self, invite: Union[Invite, str], /) -> Invite: @@ -5067,7 +5068,7 @@ class Client: """|coro| 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 `_ .. note:: diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index ef6f555bb..518d04c32 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -387,7 +387,7 @@ class PartialMessageConverter(Converter[discord.PartialMessage]): return None 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: guild_id, message_id, channel_id = self._get_id_matches(ctx, argument) diff --git a/discord/http.py b/discord/http.py index 0ab638d70..d8e914744 100644 --- a/discord/http.py +++ b/discord/http.py @@ -2257,9 +2257,9 @@ class HTTPClient: guild_id: Snowflake = MISSING, channel_id: Snowflake = MISSING, channel_type: ChannelType = MISSING, - message: Message = MISSING, + message: Optional[Message] = None, ): # TODO: response type - if message is not MISSING: # Invite Button Embed + if message: # Invite Button Embed props = ContextProperties.from_invite_button_embed( guild_id=getattr(message.guild, 'id', None), channel_id=message.channel.id, diff --git a/discord/invite.py b/discord/invite.py index b3099b5bf..1be53cfbb 100644 --- a/discord/invite.py +++ b/discord/invite.py @@ -661,16 +661,17 @@ class Invite(Hashable): """ state = self._state type = self.type - if message := self._message: - kwargs = {'message': message} - else: + kwargs = {} + if not self._message: kwargs = { 'guild_id': getattr(self.guild, 'id', MISSING), 'channel_id': getattr(self.channel, 'id', 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) - return Invite.from_incomplete(state=state, data=data, message=message) + data = await state.http.accept_invite( + 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: """|coro| diff --git a/discord/promotions.py b/discord/promotions.py index f039ea86a..3da48315d 100644 --- a/discord/promotions.py +++ b/discord/promotions.py @@ -138,7 +138,7 @@ class Promotion(Hashable): return f'' 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.trial_id: Optional[int] = _get_as_snowflake(promotion, 'trial_id') diff --git a/discord/state.py b/discord/state.py index 8a25404ea..c339e5f08 100644 --- a/discord/state.py +++ b/discord/state.py @@ -812,7 +812,7 @@ class ConnectionState: self._users[user_id] = 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']) if user_id == self.self_id: return self.user # type: ignore @@ -1176,7 +1176,7 @@ class ConnectionState: for pm in data.get('private_channels', []) + extra_data.get('lazy_private_channels', []): factory, _ = _private_channel_factory(pm['type']) 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 # Disloses @@ -1897,7 +1897,7 @@ class ConnectionState: channel, _ = self._get_guild_channel(message) # 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: self._messages.append(message) @@ -2056,7 +2056,7 @@ class ConnectionState: mdata = item['member'] member = Member(data=mdata, guild=guild, state=self) 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) guild._member_list.append(member) if should_parse else None @@ -2102,7 +2102,7 @@ class ConnectionState: else: member = Member(data=mdata, guild=guild, state=self) 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) diff --git a/docs/api.rst b/docs/api.rst index 041d7b98d..ec4a9f3dd 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -3638,13 +3638,6 @@ of :class:`enum.Enum`. Represents the default avatar with the 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 Represents the type of sticker.