mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-25 02:23:04 +00:00 
			
		
		
		
	Client.invites_from now returns a list instead of a generator.
The old syntax is a bit awkward to use and has little benefit in this case. This is a breaking change.
This commit is contained in:
		| @@ -1877,8 +1877,7 @@ class Client: | |||||||
|     def invites_from(self, server): |     def invites_from(self, server): | ||||||
|         """|coro| |         """|coro| | ||||||
|  |  | ||||||
|         Returns a generator that yields all active instant invites from |         Returns a list of all active instant invites from a :class:`Server`. | ||||||
|         a :class:`Server`. |  | ||||||
|  |  | ||||||
|         You must have proper permissions to get this information. |         You must have proper permissions to get this information. | ||||||
|  |  | ||||||
| @@ -1894,25 +1893,25 @@ class Client: | |||||||
|         HTTPException |         HTTPException | ||||||
|             An error occurred while fetching the information. |             An error occurred while fetching the information. | ||||||
|  |  | ||||||
|         Yields |         Returns | ||||||
|         ------- |         ------- | ||||||
|         :class:`Invite` |         list of :class:`Invite` | ||||||
|             The invite with the message data parsed. |             The list of invites that are currently active. | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
|         def generator(data): |  | ||||||
|             for invite in data: |  | ||||||
|                 channel = server.get_channel(invite['channel']['id']) |  | ||||||
|                 invite['channel'] = channel |  | ||||||
|                 invite['server'] = server |  | ||||||
|                 yield Invite(**invite) |  | ||||||
|  |  | ||||||
|         url = '{0}/{1.id}/invites'.format(endpoints.SERVERS, server) |         url = '{0}/{1.id}/invites'.format(endpoints.SERVERS, server) | ||||||
|         resp = yield from aiohttp.get(url, headers=self.headers, loop=self.loop) |         resp = yield from aiohttp.get(url, headers=self.headers, loop=self.loop) | ||||||
|         log.debug(request_logging_format.format(method='GET', response=resp)) |         log.debug(request_logging_format.format(method='GET', response=resp)) | ||||||
|         yield from utils._verify_successful_response(resp) |         yield from utils._verify_successful_response(resp) | ||||||
|         data = yield from resp.json() |         data = yield from resp.json() | ||||||
|         return generator(data) |         result = [] | ||||||
|  |         for invite in data: | ||||||
|  |             channel = server.get_channel(invite['channel']['id']) | ||||||
|  |             invite['channel'] = channel | ||||||
|  |             invite['server'] = server | ||||||
|  |             result.append(Invite(**invite)) | ||||||
|  |  | ||||||
|  |         return result | ||||||
|  |  | ||||||
|     @asyncio.coroutine |     @asyncio.coroutine | ||||||
|     def accept_invite(self, invite): |     def accept_invite(self, invite): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user