diff options
| author | Rapptz <[email protected]> | 2015-12-04 22:13:17 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-04 22:13:17 -0500 |
| commit | 79bdf2a72174a634aad0a752cad60d96ee8336f6 (patch) | |
| tree | 866d7d4ac7cf19071c7190ab4c9a749eedb2c851 /discord/client.py | |
| parent | Add channel management functions (diff) | |
| download | discord.py-79bdf2a72174a634aad0a752cad60d96ee8336f6.tar.xz discord.py-79bdf2a72174a634aad0a752cad60d96ee8336f6.zip | |
Add enumerators instead of strings.
Changes channel type, status and server region into 3.4 enums.
Diffstat (limited to 'discord/client.py')
| -rw-r--r-- | discord/client.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/discord/client.py b/discord/client.py index 9f675ed3..881bab6b 100644 --- a/discord/client.py +++ b/discord/client.py @@ -34,6 +34,7 @@ from .object import Object from .errors import * from .state import ConnectionState from . import utils +from .enums import ChannelType, ServerRegion import asyncio import aiohttp @@ -1085,7 +1086,7 @@ class Client: log.debug(request_success_log.format(response=r, json=payload, data=data)) @asyncio.coroutine - def create_channel(self, server, name, type='text'): + def create_channel(self, server, name, type=None): """|coro| Creates a :class:`Channel` in the specified :class:`Server`. @@ -1098,8 +1099,8 @@ class Client: The server to create the channel in. name : str The channel's name. - type : str - The type of channel to create. 'text' or 'voice'. + type : :class:`ChannelType` + The type of channel to create. Defaults to :attr:`ChannelType.text`. Raises ------- @@ -1117,9 +1118,12 @@ class Client: different than the one that will be added in cache. """ + if type is None: + type = ChannelType.text + payload = { 'name': name, - 'type': type + 'type': str(type) } url = '{0}/{1.id}/channels'.format(endpoints.SERVERS, server) @@ -1160,4 +1164,3 @@ class Client: response = yield from self.session.delete(url, headers=self.headers) log.debug(request_logging_format.format(method='DELETE', response=response)) yield from utils._verify_successful_response(response) - |