diff --git a/discord/abc.py b/discord/abc.py index 32d843f63..242662d15 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -946,8 +946,6 @@ class GuildChannel: if len(permissions) > 0: raise TypeError('Cannot mix overwrite and keyword arguments.') - # TODO: wait for event - if overwrite is None: await http.delete_channel_permissions(self.id, target.id, reason=reason) elif isinstance(overwrite, PermissionOverwrite): diff --git a/discord/guild.py b/discord/guild.py index 0c50f5aeb..b95ac4247 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -502,56 +502,47 @@ class Guild(Hashable): self.approximate_member_count: Optional[int] = guild.get('approximate_member_count') self.premium_progress_bar_enabled: bool = guild.get('premium_progress_bar_enabled', False) self.owner_id: Optional[int] = utils._get_as_snowflake(guild, 'owner_id') - - self._sync(guild) self._large: Optional[bool] = None if self._member_count is None else self._member_count >= 250 - self.afk_channel: Optional[VocalGuildChannel] = self.get_channel(utils._get_as_snowflake(guild, 'afk_channel_id')) # type: ignore - - # TODO: refactor/remove? - def _sync(self, data: GuildPayload) -> None: - try: - self._large = data['large'] - except KeyError: - pass - - if 'channels' in data: - channels = data['channels'] + if 'channels' in guild: + channels = guild['channels'] for c in channels: factory, ch_type = _guild_channel_factory(c['type']) if factory: self._add_channel(factory(guild=self, data=c, state=self._state)) # type: ignore - for obj in data.get('voice_states', []): + self.afk_channel: Optional[VocalGuildChannel] = self.get_channel(utils._get_as_snowflake(guild, 'afk_channel_id')) # type: ignore + + for obj in guild.get('voice_states', []): self._update_voice_state(obj, int(obj['channel_id'])) cache_joined = self._state.member_cache_flags.joined cache_voice = self._state.member_cache_flags.voice self_id = self._state.self_id - for mdata in data.get('members', []): + for mdata in guild.get('members', []): member = Member(data=mdata, guild=self, state=self._state) # type: ignore # Members will have the 'user' key in this scenario if cache_joined or member.id == self_id or (cache_voice and member.id in self._voice_states): self._add_member(member) empty_tuple = () - for presence in data.get('presences', []): + for presence in guild.get('presences', []): user_id = int(presence['user']['id']) member = self.get_member(user_id) if member is not None: member._presence_update(presence, empty_tuple) # type: ignore - if 'threads' in data: - threads = data['threads'] + if 'threads' in guild: + threads = guild['threads'] for thread in threads: self._add_thread(Thread(guild=self, state=self._state, data=thread)) - if 'stage_instances' in data: - for s in data['stage_instances']: + if 'stage_instances' in guild: + for s in guild['stage_instances']: stage_instance = StageInstance(guild=self, data=s, state=self._state) self._stage_instances[stage_instance.id] = stage_instance - if 'guild_scheduled_events' in data: - for s in data['guild_scheduled_events']: + if 'guild_scheduled_events' in guild: + for s in guild['guild_scheduled_events']: scheduled_event = ScheduledEvent(data=s, state=self._state) self._scheduled_events[scheduled_event.id] = scheduled_event @@ -3484,7 +3475,6 @@ class Guild(Hashable): data = await self._state.http.create_role(self.id, reason=reason, **fields) role = Role(guild=self, data=data, state=self._state) - # TODO: add to cache return role async def edit_role_positions(self, positions: Mapping[Snowflake, int], *, reason: Optional[str] = None) -> List[Role]: diff --git a/discord/message.py b/discord/message.py index a3e788d0c..338d9c33e 100644 --- a/discord/message.py +++ b/discord/message.py @@ -1827,7 +1827,6 @@ class Message(PartialMessage, Hashable): author._update_from_message(member) # type: ignore except AttributeError: # It's a user here - # TODO: consider adding to cache here self.author = Member._from_message(message=self, data=member) def _handle_mentions(self, mentions: List[UserWithMemberPayload]) -> None: diff --git a/discord/reaction.py b/discord/reaction.py index 5f50ec8f4..c0cbb8ee5 100644 --- a/discord/reaction.py +++ b/discord/reaction.py @@ -89,7 +89,6 @@ class Reaction: self.count: int = data.get('count', 1) self.me: bool = data['me'] - # TODO: typeguard def is_custom_emoji(self) -> bool: """:class:`bool`: If this is a custom emoji.""" return not isinstance(self.emoji, str)