Skip to main content

Module payload

Module payload 

Source
Expand description

The payloads the client builds itself (D-225): events with the state before them (D-221, D-227), events derived from a list (D-223) and shard lifecycle events (D-226).

Events with a previous state have two fields (D-228):

  • old: what the cache held before the event — None without a cache, with the resource disabled in CacheConfig, or for something it never received (the counterpart of a discord.js partial);
  • new: Discord’s data for the event, as its djs-model type. For a removal, this is Discord’s notice (IDs) and old the removed object.

Each of them dereferences to new, so its fields read as on an event without a wrapper:

client.on(Events::GuildMemberUpdate, |_ctx, update| async move {
    let old_nick = update.old.as_ref().and_then(|old| old.nick.clone());
    println!("{} was {old_nick:?}, is now {:?}", update.user.id, update.nick);
    Ok(())
});

Structs§

ChannelDelete
The payload of Events::ChannelDelete.
ChannelUpdate
The payload of Events::ChannelUpdate.
GuildDelete
The payload of Events::GuildDelete: new only holds the guild’s ID, old the cached guild.
GuildEmojiCreate
The payload of Events::GuildEmojiCreate: a new emoji.
GuildEmojiDelete
The payload of Events::GuildEmojiDelete: a deleted emoji, as the cache held it.
GuildEmojiUpdate
The payload of Events::GuildEmojiUpdate: a changed emoji, before and after.
GuildMemberRemove
The payload of Events::GuildMemberRemove: new holds the guild ID and the user, old the cached member.
GuildMemberUpdate
The payload of Events::GuildMemberUpdate.
GuildRoleDelete
The payload of Events::GuildRoleDelete: new only holds the IDs, old the cached role.
GuildRoleUpdate
The payload of Events::GuildRoleUpdate.
GuildScheduledEventDelete
The payload of Events::GuildScheduledEventDelete.
GuildScheduledEventUpdate
The payload of Events::GuildScheduledEventUpdate.
GuildSoundboardSoundDelete
The payload of Events::GuildSoundboardSoundDelete: new only holds the IDs, old the cached sound.
GuildSoundboardSoundUpdate
The payload of Events::GuildSoundboardSoundUpdate.
GuildStickerCreate
The payload of Events::GuildStickerCreate: a new sticker.
GuildStickerDelete
The payload of Events::GuildStickerDelete: a deleted sticker, as the cache held it.
GuildStickerUpdate
The payload of Events::GuildStickerUpdate: a changed sticker, before and after.
GuildUnavailable
The payload of Events::GuildUnavailable: new only holds the guild’s ID, old the cached guild (which the cache keeps while the guild is unavailable).
GuildUpdate
The payload of Events::GuildUpdate.
Invalidated
The payload of Events::Invalidated. The shard is Context::shard_id.
MessageBulkDelete
The payload of Events::MessageBulkDelete: new holds the IDs, old the messages the cache held (empty without a message cache).
MessageDelete
The payload of Events::MessageDelete: new only holds the IDs, old the cached message.
MessageUpdate
The payload of Events::MessageUpdate.
PresenceUpdate
The payload of Events::PresenceUpdate.
ShardReconnecting
The payload of Events::ShardReconnecting. The shard is Context::shard_id.
ShardResume
The payload of Events::ShardResume.
StageInstanceDelete
The payload of Events::StageInstanceDelete.
StageInstanceUpdate
The payload of Events::StageInstanceUpdate.
ThreadDelete
The payload of Events::ThreadDelete: new only holds the thread’s IDs, old the cached thread.
ThreadUpdate
The payload of Events::ThreadUpdate.
UserUpdate
The payload of Events::UserUpdate.
VoiceStateUpdate
The payload of Events::VoiceStateUpdate.