Example #1
0
    def guilds_channels_create(
            self,
            guild,
            channel_type,
            name,
            bitrate=None,
            user_limit=None,
            permission_overwrites=[],
            nsfw=None,
            parent_id=None,
            position=None,
            reason=None):

        payload = {
            'name': name,
            'type': channel_type.value if isinstance(channel_type, EnumAttr) else channel_type,
            'permission_overwrites': [i.to_dict() for i in permission_overwrites],
            'parent_id': parent_id,
        }

        payload.update(optional(
            nsfw=nsfw,
            bitrate=bitrate,
            user_limit=user_limit,
            position=position,
        ))

        r = self.http(
            Routes.GUILDS_CHANNELS_CREATE,
            dict(guild=guild),
            json=payload,
            headers=_reason_header(reason))
        return Channel.create(self.client, r.json(), guild_id=guild)
Example #2
0
 def channels_modify(self, channel, reason=None, **kwargs):
     r = self.http(
         Routes.CHANNELS_MODIFY,
         dict(channel=channel),
         json=kwargs,
         headers=_reason_header(reason))
     return Channel.create(self.client, r.json())
Example #3
0
    def guilds_channels_create(self,
            guild,
            name,
            channel_type,
            bitrate=None,
            user_limit=None,
            permission_overwrites=[],
            parent_id=None,
            reason=None):

        payload = {
            'name': name,
            'channel_type': channel_type,
            'permission_overwrites': [i.to_dict() for i in permission_overwrites],
            'parent_id': parent_id,
        }

        if channel_type == 'text':
            pass
        elif channel_type == 'voice':
            if bitrate is not None:
                payload['bitrate'] = bitrate

            if user_limit is not None:
                payload['user_limit'] = user_limit
        else:
            # TODO: better error here?
            raise Exception('Invalid channel type: {}'.format(channel_type))

        r = self.http(
            Routes.GUILDS_CHANNELS_CREATE,
            dict(guild=guild),
            json=payload,
            headers=_reason_header(reason))
        return Channel.create(self.client, r.json(), guild_id=guild)
Example #4
0
 def channels_delete(self, channel):
     r = self.http(Routes.CHANNELS_DELETE, dict(channel=channel))
     return Channel.create(self.client, r.json())
Example #5
0
 def channels_modify(self, channel, **kwargs):
     r = self.http(Routes.CHANNELS_MODIFY, dict(channel=channel), json=kwargs)
     return Channel.create(self.client, r.json())
Example #6
0
 def channels_get(self, channel):
     r = self.http(Routes.CHANNELS_GET, dict(channel=channel))
     return Channel.create(self.client, r.json())
Example #7
0
 def guilds_channels_create(self, guild, **kwargs):
     r = self.http(Routes.GUILDS_CHANNELS_CREATE, dict(guild=guild), json=kwargs)
     return Channel.create(self.client, r.json(), guild_id=guild)
Example #8
0
 def users_me_dms_create(self, recipient_id):
     r = self.http(Routes.USERS_ME_DMS_CREATE, json={
         'recipient_id': recipient_id,
     })
     return Channel.create(self.client, r.json())
Example #9
0
 def channels_delete(self, channel, reason=None):
     r = self.http(
         Routes.CHANNELS_DELETE,
         dict(channel=channel),
         headers=_reason_header(reason))
     return Channel.create(self.client, r.json())