Browse Source

Remove application command counts

pull/10109/head
dolfies 11 months ago
parent
commit
fb3d3adc8a
  1. 21
      discord/guild.py
  2. 9
      discord/state.py
  3. 5
      discord/types/gateway.py
  4. 2
      discord/types/guild.py
  5. 32
      docs/api.rst

21
discord/guild.py

@ -154,16 +154,9 @@ __all__ = (
'Guild',
'UserGuild',
'BanEntry',
'ApplicationCommandCounts',
)
class ApplicationCommandCounts(NamedTuple):
chat_input: int
user: int
message: int
class BanEntry(NamedTuple):
reason: Optional[str]
user: User
@ -338,6 +331,10 @@ class Guild(Hashable):
Returns the guild's name.
.. versionchanged:: 2.1
Removed ``application_command_counts`` as it is no longer provided by Discord.
Attributes
----------
name: :class:`str`
@ -408,10 +405,6 @@ class Guild(Hashable):
.. versionchanged:: 2.0
This field is now an enum instead of an :class:`int`.
application_command_counts: Optional[:class:`ApplicationCommandCounts`]
A namedtuple representing the number of application commands in the guild, separated by type.
.. versionadded:: 2.0
approximate_member_count: Optional[:class:`int`]
The approximate number of members in the guild. This is ``None`` unless the guild is obtained
using :meth:`Client.fetch_guild` with ``with_counts=True``.
@ -489,7 +482,6 @@ class Guild(Hashable):
'_member_list',
'keywords',
'primary_category_id',
'application_command_counts',
'hub_type',
'_joined_at',
'_cs_joined',
@ -514,7 +506,6 @@ class Guild(Hashable):
self._stage_instances: Dict[int, StageInstance] = {}
self._scheduled_events: Dict[int, ScheduledEvent] = {}
self._state: ConnectionState = state
self.application_command_counts: Optional[ApplicationCommandCounts] = None
self._member_count: Optional[int] = None
self._presence_count: Optional[int] = None
self._large: Optional[bool] = None
@ -703,10 +694,6 @@ class Guild(Hashable):
except KeyError:
pass
counts = guild.get('application_command_counts')
if counts:
self.application_command_counts = ApplicationCommandCounts(counts.get(1, 0), counts.get(2, 0), counts.get(3, 0))
for vs in guild.get('voice_states', []):
self._update_voice_state(vs, int(vs['channel_id']))

9
discord/state.py

@ -54,7 +54,7 @@ from math import ceil
from discord_protos import UserSettingsType
from .errors import ClientException, InvalidData, NotFound
from .guild import ApplicationCommandCounts, Guild
from .guild import Guild
from .activity import BaseActivity, create_activity, Session
from .user import User, ClientUser, Note
from .emoji import Emoji
@ -2716,12 +2716,7 @@ class ConnectionState:
)
return
counts = data['application_command_counts']
old_counts = guild.application_command_counts or ApplicationCommandCounts(0, 0, 0)
guild.application_command_counts = new_counts = ApplicationCommandCounts(
counts.get(1, 0), counts.get(2, 0), counts.get(3, 0)
)
self.dispatch('application_command_counts_update', guild, old_counts, new_counts)
self.dispatch('application_command_index_update', guild)
def parse_guild_emojis_update(self, data: gw.GuildEmojisUpdateEvent) -> None:
guild = self._get_guild(int(data['guild_id']))

5
discord/types/gateway.py

@ -572,7 +572,10 @@ class PassiveUpdateEvent(TypedDict):
class GuildApplicationCommandIndexUpdateEvent(TypedDict):
guild_id: Snowflake
application_command_counts: ApplicationCommandCounts
# All these fields are dead
# application_command_counts: ApplicationCommandCounts
# bot_users: List[PartialUser]
# version: Snowflake
class UserNoteUpdateEvent(TypedDict):

2
discord/types/guild.py

@ -125,7 +125,7 @@ class Guild(UnavailableGuild, _GuildMedia):
max_members: NotRequired[int]
premium_subscription_count: NotRequired[int]
max_video_channel_users: NotRequired[int]
application_command_counts: ApplicationCommandCounts
# application_command_counts: ApplicationCommandCounts
hub_type: Optional[Literal[0, 1, 2]]

32
docs/api.rst

@ -817,18 +817,14 @@ Guilds
:param after: A list of stickers after the update.
:type after: Sequence[:class:`GuildSticker`]
.. function:: on_application_command_counts_update(guild, before, after)
.. function:: on_application_command_index_update(guild)
Called when a :class:`Guild`\'s application command counts are updated.
Called when a :class:`Guild`\'s application command index is updated.
.. versionadded:: 2.0
.. versionadded:: 2.1
:param guild: The guild who got their application command counts updated.
:type guild: :class:`Guild`
:param before: A namedtuple of application command counts before the update.
:type before: :class:`ApplicationCommandCounts`
:param after: A namedtuple of application command counts after the update.
:type after: :class:`ApplicationCommandCounts`
.. function:: on_audit_log_entry_create(entry)
@ -7346,28 +7342,6 @@ Guild
:type: :class:`User`
.. class:: ApplicationCommandCounts
A namedtuple which represents the application command counts for a guild.
.. attribute:: chat_input
The number of chat input (slash) commands.
:type: :class:`int`
.. attribute:: user
The number of user commands.
:type: :class:`int`
.. attribute:: message
The number of message commands.
:type: :class:`int`
Role
~~~~~

Loading…
Cancel
Save