Rename MessageChannel abc to Messageable.

This commit is contained in:
Rapptz
2016-12-31 06:58:05 -05:00
parent 633eacc982
commit d5b616fa11
4 changed files with 62 additions and 43 deletions

View File

@ -27,14 +27,14 @@ import asyncio
import discord.abc
import discord.utils
class Context(discord.abc.MessageChannel):
class Context(discord.abc.Messageable):
"""Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about
the invocation context. This class is not created manually and is instead
passed around to commands by passing in :attr:`Command.pass_context`.
This class implements the :class:`abc.MessageChannel` ABC.
This class implements the :class:`abc.Messageable` ABC.
Attributes
-----------
@ -117,8 +117,12 @@ class Context(discord.abc.MessageChannel):
ret = yield from command.callback(*arguments, **kwargs)
return ret
def _get_destination(self):
return self.channel.id, getattr(self.guild, 'id', None)
def _get_channel(self):
return self.channel
def _get_guild_id(self):
g = self.guild
return g.id if g is not None else None
@property
def cog(self):
@ -128,13 +132,6 @@ class Context(discord.abc.MessageChannel):
return None
return self.command.instance
@discord.utils.cached_property
def id(self):
# we need this to meet MessageChannel abc
# it is purposefully undocumented because it makes no logistic sense
# outside of providing the sugar of the main class.
return self.channel.id
@discord.utils.cached_property
def guild(self):
"""Returns the guild associated with this context's command. None if not available."""