hikari.events.guild_events#

Events that fire when something occurs within a guild.

Module Contents#

class hikari.events.guild_events.AuditLogEntryCreateEvent[source]#

Bases: GuildEvent

Event sent when a guild audit log entry was created.

property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild that this event relates to.

entry: hikari.audit_logs.AuditLogEntry[source]#

The created entry.

class hikari.events.guild_events.BanCreateEvent[source]#

Bases: BanEvent

Event that is fired when a user is banned from a guild.

async fetch_ban()[source]#

Perform an API call to fetch the details about this ban.

This will include the optionally defined audit log reason for the ban.

Returns:
hikari.guilds.GuildBan

The ban details.

class hikari.events.guild_events.BanDeleteEvent[source]#

Bases: BanEvent

Event that is fired when a user is unbanned from a guild.

class hikari.events.guild_events.BanEvent[source]#

Bases: GuildEvent, abc.ABC

Event base for any guild ban or unban.

abstract property user: hikari.users.User[source]#

User that this ban event affects.

property user_id: hikari.snowflakes.Snowflake[source]#

User ID of the user that got banned.

async fetch_user()[source]#

Perform an API call to fetch the user this ban event affects.

Returns:
hikari.users.User

The user affected by this event.

class hikari.events.guild_events.EmojisUpdateEvent[source]#

Bases: GuildEvent

Event that is fired when the emojis in a guild are updated.

emojis: Sequence[hikari.emojis.KnownCustomEmoji][source]#

Sequence of all emojis in this guild.

old_emojis: Sequence[hikari.emojis.KnownCustomEmoji] | None[source]#

Sequence of all old emojis in this guild.

This will be None if it’s missing from the cache.

async fetch_emojis()[source]#

Perform an API call to retrieve an up-to-date view of the emojis.

Returns:
typing.Sequence[hikari.emojis.KnownCustomEmoji]

All emojis in the guild.

class hikari.events.guild_events.GuildAvailableEvent[source]#

Bases: GuildVisibilityEvent

Event fired when a guild becomes available.

This will occur on startup or after outages.

Note

Some fields like members and presences are included here but not on the other GuildUpdateEvent and GuildUnavailableEvent guild visibility event models.

property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild that this event relates to.

channels: Mapping[hikari.snowflakes.Snowflake, hikari.channels.PermissibleGuildChannel][source]#

Mapping of channel IDs to the channels in the guild.

chunk_nonce: str | None[source]#

Nonce used to request the member chunks for this guild.

This will be None if no chunks were requested.

Note

This is a synthetic field.

emojis: Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji][source]#

Mapping of emoji IDs to the emojis in the guild.

guild: hikari.guilds.GatewayGuild[source]#

Guild that just became available.

members: Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Member][source]#

Mapping of user IDs to the members in the guild.

presences: Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence][source]#

Mapping of user IDs to the presences for the guild.

roles: Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Role][source]#

Mapping of role IDs to the roles in the guild.

stickers: Mapping[hikari.snowflakes.Snowflake, hikari.stickers.GuildSticker][source]#

Mapping of sticker IDs to the stickers in the guild.

threads: Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel][source]#

Mapping of channel IDs to the threads in the guild.

voice_states: Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState][source]#

Mapping of user IDs to the voice states active in this guild.

class hikari.events.guild_events.GuildEvent[source]#

Bases: hikari.events.shard_events.ShardEvent, abc.ABC

Event base for any guild-bound event.

abstract property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild that this event relates to.

async fetch_guild()[source]#

Perform an API call to get the guild that this event relates to.

Returns:
hikari.guilds.RESTGuild

The guild this event occurred in.

async fetch_guild_preview()[source]#

Perform an API call to get the preview of the event’s guild.

Returns:
hikari.guilds.GuildPreview

The preview of the guild this event occurred in.

get_guild()[source]#

Get the cached guild that this event relates to, if known.

If not known, this will return None instead.

Returns:
typing.Optional[hikari.guilds.GatewayGuild]

The guild this event relates to, or None if not known.

class hikari.events.guild_events.GuildJoinEvent[source]#

Bases: GuildVisibilityEvent

Event fired when the bot joins a new guild.

Note

Some fields like members and presences are included here but not on the other GuildUpdateEvent and GuildUnavailableEvent guild visibility event models.

property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild that this event relates to.

channels: Mapping[hikari.snowflakes.Snowflake, hikari.channels.PermissibleGuildChannel][source]#

Mapping of channel IDs to the channels in the guild.

chunk_nonce: str | None[source]#

Nonce used to request the member chunks for this guild.

This will be None if no chunks were requested.

Note

This is a synthetic field.

emojis: Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji][source]#

Mapping of emoji IDs to the emojis in the guild.

guild: hikari.guilds.GatewayGuild[source]#

The guild the bot just joined.

members: Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Member][source]#

Mapping of user IDs to the members in the guild.

presences: Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence][source]#

Mapping of user IDs to the presences for the guild.

roles: Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Role][source]#

Mapping of role IDs to the roles in the guild.

stickers: Mapping[hikari.snowflakes.Snowflake, hikari.stickers.GuildSticker][source]#

Mapping of sticker IDs to the stickers in the guild.

threads: Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel][source]#

Mapping of channel IDs to the threads in the guild.

voice_states: Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState][source]#

Mapping of user IDs to the voice states active in this guild.

class hikari.events.guild_events.GuildLeaveEvent[source]#

Bases: GuildVisibilityEvent

Event fired when the bot is banned/kicked/leaves a guild.

This will also fire if the guild was deleted.

old_guild: hikari.guilds.GatewayGuild | None[source]#

The old guild object.

This will be None if the guild missing from the cache.

class hikari.events.guild_events.GuildUnavailableEvent[source]#

Bases: GuildVisibilityEvent

Event fired when a guild becomes unavailable because of an outage.

class hikari.events.guild_events.GuildUpdateEvent[source]#

Bases: GuildEvent

Event fired when an existing guild is updated.

property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild that this event relates to.

emojis: Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji][source]#

Mapping of emoji IDs to the emojis in the guild.

guild: hikari.guilds.GatewayGuild[source]#

Guild that was just updated.

old_guild: hikari.guilds.GatewayGuild | None[source]#

The old guild object.

This will be None if the guild missing from the cache.

roles: Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Role][source]#

Mapping of role IDs to the roles in the guild.

stickers: Mapping[hikari.snowflakes.Snowflake, hikari.stickers.GuildSticker][source]#

Mapping of sticker IDs to the stickers in the guild.

class hikari.events.guild_events.GuildVisibilityEvent[source]#

Bases: GuildEvent, abc.ABC

Event base for any event that changes the visibility of a guild.

This includes when a guild becomes available after an outage, when a guild becomes available on startup, when a guild becomes unavailable due to an outage, when the user is kicked/banned/leaves a guild, or when the user joins a new guild.

class hikari.events.guild_events.IntegrationCreateEvent[source]#

Bases: IntegrationEvent

Event that is fired when an integration is created in a guild.

property application_id: hikari.snowflakes.Snowflake | None[source]#

ID of Discord bot application this integration is connected to.

property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild that this event relates to.

property id: hikari.snowflakes.Snowflake[source]#

ID of the integration.

integration: hikari.guilds.Integration[source]#

Integration that was created.

class hikari.events.guild_events.IntegrationDeleteEvent[source]#

Bases: IntegrationEvent

Event that is fired when an integration is deleted in a guild.

class hikari.events.guild_events.IntegrationEvent[source]#

Bases: GuildEvent, abc.ABC

Event base for any integration related events.

abstract property application_id: hikari.snowflakes.Snowflake | None[source]#

ID of Discord bot application this integration is connected to.

abstract property id: hikari.snowflakes.Snowflake[source]#

ID of the integration.

async fetch_integrations()[source]#

Perform an API call to fetch some number of guild integrations.

Warning

The results of this are not clearly defined by Discord. The current behaviour appears to be that only the first 50 integrations actually get returned. Discord have made it clear that they are not willing to fix this in <https://github.com/discord/discord-api-docs/issues/1990>.

Returns:
typing.Sequence[hikari.guilds.Integration]

Some possibly random subset of the integrations in a guild, probably.

class hikari.events.guild_events.IntegrationUpdateEvent[source]#

Bases: IntegrationEvent

Event that is fired when an integration is updated in a guild.

property application_id: hikari.snowflakes.Snowflake | None[source]#

ID of Discord bot application this integration is connected to.

property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild that this event relates to.

property id: hikari.snowflakes.Snowflake[source]#

ID of the integration.

integration: hikari.guilds.Integration[source]#

Integration that was updated.

class hikari.events.guild_events.PresenceUpdateEvent[source]#

Bases: hikari.events.shard_events.ShardEvent

Event fired when a user in a guild updates their presence in a guild.

Sent when a guild member changes their presence in a specific guild.

If the user is changed (e.g. new username), then this may fire many times (once for every guild the bot is part of). This is a limitation of how Discord implements their event system, unfortunately.

Furthermore, if the target user is a bot and the bot only updates their presence on specific shards, this will only fire for the corresponding shards that saw the presence update.

property guild_id: hikari.snowflakes.Snowflake[source]#

Guild ID that the presence was updated in.

property user_id: hikari.snowflakes.Snowflake[source]#

User ID of the user that updated their presence.

old_presence: hikari.presences.MemberPresence | None[source]#

The old member presence object.

This will be None if the member presence missing from the cache.

presence: hikari.presences.MemberPresence[source]#

Member presence.

user: hikari.users.PartialUser | None[source]#

User that was updated.

This is a partial user object that only contains the fields that were updated on the user profile.

Will be None if the user itself did not change. This is always the case if the user only updated their member representation and did not change their user profile directly.

async fetch_user()[source]#

Perform an API call to fetch the user this event concerns.

Returns:
hikari.users.User

The user affected by this event.

get_user()[source]#

Get the full cached user, if it is available.

Returns:
typing.Optional[hikari.users.User]

The full cached user, or None if not cached.

class hikari.events.guild_events.StickersUpdateEvent[source]#

Bases: GuildEvent

Event that is fired when the emojis in a guild are updated.

old_stickers: Sequence[hikari.stickers.GuildSticker] | None[source]#

Sequence of all old stickers in this guild.

This will be None if it’s missing from the cache.

stickers: Sequence[hikari.stickers.GuildSticker][source]#

Sequence of all stickers in this guild.

async fetch_stickers()[source]#

Perform an API call to retrieve an up-to-date view of the emojis.

Returns:
typing.Sequence[hikari.stickers.GuildSticker]

All emojis in the guild.