diff --git a/revolt/channel.py b/revolt/channel.py index 91c7df5..90470f2 100755 --- a/revolt/channel.py +++ b/revolt/channel.py @@ -107,6 +107,9 @@ class TextChannel(Channel, Messageable): if role_perms := data.get("role_permissions"): self.role_permissions = {role_id: ChannelPermissions(perms) for role_id, perms in role_perms.items()} + def _get_channel_id(self) -> str: + return self.id + @property def last_message(self) -> Message: return self.state.get_message(self.last_message_id) diff --git a/revolt/ext/commands/context.py b/revolt/ext/commands/context.py index 91269de..27e58ec 100755 --- a/revolt/ext/commands/context.py +++ b/revolt/ext/commands/context.py @@ -14,7 +14,7 @@ __all__ = ( "Context", ) -class Context: +class Context(revolt.Messageable): """Stores metadata the commands execution. Attributes @@ -38,6 +38,9 @@ class Context: """ __slots__ = ("command", "invoked_with", "args", "message", "server", "channel", "author", "view", "kwargs") + def _get_channel_id(self) -> str: + return self.channel.id + def __init__(self, command: Optional[Command], invoked_with: str, view: StringView, message: revolt.Message): self.command = command self.invoked_with = invoked_with diff --git a/revolt/messageable.py b/revolt/messageable.py index d1b7a65..38927e9 100755 --- a/revolt/messageable.py +++ b/revolt/messageable.py @@ -13,17 +13,19 @@ __all__ = ("Messageable",) class Messageable: """Base class for all channels that you can send messages in - + Attributes ----------- id: :class:`str` The id of the channel """ - id: str state: State __slots__ = () + def _get_channel_id(self) -> str: + raise NotImplementedError + async def send(self, content: Optional[str] = None, *, embeds: Optional[list[Embed]] = None, embed: Optional[Embed] = None, attachments: Optional[list[File]] = None, replies: Optional[list[MessageReply]] = None, reply: Optional[MessageReply] = None) -> Message: """Sends a message in a channel, you must send at least one of either `content`, `embeds` or `attachments` @@ -52,5 +54,5 @@ class Messageable: embed_payload = [embed.to_dict() for embed in embeds] if embeds else None reply_payload = [reply.to_dict() for reply in replies] if replies else None - message = await self.state.http.send_message(self.id, content, embed_payload, attachments, reply_payload) + message = await self.state.http.send_message(self._get_channel_id(), content, embed_payload, attachments, reply_payload) return self.state.add_message(message)