async def parse_guild_role_update(self, data, old): if old: guild = await self._get_guild(int(data["guild_id"])) if guild: role = Role(guild=guild, state=self, data=data["role"]) old_role = Role(guild=guild, state=self, data=old) self.dispatch("guild_role_update", old_role, role)
async def _roles(self): roles = [] for role in await self._state._members_get_all("guild", key_id=self.id, name="role"): roles.append(Role(guild=self, state=self._state, data=role)) return roles
async def get_role(self, role_id): role = await self._state.get(f"role:{self.id}:{role_id}") if role: return Role(guild=self, state=self._state, data=tools.upgrade_payload(role)) return None
async def _roles(self): return sorted( [ Role(guild=self, state=self._state, data=tools.upgrade_payload(x)) for x in await self._state._members_get_all("guild", key_id=self.id, name="role") ] )
async def get_role(self, role_id): role = await self._state.get(f"role:{self.id}:{role_id}") if role: return Role(guild=self, state=self._state, data=role) return None
def make_guild(self, **kwargs): data = { 'id': 0, 'name': 'Repldex 2 Editors', 'icon': None, 'splash': None, 'discovery_splash': None, 'owner_id': '0', 'region': 'en-US', 'afk_channel_id': '0', 'afk_timeout': 0, 'verification_level': 0, 'default_message_notifications': 0, 'explicit_content_filter': 0, 'roles': {}, 'emojis': [], 'features': [], 'mfa_level': 0, 'application_id': None, 'system_channel_id': None, 'system_channel_flags': 0, 'rules_channel_id': None, 'joined_at': '1970-01-01T00:00:01+00:00', 'vanity_url_code': None, 'description': None, 'banner': None, 'premium_tier': 0, 'premium_subscription_count': 0, 'preferred_locale': 'en-US', 'public_updates_channel_id': None, 'member_count': 0 } data.update(kwargs) self.client._connection.parse_guild_create(data) guild = self.client.get_guild(int(data['id'])) default_role = Role(guild=guild, state=self.client._connection, data={ 'id': str(guild.id), 'name': '@everyone', 'color': '000000', 'hoist': True, 'position': 0, 'permissions': '', 'managed': False, 'mentionable': False }) guild._roles[default_role.id] = default_role # the bot is always a member of the guild self.make_member(guild, self.client._connection.user) return guild
async def get_role(self, role_id): result = await self._state._get(f"role:{self.id}:{role_id}") if result: Role(guild=self, state=self._state, data=result) return result