Add support for setting application_id
This commit is contained in:
parent
9ab58d302d
commit
1e7f139313
@ -113,6 +113,8 @@ class Client:
|
|||||||
Integer starting at ``0`` and less than :attr:`.shard_count`.
|
Integer starting at ``0`` and less than :attr:`.shard_count`.
|
||||||
shard_count: Optional[:class:`int`]
|
shard_count: Optional[:class:`int`]
|
||||||
The total number of shards.
|
The total number of shards.
|
||||||
|
application_id: :class:`int`
|
||||||
|
The client's application ID.
|
||||||
intents: :class:`Intents`
|
intents: :class:`Intents`
|
||||||
The intents that you want to enable for the session. This is a way of
|
The intents that you want to enable for the session. This is a way of
|
||||||
disabling and enabling certain gateway events from triggering and being sent.
|
disabling and enabling certain gateway events from triggering and being sent.
|
||||||
@ -306,6 +308,16 @@ class Client:
|
|||||||
"""
|
"""
|
||||||
return self._connection.voice_clients
|
return self._connection.voice_clients
|
||||||
|
|
||||||
|
@property
|
||||||
|
def application_id(self):
|
||||||
|
"""Optional[:class:`int`]: The client's application ID.
|
||||||
|
|
||||||
|
If this is not passed via ``__init__`` then this is retrieved
|
||||||
|
through the gateway when an event contains the data. Usually
|
||||||
|
after :func:`on_connect` is called.
|
||||||
|
"""
|
||||||
|
return self._connection.application_id
|
||||||
|
|
||||||
def is_ready(self):
|
def is_ready(self):
|
||||||
""":class:`bool`: Specifies if the client's internal cache is ready for use."""
|
""":class:`bool`: Specifies if the client's internal cache is ready for use."""
|
||||||
return self._ready.is_set()
|
return self._ready.is_set()
|
||||||
|
@ -113,6 +113,7 @@ class ConnectionState:
|
|||||||
self.hooks = hooks
|
self.hooks = hooks
|
||||||
self.shard_count = None
|
self.shard_count = None
|
||||||
self._ready_task = None
|
self._ready_task = None
|
||||||
|
self.application_id = utils._get_as_snowflake(options, 'application_id')
|
||||||
self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0)
|
self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0)
|
||||||
self.guild_ready_timeout = options.get('guild_ready_timeout', 2.0)
|
self.guild_ready_timeout = options.get('guild_ready_timeout', 2.0)
|
||||||
if self.guild_ready_timeout < 0:
|
if self.guild_ready_timeout < 0:
|
||||||
@ -452,6 +453,14 @@ class ConnectionState:
|
|||||||
self.user = user = ClientUser(state=self, data=data['user'])
|
self.user = user = ClientUser(state=self, data=data['user'])
|
||||||
self._users[user.id] = user
|
self._users[user.id] = user
|
||||||
|
|
||||||
|
if self.application_id is None:
|
||||||
|
try:
|
||||||
|
application = data['application']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.application_id = utils._get_as_snowflake(application, 'id')
|
||||||
|
|
||||||
for guild_data in data['guilds']:
|
for guild_data in data['guilds']:
|
||||||
self._add_guild_from_data(guild_data)
|
self._add_guild_from_data(guild_data)
|
||||||
|
|
||||||
@ -1153,6 +1162,14 @@ class AutoShardedConnectionState(ConnectionState):
|
|||||||
self.user = user = ClientUser(state=self, data=data['user'])
|
self.user = user = ClientUser(state=self, data=data['user'])
|
||||||
self._users[user.id] = user
|
self._users[user.id] = user
|
||||||
|
|
||||||
|
if self.application_id is None:
|
||||||
|
try:
|
||||||
|
application = data['application']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.application_id = utils._get_as_snowflake(application, 'id')
|
||||||
|
|
||||||
for guild_data in data['guilds']:
|
for guild_data in data['guilds']:
|
||||||
self._add_guild_from_data(guild_data)
|
self._add_guild_from_data(guild_data)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user