Fix bug with GuildChannel.edit and Role.edit with positions.
I did not update the HTTP code for these two methods.
This commit is contained in:
		| @@ -124,8 +124,8 @@ class GuildChannel: | ||||
|             raise InvalidArgument('Channel position cannot be less than 0.') | ||||
|  | ||||
|         http = self._state.http | ||||
|         url = '{0}/{1.guild.id}/channels'.format(http.GUILDS, self) | ||||
|         channels = [c for c in self.guild.channels if isinstance(c, type(self))] | ||||
|         cls = type(self) | ||||
|         channels = [c for c in self.guild.channels if isinstance(c, cls)] | ||||
|  | ||||
|         if position >= len(channels): | ||||
|             raise InvalidArgument('Channel position cannot be greater than {}'.format(len(channels) - 1)) | ||||
| @@ -143,7 +143,7 @@ class GuildChannel: | ||||
|             channels.insert(position, self) | ||||
|  | ||||
|         payload = [{'id': c.id, 'position': index } for index, c in enumerate(channels)] | ||||
|         yield from http.patch(url, json=payload, bucket='move_channel') | ||||
|         yield from http.move_channel_position(self.guild.id, payload) | ||||
|  | ||||
|     def _fill_overwrites(self, data): | ||||
|         self._overwrites = [] | ||||
|   | ||||
| @@ -475,6 +475,10 @@ class HTTPClient: | ||||
|  | ||||
|         return self.request(Route('PATCH', '/channels/{channel_id}', channel_id=channel_id), json=payload) | ||||
|  | ||||
|     def move_channel_position(self, guild_id, positions): | ||||
|         r = Route('PATCH', '/guilds/{guild_id}/channels', guild_id=guild_id) | ||||
|         return self.request(r, json=positions) | ||||
|  | ||||
|     def create_channel(self, guild_id, name, channe_type, permission_overwrites=None): | ||||
|         payload = { | ||||
|             'name': name, | ||||
| @@ -598,6 +602,10 @@ class HTTPClient: | ||||
|         r = Route('POST', '/guilds/{guild_id}/roles', guild_id=guild_id) | ||||
|         return self.request(r, json=fields) | ||||
|  | ||||
|     def move_role_position(self, guild_id, positions): | ||||
|         r = Route('PATCH', '/guilds/{guild_id}/roles', guild_id=guild_id) | ||||
|         return self.request(r, json=positions) | ||||
|  | ||||
|     def add_role(self, guild_id, user_id, role_id): | ||||
|         r = Route('PUT', '/guilds/{guild_id}/members/{user_id}/roles/{role_id}', | ||||
|                   guild_id=guild_id, user_id=user_id, role_id=role_id) | ||||
|   | ||||
| @@ -175,7 +175,6 @@ class Role(Hashable): | ||||
|             return  # Save discord the extra request. | ||||
|  | ||||
|         http = self._state.http | ||||
|         url = '{0}/{1}/roles'.format(http.GUILDS, self.guild.id) | ||||
|  | ||||
|         change_range = range(min(self.position, position), max(self.position, position) + 1) | ||||
|         sorted_roles = sorted((x for x in self.guild.roles if x.position in change_range and x.id != self.id), | ||||
| @@ -189,7 +188,7 @@ class Role(Hashable): | ||||
|             roles.append(self.id) | ||||
|  | ||||
|         payload = [{"id": z[0], "position": z[1]} for z in zip(roles, change_range)] | ||||
|         yield from http.patch(url, json=payload, bucket='move_role') | ||||
|         yield from http.move_role_position(role.guild.id, payload) | ||||
|  | ||||
|     @asyncio.coroutine | ||||
|     def edit(self, **fields): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user