Inherits From namedtuple

A message stored on a stack inside of the state object, used for tracking previously sent messages in channels.

Name Type Description
id snowflake the id of the message
channel_id snowflake the id of the channel this message was sent in
author_id snowflake the id of the author of this message


Inherits From Config

A configuration object for determining how the State tracking behaves.

Name Type Description
track_messages bool Whether the state store should keep a buffer of previously sent messages. Message tracking allows for multiple higher-level shortcuts and can be highly useful when developing bots that need to delete their own messages. Message tracking is implemented using a deque and a namedtuple, meaning it should generally not have a high impact on memory, however users who find they do not need and may be experiencing memory pressure can disable this feature entirely using this attribute.
track_messages_size int The size of the messages deque for each channel. This value can be used to calculate the total number of possible `StackMessage` objects kept in memory, simply: `total_messages_size * total_channels`. This value can be tweaked based on usage and to help prevent memory pressure.
sync_guild_members bool If true, guilds will be automatically synced when they are initially loaded or joined. Generally this setting is OK for smaller bots, however bots in over 50 guilds will notice this operation can take a while to complete.


The State class is used to track global state based on events emitted from the GatewayClient. State tracking is a core component of the Disco client, providing the mechanism for most of the higher-level utility functions.

Name Type Description
EVENTS list(str) A list of all events the State object binds to
client `disco.client.Client` The Client instance this state is attached to
config `StateConfig` The configuration for this state instance
me `User` The currently logged in user
dms dict(snowflake, `Channel`) Mapping of all known DM Channels
guilds dict(snowflake, `Guild`) Mapping of all known/loaded Guilds
channels dict(snowflake, `Channel`) Weak mapping of all known/loaded Channels
users dict(snowflake, `User`) Weak mapping of all known/loaded Users
voice_states dict(str, `VoiceState`) Weak mapping of all known/active Voice States
messages Optional[dict(snowflake, deque)] Mapping of channel ids to deques containing `StackMessage` objects


init(self, client, config)


Unbinds all bound event listeners for this state object.


Binds all events for this state object, storing the listeners for later

fill_messages(self, channel)

on_ready(self, event)

on_message_create(self, event)

on_message_delete(self, event)

on_message_delete_bulk(self, event)

on_guild_create(self, event)

on_guild_update(self, event)

on_guild_delete(self, event)

on_channel_create(self, event)

on_channel_update(self, event)

on_channel_delete(self, event)

on_voice_state_update(self, event)

on_guild_member_add(self, event)

on_guild_member_update(self, event)

on_guild_member_remove(self, event)

on_guild_members_chunk(self, event)

on_guild_role_create(self, event)

on_guild_role_update(self, event)

on_guild_role_delete(self, event)

on_guild_emojis_update(self, event)

on_presence_update(self, event)

results matching ""

    No results matching ""