Fix typings in message.py
This commit is contained in:
parent
81004369dc
commit
ca92f37f18
@ -36,7 +36,7 @@ from .reaction import Reaction
|
|||||||
from .emoji import Emoji
|
from .emoji import Emoji
|
||||||
from .partial_emoji import PartialEmoji
|
from .partial_emoji import PartialEmoji
|
||||||
from .enums import MessageType, ChannelType, try_enum
|
from .enums import MessageType, ChannelType, try_enum
|
||||||
from .errors import InvalidArgument, ClientException, HTTPException
|
from .errors import InvalidArgument, HTTPException
|
||||||
from .embeds import Embed
|
from .embeds import Embed
|
||||||
from .member import Member
|
from .member import Member
|
||||||
from .flags import MessageFlags
|
from .flags import MessageFlags
|
||||||
@ -60,7 +60,7 @@ if TYPE_CHECKING:
|
|||||||
from .types.user import User as UserPayload
|
from .types.user import User as UserPayload
|
||||||
from .types.embed import Embed as EmbedPayload
|
from .types.embed import Embed as EmbedPayload
|
||||||
from .abc import Snowflake
|
from .abc import Snowflake
|
||||||
from .abc import GuildChannel, PrivateChannel, Messageable
|
from .abc import GuildChannel
|
||||||
from .state import ConnectionState
|
from .state import ConnectionState
|
||||||
from .channel import TextChannel, GroupChannel, DMChannel
|
from .channel import TextChannel, GroupChannel, DMChannel
|
||||||
|
|
||||||
@ -445,13 +445,13 @@ class MessageReference:
|
|||||||
return f'<MessageReference message_id={self.message_id!r} channel_id={self.channel_id!r} guild_id={self.guild_id!r}>'
|
return f'<MessageReference message_id={self.message_id!r} channel_id={self.channel_id!r} guild_id={self.guild_id!r}>'
|
||||||
|
|
||||||
def to_dict(self) -> MessageReferencePayload:
|
def to_dict(self) -> MessageReferencePayload:
|
||||||
result: MessageReferencePayload = {'message_id': self.message_id} if self.message_id is not None else {}
|
result = {'message_id': self.message_id} if self.message_id is not None else {}
|
||||||
result['channel_id'] = self.channel_id
|
result['channel_id'] = self.channel_id
|
||||||
if self.guild_id is not None:
|
if self.guild_id is not None:
|
||||||
result['guild_id'] = self.guild_id
|
result['guild_id'] = self.guild_id
|
||||||
if self.fail_if_not_exists is not None:
|
if self.fail_if_not_exists is not None:
|
||||||
result['fail_if_not_exists'] = self.fail_if_not_exists
|
result['fail_if_not_exists'] = self.fail_if_not_exists
|
||||||
return result
|
return result # type: ignore
|
||||||
|
|
||||||
to_message_reference_dict = to_dict
|
to_message_reference_dict = to_dict
|
||||||
|
|
||||||
@ -1480,7 +1480,7 @@ class PartialMessage(Hashable):
|
|||||||
to_reference = Message.to_reference
|
to_reference = Message.to_reference
|
||||||
to_message_reference_dict = Message.to_message_reference_dict
|
to_message_reference_dict = Message.to_message_reference_dict
|
||||||
|
|
||||||
def __init__(self, *, channel: Union[GuildChannel, PrivateChannel], id: int):
|
def __init__(self, *, channel: Union[TextChannel, DMChannel], id: int):
|
||||||
if channel.type not in (ChannelType.text, ChannelType.news, ChannelType.private):
|
if channel.type not in (ChannelType.text, ChannelType.news, ChannelType.private):
|
||||||
raise TypeError(f'Expected TextChannel or DMChannel not {type(channel)!r}')
|
raise TypeError(f'Expected TextChannel or DMChannel not {type(channel)!r}')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user