Split channel types.

This splits them into the following:

* DMChannel
* GroupChannel
* VoiceChannel
* TextChannel

This also makes the channels "stateful".
This commit is contained in:
Rapptz
2016-10-17 01:10:22 -04:00
parent 20251c54a7
commit 53ab263125
10 changed files with 718 additions and 177 deletions

View File

@@ -27,7 +27,7 @@ DEALINGS IN THE SOFTWARE.
from . import __version__ as library_version
from .user import User
from .member import Member
from .channel import Channel, PrivateChannel
from .channel import *
from .server import Server
from .message import Message
from .invite import Invite
@@ -261,9 +261,9 @@ class Client:
@asyncio.coroutine
def _resolve_destination(self, destination):
if isinstance(destination, Channel):
if isinstance(destination, TextChannel):
return destination.id, destination.server.id
elif isinstance(destination, PrivateChannel):
elif isinstance(destination, DMChannel):
return destination.id, None
elif isinstance(destination, Server):
return destination.id, destination.id
@@ -283,7 +283,7 @@ class Client:
# couldn't find it in cache so YOLO
return destination.id, destination.id
else:
fmt = 'Destination must be Channel, PrivateChannel, User, or Object. Received {0.__class__.__name__}'
fmt = 'Destination must be TextChannel, DMChannel, User, or Object. Received {0.__class__.__name__}'
raise InvalidArgument(fmt.format(destination))
def __getattr__(self, name):