Add support for bot integrations

This commit is contained in:
Maya
2021-05-29 16:43:33 +12:00
committed by GitHub
parent 7e1f8bf1b4
commit 4d7822493f
3 changed files with 185 additions and 51 deletions

View File

@@ -45,7 +45,7 @@ from .iterators import AuditLogIterator, MemberIterator
from .widget import Widget
from .asset import Asset
from .flags import SystemChannelFlags
from .integrations import Integration
from .integrations import BotIntegration, StreamIntegration, _integration_factory
__all__ = (
'Guild',
@@ -1803,7 +1803,14 @@ class Guild(Hashable):
The list of integrations that are attached to the guild.
"""
data = await self._state.http.get_all_integrations(self.id)
return [Integration(guild=self, data=d) for d in data]
def convert(d):
factory, itype = _integration_factory(d['type'])
if factory is None:
raise InvalidData('Unknown integration type {type!r} for integration ID {id}'.format_map(d))
return factory(guild=self, data=d)
return [convert(d) for d in data]
async def fetch_emojis(self):
r"""|coro|