slidge.plugins.discord.client
#
Module Contents#
Classes#
Represents a client connection that connects to Discord. |
Attributes#
- class slidge.plugins.discord.client.Discord(session)[source]#
Bases:
discord.Client
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the
Client
.Parameters#
- max_messages: Optional[
int
] The maximum number of messages to store in the internal message cache. This defaults to
1000
. Passing inNone
disables the message cache.Changed in version 1.3: Allow disabling the message cache and change the default size to
1000
.- proxy: Optional[
str
] Proxy URL.
- proxy_auth: Optional[
aiohttp.BasicAuth
] An object that represents proxy HTTP Basic Authorization.
- member_cache_flags:
MemberCacheFlags
Allows for finer control over how the library caches members. If not given, defaults to cache as much as possible.
New in version 1.5.
- chunk_guilds_at_startup:
bool
Indicates if
on_ready()
should be delayed to chunk all guilds at start-up if necessary. This operation is incredibly slow for large amounts of guilds. The default isTrue
.New in version 1.5.
- request_guilds:
bool
Whether to request guilds at startup. Defaults to True.
New in version 2.0.
- status: Optional[
Status
] A status to start your presence with upon logging on to Discord.
- activity: Optional[
BaseActivity
] An activity to start your presence with upon logging on to Discord.
- allowed_mentions: Optional[
AllowedMentions
] Control how the client handles mentions by default on every message sent.
New in version 1.4.
- heartbeat_timeout:
float
The maximum numbers of seconds before timing out and restarting the WebSocket in the case of not receiving a HEARTBEAT_ACK. Useful if processing the initial packets take too long to the point of disconnecting you. The default timeout is 60 seconds.
- assume_unsync_clock:
bool
Whether to assume the system clock is unsynced. This applies to the ratelimit handling code. If this is set to
True
, the default, then the library uses the time to reset a rate limit bucket given by Discord. If this isFalse
then your system clock is used to calculate how long to sleep for. If this is set toFalse
it is recommended to sync your system clock to Google’s NTP server.New in version 1.3.
- enable_debug_events:
bool
Whether to enable events that are useful only for debugging gateway related information.
Right now this involves
on_socket_raw_receive()
andon_socket_raw_send()
. If this isFalse
then those events will not be dispatched (due to performance considerations). To enable these events, this must be set toTrue
. Defaults toFalse
.New in version 2.0.
- sync_presence:
bool
Whether to keep presences up-to-date across clients. The default behavior is
True
(what the client does).New in version 2.0.
- http_trace:
aiohttp.TraceConfig
The trace configuration to use for tracking HTTP requests the library does using
aiohttp
. This allows you to check requests the library is using. For more information, check the aiohttp documentation.New in version 2.0.
- captcha_handler: Optional[
CaptchaHandler
] A class that solves captcha challenges.
New in version 2.0.
Attributes#
- ws
The websocket gateway the client is currently connected to. Could be
None
.
- async on_typing(channel, user, _when)[source]#
- Parameters:
channel (MessageableChannel) –
user (Author) –
- async on_message_edit(before, after)[source]#
- Parameters:
before (discord.Message) –
after (discord.Message) –
- async on_reaction_add(reaction, user)[source]#
- Parameters:
reaction (discord.Reaction) –
user (Author) –
- async on_reaction_remove(reaction, user)[source]#
- Parameters:
reaction (discord.Reaction) –
user (Author) –
- async update_reactions(reaction, user)[source]#
- Parameters:
reaction (discord.Reaction) –
user (Author) –
- async on_presence_update(_before, after)[source]#
- Parameters:
_before (Union[discord.Member, discord.Relationship]) –
after (Union[discord.Member, discord.Relationship]) –
- async get_sender(author, channel)[source]#
- Parameters:
author (Author) –
channel (MessageableChannel) –
- Return type:
Optional[Union[slidge.plugins.discord.contact.Contact, slidge.plugins.discord.group.Participant]]
- Parameters:
session (slidge.plugins.discord.session.Session) –
- max_messages: Optional[