bevy_discord/
messages.rs

1//! Contains all the Bevy messages that can be emitted by the Discord integration.
2//!
3//! This module is split into two main feature-gated submodules:
4//!
5//! - [`bot`] - Events related to Discord bot functionality (requires `bot` feature)
6//! - [`rich_presence`] - Events related to Discord Rich Presence integration (requires `rich_presence` feature)
7
8use crate::common::create_message_collection_and_handler;
9
10#[cfg(feature = "bot")]
11#[cfg_attr(docsrs, doc(cfg(feature = "bot")))]
12pub mod bot {
13    //! This module contains all the bevy [Message] that are send by `bot` feature
14
15    use bevy_ecs::prelude::Message;
16    use serenity::all::*;
17    use serenity::model::channel::Message as SMessage;
18    use std::collections::HashMap;
19
20    /// Dispatched upon startup.
21    ///
22    /// Provides data about the bot and the guilds it’s in.
23    ///
24    /// Once, dispatched it automatically inserts [DiscordHttpResource](crate::res::DiscordHttpResource)
25    /// to the bevy app.
26    #[derive(Message, Debug, Clone)]
27    pub struct BotReadyMessage {
28        pub ctx: Context,
29        pub data_about_bot: Ready,
30    }
31
32    /// Dispatched when the permissions of an application command was updated.
33    ///
34    /// Provides said permission’s data.
35    #[derive(Message, Debug, Clone)]
36    pub struct CommandPermissionsUpdateMessage {
37        pub ctx: Context,
38        pub permission: CommandPermissions,
39    }
40
41    /// Dispatched when an auto moderation rule was created.
42    ///
43    /// Provides said rule’s data.
44    #[derive(Message, Debug, Clone)]
45    pub struct AutoModerationRuleCreateMessage {
46        pub ctx: Context,
47        pub rule: Rule,
48    }
49
50    /// Dispatched when an auto moderation rule was updated.
51    ///
52    /// Provides said rule’s data.
53    #[derive(Message, Debug, Clone)]
54    pub struct AutoModerationRuleUpdateMessage {
55        pub ctx: Context,
56        pub rule: Rule,
57    }
58
59    /// Dispatched when an auto moderation rule was deleted.
60    ///
61    /// Provides said rule’s data.
62    #[derive(Message, Debug, Clone)]
63    pub struct AutoModerationRuleDeleteMessage {
64        pub ctx: Context,
65        pub rule: Rule,
66    }
67
68    /// Dispatched when an auto moderation rule was triggered and an action was executed.
69    ///
70    /// Provides said action execution’s data.
71    #[derive(Message, Debug, Clone)]
72    pub struct AutoModerationActionExecutionMessage {
73        pub ctx: Context,
74        pub execution: ActionExecution,
75    }
76
77    /// Dispatched when the cache has received and inserted all data from guilds.
78    ///
79    /// This process happens upon starting your bot and should be fairly quick. However, cache actions
80    /// performed prior this event may fail as the data could be not inserted yet.
81    ///
82    /// Provides the cached guilds’ ids.
83    #[cfg(feature = "bot_cache")]
84    #[cfg_attr(docsrs, doc(cfg(feature = "bot_cache")))]
85    #[derive(Message, Debug, Clone)]
86    pub struct CacheReadMessage {
87        pub ctx: Context,
88        pub guilds: Vec<GuildId>,
89    }
90
91    /// Dispatched when every shard has received a Ready event
92    #[cfg(feature = "bot_cache")]
93    #[cfg_attr(docsrs, doc(cfg(feature = "bot_cache")))]
94    #[derive(Message, Debug, Clone)]
95    pub struct ShardsReadyMessage {
96        pub ctx: Context,
97        pub total_shards: u32,
98    }
99
100    /// Dispatched when a channel is created.
101    ///
102    /// Provides said channel’s data.
103    #[derive(Message, Debug, Clone)]
104    pub struct ChannelCreateMessage {
105        pub ctx: Context,
106        pub channel: GuildChannel,
107    }
108
109    /// Dispatched when a category is created.
110    ///
111    /// Provides said category’s data.
112    #[derive(Message, Debug, Clone)]
113    pub struct CategoryCreateMessage {
114        pub ctx: Context,
115        pub category: GuildChannel,
116    }
117
118    /// Dispatched when a category is deleted.
119    ///
120    /// Provides said category’s data.
121    #[derive(Message, Debug, Clone)]
122    pub struct CategoryDeleteMessage {
123        pub ctx: Context,
124        pub category: GuildChannel,
125    }
126
127    /// Dispatched when a channel is deleted.
128    ///
129    /// Provides said channel’s data.
130    #[derive(Message, Debug, Clone)]
131    pub struct ChannelDeleteMessage {
132        pub ctx: Context,
133        pub channel: GuildChannel,
134        pub messages: Option<Vec<SMessage>>,
135    }
136
137    /// Dispatched when a pin is added, deleted.
138    ///
139    /// Provides said pin’s data.
140    #[derive(Message, Debug, Clone)]
141    pub struct ChannelPinUpdateMessage {
142        pub ctx: Context,
143        pub pin: ChannelPinsUpdateEvent,
144    }
145
146    /// Dispatched when a channel is updated.
147    ///
148    /// The old channel data is only provided when the `bot_cache` feature is enabled.
149    #[derive(Message, Debug, Clone)]
150    pub struct ChannelUpdateMessage {
151        pub ctx: Context,
152        pub old: Option<GuildChannel>,
153        pub new: GuildChannel,
154    }
155
156    /// Dispatched when a new audit log entry is created.
157    ///
158    /// Provides said entry’s data and the id of the guild where it was created.
159    #[derive(Message, Debug, Clone)]
160    pub struct GuildAuditLogEntryCreateMessage {
161        pub ctx: Context,
162        pub entry: AuditLogEntry,
163        pub guild_id: GuildId,
164    }
165
166    /// Dispatched when a user is banned from a guild.
167    ///
168    /// Provides the guild’s id and the banned user’s data.
169    #[derive(Message, Debug, Clone)]
170    pub struct GuildBanAdditionMessage {
171        pub ctx: Context,
172        pub guild_id: GuildId,
173        pub banned_user: User,
174    }
175
176    /// Dispatched when a user’s ban is lifted from a guild.
177    ///
178    /// Provides the guild’s id and the lifted user’s data.
179    #[derive(Message, Debug, Clone)]
180    pub struct GuildBanRemovalMessage {
181        pub ctx: Context,
182        pub guild_id: GuildId,
183        pub unbanned_user: User,
184    }
185
186    /// Dispatched when a guild is created; or an existing guild’s data is sent to us.
187    ///
188    /// Provides the guild’s data and whether the guild is new (only when `bot_cache` feature is enabled).
189    #[derive(Message, Debug, Clone)]
190    pub struct GuildCreateMessage {
191        pub ctx: Context,
192        pub guild: Guild,
193        pub is_new: Option<bool>,
194    }
195
196    /// Dispatched when a guild is deleted.
197    ///
198    /// Provides the partial data of the guild sent by discord, and the full data from the cache,
199    /// if `bot_cache` feature is enabled and the data is available.
200    ///
201    /// The [`UnavailableGuild::unavailable`] flag in the partial data determines the status of the guild. If the flag
202    /// is false, the bot was removed from the guild, either by being kicked or banned. If the
203    /// flag is true, the guild went offline.
204    #[derive(Message, Debug, Clone)]
205    pub struct GuildDeleteMessage {
206        pub ctx: Context,
207        pub incomplete: UnavailableGuild,
208        pub full: Option<Guild>,
209    }
210
211    /// Dispatched when the emojis are updated.
212    ///
213    /// Provides the guild’s id and the new state of the emojis in the guild.
214    #[derive(Message, Debug, Clone)]
215    pub struct GuildEmojisUpdateMessage {
216        pub ctx: Context,
217        pub guild_id: GuildId,
218        pub current_state: HashMap<EmojiId, Emoji>,
219    }
220
221    /// Dispatched when a guild’s integration is added, updated or removed.
222    ///
223    /// Provides the guild’s id.
224    #[derive(Message, Debug, Clone)]
225    pub struct GuildIntegrationsUpdateMessage {
226        pub ctx: Context,
227        pub guild_id: GuildId,
228    }
229
230    /// Dispatched when a user joins a guild.
231    ///
232    /// Provides the guild’s id and the user’s member data.
233    ///
234    /// Note: This event will not trigger unless the “guild members” privileged intent is enabled
235    /// on the bot application page.
236    #[derive(Message, Debug, Clone)]
237    pub struct GuildMemberAdditionMessage {
238        pub ctx: Context,
239        pub new_member: Member,
240    }
241
242    /// Dispatched when a user’s membership ends by leaving, getting kicked, or being banned.
243    ///
244    /// Provides the guild’s id, the user’s data, and the user’s member data if cache feature is
245    /// enabled and the data is available.
246    ///
247    /// Note: This event will not trigger unless the “guild members” privileged intent is enabled
248    /// on the bot application page.
249    #[derive(Message, Debug, Clone)]
250    pub struct GuildMemberRemovalMessage {
251        pub ctx: Context,
252        pub guild_id: GuildId,
253        pub user: User,
254        pub member_data_if_available: Option<Member>,
255    }
256
257    /// Dispatched when a member is updated (e.g their nickname is updated).
258    ///
259    /// Provides the member’s old and new data (if cache feature is enabled and data is available)
260    /// and the new raw data about updated fields.
261    ///
262    /// Note: This event will not trigger unless the “guild members” privileged intent is enabled
263    /// on the bot application page.
264    #[derive(Message, Debug, Clone)]
265    pub struct GuildMemberUpdateMessage {
266        pub ctx: Context,
267        pub old_if_available: Option<Member>,
268        pub new: Option<Member>,
269        pub event: GuildMemberUpdateEvent,
270    }
271
272    /// Dispatched when the data for offline members was requested.
273    ///
274    /// Provides the guild’s id and the data.
275    #[derive(Message, Debug, Clone)]
276    pub struct GuildMembersChunkMessage {
277        pub ctx: Context,
278        pub chunk: GuildMembersChunkEvent,
279    }
280
281    /// Dispatched when a role is created.
282    ///
283    /// Provides the guild’s id and the new role’s data.
284    #[derive(Message, Debug, Clone)]
285    pub struct GuildRoleCreateMessage {
286        pub ctx: Context,
287        pub new: Role,
288    }
289
290    /// Dispatched when a role is deleted.
291    /// Provides the guild’s id, the role’s id and its data (if `bot_cache` feature is enabled
292    /// and the data is available).
293    #[derive(Message, Debug, Clone)]
294    pub struct GuildRoleDeleteMessage {
295        pub ctx: Context,
296        pub guild_id: GuildId,
297        pub removed_role_id: RoleId,
298        pub removed_role_data_if_available: Option<Role>,
299    }
300
301    /// Dispatched when a role is updated.
302    ///
303    /// Provides the guild’s id, the role’s old (if `bot_cache` feature is enabled and the data
304    /// is available) and new data.
305    #[derive(Message, Debug, Clone)]
306    pub struct GuildRoleUpdateMessage {
307        pub ctx: Context,
308        pub old_data_if_available: Option<Role>,
309        pub new: Role,
310    }
311
312    /// Dispatched when the stickers are updated.
313    ///
314    /// Provides the guild’s id and the new state of the stickers in the guild.
315    #[derive(Message, Debug, Clone)]
316    pub struct GuildStickersUpdateMessage {
317        pub ctx: Context,
318        pub guild_id: GuildId,
319        pub current_state: HashMap<StickerId, Sticker>,
320    }
321
322    /// Dispatched when the guild is updated.
323    ///
324    /// Provides the guild’s old data (if `bot_cache` feature is enabled and the data is
325    /// available) and the new data.
326    #[derive(Message, Debug, Clone)]
327    pub struct GuildUpdateMessage {
328        pub ctx: Context,
329        pub old_data_if_available: Option<Guild>,
330        pub new_data: PartialGuild,
331    }
332
333    /// Dispatched when a invite is created.
334    ///
335    /// Provides data about the invite.
336    #[derive(Message, Debug, Clone)]
337    pub struct InviteCreateMessage {
338        pub ctx: Context,
339        pub data: InviteCreateEvent,
340    }
341
342    /// Dispatched when a invite is deleted.
343    ///
344    /// Provides data about the invite.
345    #[derive(Message, Debug, Clone)]
346    pub struct InviteDeleteMessage {
347        pub ctx: Context,
348        pub data: InviteDeleteEvent,
349    }
350
351    /// Dispatched when a message is created.
352    ///
353    /// Provides the message’s data.
354    // TODO: Is the name good??
355    #[derive(Message, Debug, Clone)]
356    pub struct DiscordMessage {
357        pub ctx: Context,
358        pub new_message: SMessage,
359    }
360
361    /// Dispatched when a message is deleted.
362    ///
363    /// Provides the guild’s id, the channel’s id and the message’s id.
364    // TODO: Is the name good??
365    #[derive(Message, Debug, Clone)]
366    pub struct DiscordMessageDeleteMessage {
367        pub ctx: Context,
368        pub channel_id: ChannelId,
369        pub deleted_message_id: MessageId,
370        pub guild_id: Option<GuildId>,
371    }
372
373    /// Dispatched when multiple messages were deleted at once.
374    ///
375    /// Provides the guild’s id, channel’s id and the deleted messages’ ids.
376    // TODO: Is the name good??
377    #[derive(Message, Debug, Clone)]
378    pub struct DiscordMessageDeleteBulkMessage {
379        pub ctx: Context,
380        pub channel_id: ChannelId,
381        pub multiple_deleted_messages_ids: Vec<MessageId>,
382        pub guild_id: Option<GuildId>,
383    }
384
385    /// Dispatched when a message is updated.
386    ///
387    /// Provides the message update data, as well as the actual old and new message if `bot_cache`
388    /// feature is enabled and the data is available.
389    // TODO: Is the name good??
390    #[derive(Message, Debug, Clone)]
391    pub struct DiscordMessageUpdateMessage {
392        pub ctx: Context,
393        pub old_if_available: Option<SMessage>,
394        pub new: Option<SMessage>,
395        pub event: MessageUpdateEvent,
396    }
397
398    /// Dispatched when a new reaction is attached to a message.
399    ///
400    /// Provides the reaction’s data.
401    #[derive(Message, Debug, Clone)]
402    pub struct ReactionAddMessage {
403        pub ctx: Context,
404        pub add_reaction: Reaction,
405    }
406
407    /// Dispatched when a reaction is detached from a message.
408    ///
409    /// Provides the reaction’s data.
410    #[derive(Message, Debug, Clone)]
411    pub struct ReactionRemoveMessage {
412        pub ctx: Context,
413        pub removed_reaction: Reaction,
414    }
415
416    /// Dispatched when all reactions of a message are detached from a message.
417    ///
418    /// Provides the channel’s id and the message’s id.
419    #[derive(Message, Debug, Clone)]
420    pub struct ReactionRemoveAllMessage {
421        pub ctx: Context,
422        pub channel_id: ChannelId,
423        pub removed_from_message_id: MessageId,
424    }
425
426    /// Dispatched when all reactions of a message are detached from a message.
427    ///
428    /// Provides the channel’s id and the message’s id.
429    #[derive(Message, Debug, Clone)]
430    pub struct ReactionRemoveEmojiMessage {
431        pub ctx: Context,
432        pub removed_reactions: Reaction,
433    }
434
435    /// Dispatched when a user’s presence is updated (e.g off -> on).
436    ///
437    /// Provides the presence’s new data.
438    ///
439    /// Note: This event will not trigger unless the “guild presences” privileged intent is enabled
440    /// on the bot application page.
441    #[derive(Message, Debug, Clone)]
442    pub struct PresenceUpdateMessage {
443        pub ctx: Context,
444        pub new_data: Presence,
445    }
446
447    /// Dispatched upon reconnection.
448    #[derive(Message, Debug, Clone)]
449    pub struct ResumeMessage {
450        pub ctx: Context,
451        pub event: ResumedEvent,
452    }
453
454    /// Dispatched when a shard’s connection stage is updated
455    ///
456    /// Provides the context of the shard and the event information about the update.
457    #[derive(Message, Debug, Clone)]
458    pub struct ShardStageUpdateMessage {
459        pub ctx: Context,
460        pub event: ShardStageUpdateEvent,
461    }
462
463    /// Dispatched when a user starts typing.
464    #[derive(Message, Debug, Clone)]
465    pub struct TypingStartMessage {
466        pub ctx: Context,
467        pub event: TypingStartEvent,
468    }
469
470    /// Dispatched when the bot’s data is updated.
471    ///
472    /// Provides the old (if `bot_cache` feature is enabled and the data is available) and new data.
473    #[derive(Message, Debug, Clone)]
474    pub struct UserUpdateMessage {
475        pub ctx: Context,
476        pub old_data: Option<CurrentUser>,
477        pub new: CurrentUser,
478    }
479
480    /// Dispatched when a guild’s voice server was updated (or changed to another one).
481    ///
482    /// Provides the voice server’s data.
483    #[derive(Message, Debug, Clone)]
484    pub struct VoiceServerUpdateMessage {
485        pub ctx: Context,
486        pub event: VoiceServerUpdateEvent,
487    }
488
489    /// Dispatched when a user joins, leaves or moves to a voice channel.
490    ///
491    /// Provides the guild’s id (if available) and the old state (if `bot_cache` feature is enabled
492    /// and [`GatewayIntents::GUILDS`] is enabled) and the new state of the guild’s voice channels.
493    #[derive(Message, Debug, Clone)]
494    pub struct VoiceStateUpdateMessage {
495        pub ctx: Context,
496        pub old: Option<VoiceState>,
497        pub new: VoiceState,
498    }
499
500    /// Dispatched when a voice channel’s status is updated.
501    ///
502    /// Provides the status, channel’s id and the guild’s id.
503    #[derive(Message, Debug, Clone)]
504    pub struct VoiceChannelStatusUpdateMessage {
505        pub ctx: Context,
506        pub old: Option<String>,
507        pub status: Option<String>,
508        pub id: ChannelId,
509        pub guild_id: GuildId,
510    }
511
512    /// Dispatched when a guild’s webhook is updated.
513    ///
514    /// Provides the guild’s id and the channel’s id the webhook belongs in.
515    #[derive(Message, Debug, Clone)]
516    pub struct WebhookUpdateMessage {
517        pub ctx: Context,
518        pub guild_id: GuildId,
519        pub belongs_to_channel_id: ChannelId,
520    }
521
522    /// Dispatched when an interaction is created (e.g a slash command was used or a button was
523    /// clicked).
524    ///
525    /// Provides the created interaction.
526    #[derive(Message, Debug, Clone)]
527    pub struct InteractionCreateMessage {
528        pub ctx: Context,
529        pub interaction: Interaction,
530    }
531
532    /// Dispatched when a guild integration is created.
533    ///
534    /// Provides the created integration.
535    #[derive(Message, Debug, Clone)]
536    pub struct IntegrationCreateMessage {
537        pub ctx: Context,
538        pub integration: Integration,
539    }
540
541    /// Dispatched when a guild integration is updated.
542    ///
543    /// Provides the updated integration.
544    #[derive(Message, Debug, Clone)]
545    pub struct IntegrationUpdateMessage {
546        pub ctx: Context,
547        pub integration: Integration,
548    }
549
550    /// Dispatched when a stage instance is created.
551    ///
552    /// Provides the created stage instance.
553    #[derive(Message, Debug, Clone)]
554    pub struct StageInstanceCreateMessage {
555        pub ctx: Context,
556        pub stage_instance: StageInstance,
557    }
558
559    /// Dispatched when a stage instance is updated.
560    ///
561    /// Provides the updated stage instance.
562    #[derive(Message, Debug, Clone)]
563    pub struct StageInstanceUpdateMessage {
564        pub ctx: Context,
565        pub stage_instance: StageInstance,
566    }
567
568    /// Dispatched when a stage instance is deleted.
569    ///
570    /// Provides the deleted stage instance.
571    #[derive(Message, Debug, Clone)]
572    pub struct StageInstanceDeleteMessage {
573        pub ctx: Context,
574        pub stage_instance: StageInstance,
575    }
576
577    /// Dispatched when a thread is created or the current user is added to a private thread.
578    ///
579    /// Provides the thread.
580    #[derive(Message, Debug, Clone)]
581    pub struct ThreadCreateMessage {
582        pub ctx: Context,
583        pub thread: GuildChannel,
584    }
585
586    /// Dispatched when a thread is updated.
587    ///
588    /// Provides the updated thread and the old thread data, provided the thread was cached prior
589    /// to dispatch.
590    #[derive(Message, Debug, Clone)]
591    pub struct ThreadUpdateMessage {
592        pub ctx: Context,
593        pub old: Option<GuildChannel>,
594        pub new: GuildChannel,
595    }
596
597    /// Dispatched when a thread is deleted.
598    ///
599    /// Provides the partial data about the deleted thread and, if it was present in the cache
600    /// before its deletion, its full data.
601    #[derive(Message, Debug, Clone)]
602    pub struct ThreadDeleteMessage {
603        pub ctx: Context,
604        pub thread: PartialGuildChannel,
605        pub full_thread_data: Option<GuildChannel>,
606    }
607
608    /// Dispatched when the current user gains access to a channel.
609    ///
610    /// Provides the threads the current user can access, the thread members, the guild Id,
611    /// and the channel Ids of the parent channels being synced.
612    #[derive(Message, Debug, Clone)]
613    pub struct ThreadListSyncMessage {
614        pub ctx: Context,
615        pub thread_list_sync: ThreadListSyncEvent,
616    }
617
618    /// Dispatched when the [`ThreadMember`] for the current user is updated.
619    ///
620    /// Provides the updated thread member.
621    #[derive(Message, Debug, Clone)]
622    pub struct ThreadMemberUpdateMessage {
623        pub ctx: Context,
624        pub thread_member: ThreadMember,
625    }
626
627    /// Dispatched when anyone is added to or removed from a thread. If the current user does
628    /// not have the [`GatewayIntents::GUILDS]`, then this event will only be sent if the current
629    /// user was added to or removed from the thread.
630    ///
631    /// Provides the added/removed members, the approximate member count of members in the thread,
632    /// the thread Id and its guild Id.
633    #[derive(Message, Debug, Clone)]
634    pub struct ThreadMembersUpdateMessage {
635        pub ctx: Context,
636        pub thread_members_update: ThreadMembersUpdateEvent,
637    }
638
639    /// Dispatched when a scheduled event is created.
640    ///
641    /// Provides data about the scheduled event.
642    #[derive(Message, Debug, Clone)]
643    pub struct GuildScheduledEventCreateMessage {
644        pub ctx: Context,
645        pub event: ScheduledEvent,
646    }
647
648    /// Dispatched when a scheduled event is updated.
649    ///
650    /// Provides data about the scheduled event.
651    #[derive(Message, Debug, Clone)]
652    pub struct GuildScheduledEventUpdateMessage {
653        pub ctx: Context,
654        pub event: ScheduledEvent,
655    }
656
657    /// Dispatched when a scheduled event is deleted.
658    ///
659    /// Provides data about the scheduled event.
660    #[derive(Message, Debug, Clone)]
661    pub struct GuildScheduledEventDeleteMessage {
662        pub ctx: Context,
663        pub event: ScheduledEvent,
664    }
665
666    /// Dispatched when a guild member has subscribed to a scheduled event.
667    ///
668    /// Provides data about the subscription.
669    #[derive(Message, Debug, Clone)]
670    pub struct GuildScheduledEventUserAddMessage {
671        pub ctx: Context,
672        pub subscribed: GuildScheduledEventUserAddEvent,
673    }
674
675    /// Dispatched when a guild member has unsubscribed from a scheduled event.
676    ///
677    /// Provides data about the cancelled subscription.
678    #[derive(Message, Debug, Clone)]
679    pub struct GuildScheduledEventUserRemoveMessage {
680        pub ctx: Context,
681        pub unsubscribed: GuildScheduledEventUserRemoveEvent,
682    }
683
684    /// Dispatched when a user subscribes to a SKU.
685    ///
686    /// Provides data about the subscription.
687    #[derive(Message, Debug, Clone)]
688    pub struct EntitlementCreateMessage {
689        pub ctx: Context,
690        pub entitlement: Entitlement,
691    }
692
693    /// Dispatched when a user’s entitlement has been updated, such as when a subscription is
694    /// renewed for the next billing period.
695    ///
696    /// Provides data abut the updated subscription. If the entitlement is renewed, the
697    /// `[Entitlement::ends_at`] field will have changed.
698    #[derive(Message, Debug, Clone)]
699    pub struct EntitlementUpdateMessage {
700        pub ctx: Context,
701        pub entitlement: Entitlement,
702    }
703
704    /// Dispatched when a user’s entitlement has been deleted. This happens rarely, but can occur
705    /// if a subscription is refunded or otherwise deleted by Discord. Entitlements are not deleted
706    /// when they expire.
707    ///
708    /// Provides data about the subscription. Specifically, the Entitlement::deleted field will be set.
709    #[derive(Message, Debug, Clone)]
710    pub struct EntitlementDeleteMessage {
711        pub ctx: Context,
712        pub entitlement: Entitlement,
713    }
714
715    /// Dispatched when a user votes on a message poll.
716    ///
717    /// This will be dispatched multiple times if multiple answers are selected.
718    #[derive(Message, Debug, Clone)]
719    pub struct PollVoteAddMessage {
720        pub ctx: Context,
721        pub event: MessagePollVoteAddEvent,
722    }
723
724    /// Dispatched when a user removes a previous vote on a poll.
725    #[derive(Message, Debug, Clone)]
726    pub struct PollVoteRemoveMessage {
727        pub ctx: Context,
728        pub event: MessagePollVoteRemoveEvent,
729    }
730
731    /// Dispatched when an HTTP rate limit is hit
732    #[derive(Message, Debug, Clone)]
733    pub struct RateLimitMessage {
734        pub data: RatelimitInfo,
735    }
736}
737
738#[cfg(feature = "rich_presence")]
739#[cfg_attr(docsrs, doc(cfg(feature = "rich_presence")))]
740pub mod rich_presence {
741    //! This module contains all the bevy [Message] thrown by `rich_presence` feature
742
743    use bevy_ecs::prelude::Message;
744    use discord_sdk::activity::ActivityInvite;
745    use discord_sdk::overlay::Visibility;
746    use discord_sdk::relations::Relationship;
747    use discord_sdk::user::User;
748    use discord_sdk::{Error, Event};
749    use std::sync::Arc;
750
751    /// Fires when we’ve done something naughty and Discord is telling us to stop.
752    ///
753    /// The [Event] will always be of type [Event::Error]
754    #[derive(Message, Debug)]
755    pub struct ErrorMessage(pub Event);
756
757    /// Sent by Discord upon receipt of our Handshake message, the user is the current user logged
758    /// in to the Discord we connected to.
759    #[derive(Message, Debug, Clone)]
760    pub struct RpReadyMessage {
761        /// The protocol version, we only support v1, which is fine since that is (currently) the only version
762        pub version: u32,
763        // `DiscordConfig` is private in `ConnectEvent`
764        // pub config: DiscordConfig
765        /// The user that is logged into the Discord application we connected to
766        pub user: User,
767    }
768
769    /// Fired when the connection has been interrupted between us and Discord, this is a synthesized
770    /// event as there are can be numerous reasons on the client side for this to happen, in
771    /// addition to Discord itself being closed, etc.
772    #[derive(Message, Debug)]
773    pub struct DisconnectedMessage {
774        pub reason: Error,
775    }
776
777    /// Fired when any details on the current logged in user are changed.
778    #[derive(Message, Debug, Clone)]
779    pub struct CurrentUserUpdateMessage {
780        /// The user that is logged into the Discord application we connected to
781        pub user: User,
782    }
783
784    /// Sent by Discord when the local user has requested to join a game, and the remote user has accepted their request.
785    #[derive(Message, Debug, Clone)]
786    pub struct ActivityJoinMessage {
787        pub secret: String,
788    }
789
790    /// Sent by Discord when the local user has chosen to spectate another user’s game session.
791    #[derive(Message, Debug, Clone)]
792    pub struct ActivitySpectateMessage {
793        pub secret: String,
794    }
795
796    /// Fires when a user asks to join the current user’s game.
797    #[derive(Message, Debug, Clone)]
798    pub struct ActivityJoinRequestMessage {
799        /// Payload for the event fired when a user “Asks to Join” the current user’s game
800        pub user: User,
801    }
802
803    /// Fires when the current user is invited by another user to their game.
804    #[derive(Message, Debug, Clone)]
805    pub struct ActivityInviteMessage(pub Arc<ActivityInvite>);
806
807    /// Event fired when the overlay state changes.
808    #[derive(Message, Debug, Clone)]
809    pub struct OverlayUpdateMessage {
810        /// Whether the user has the overlay enabled or disabled. If the overlay is disabled, all
811        /// the functionality of the SDK will still work. The calls will instead focus the Discord
812        /// client and show the modal there instead of in application.
813        pub enabled: bool,
814        /// Whether the overlay is visible or not.
815        pub visible: Visibility,
816    }
817
818    /// Event fired when a relationship with another user changes.
819    #[derive(Message, Debug, Clone)]
820    pub struct RelationshipUpdateMessage(pub Arc<Relationship>);
821}
822
823#[cfg(feature = "bot")]
824use bot::*;
825#[cfg(feature = "rich_presence")]
826use rich_presence::*;
827
828#[cfg(feature = "bot")]
829create_message_collection_and_handler!(
830    MessageCollectionBot,
831    bot,
832    CommandPermissionsUpdateMessage,
833    AutoModerationRuleCreateMessage,
834    AutoModerationRuleUpdateMessage,
835    AutoModerationRuleDeleteMessage,
836    AutoModerationActionExecutionMessage,
837    #[cfg(all(feature = "bot_cache", feature = "bot_cache"))]
838    CacheReadMessage,
839    #[cfg(all(feature = "bot_cache", feature = "bot_cache"))]
840    ShardsReadyMessage,
841    ChannelCreateMessage,
842    CategoryCreateMessage,
843    CategoryDeleteMessage,
844    ChannelDeleteMessage,
845    ChannelPinUpdateMessage,
846    ChannelUpdateMessage,
847    GuildAuditLogEntryCreateMessage,
848    GuildBanAdditionMessage,
849    GuildBanRemovalMessage,
850    GuildCreateMessage,
851    GuildDeleteMessage,
852    GuildEmojisUpdateMessage,
853    GuildIntegrationsUpdateMessage,
854    GuildMemberAdditionMessage,
855    GuildMemberRemovalMessage,
856    GuildMemberUpdateMessage,
857    GuildMembersChunkMessage,
858    GuildRoleCreateMessage,
859    GuildRoleDeleteMessage,
860    GuildRoleUpdateMessage,
861    GuildStickersUpdateMessage,
862    GuildUpdateMessage,
863    InviteCreateMessage,
864    InviteDeleteMessage,
865    DiscordMessage,
866    DiscordMessageDeleteMessage,
867    DiscordMessageDeleteBulkMessage,
868    DiscordMessageUpdateMessage,
869    ReactionAddMessage,
870    ReactionRemoveMessage,
871    ReactionRemoveAllMessage,
872    ReactionRemoveEmojiMessage,
873    PresenceUpdateMessage,
874    BotReadyMessage,
875    ResumeMessage,
876    ShardStageUpdateMessage,
877    TypingStartMessage,
878    UserUpdateMessage,
879    VoiceServerUpdateMessage,
880    VoiceStateUpdateMessage,
881    VoiceChannelStatusUpdateMessage,
882    WebhookUpdateMessage,
883    InteractionCreateMessage,
884    IntegrationCreateMessage,
885    IntegrationUpdateMessage,
886    StageInstanceCreateMessage,
887    StageInstanceUpdateMessage,
888    StageInstanceDeleteMessage,
889    ThreadCreateMessage,
890    ThreadUpdateMessage,
891    ThreadDeleteMessage,
892    ThreadListSyncMessage,
893    ThreadMemberUpdateMessage,
894    ThreadMembersUpdateMessage,
895    GuildScheduledEventCreateMessage,
896    GuildScheduledEventUpdateMessage,
897    GuildScheduledEventDeleteMessage,
898    GuildScheduledEventUserAddMessage,
899    GuildScheduledEventUserRemoveMessage,
900    EntitlementCreateMessage,
901    EntitlementUpdateMessage,
902    EntitlementDeleteMessage,
903    PollVoteAddMessage,
904    PollVoteRemoveMessage,
905    RateLimitMessage,
906);
907
908#[cfg(feature = "rich_presence")]
909create_message_collection_and_handler!(
910    MessageCollectionRichPresence,
911    rich_presence,
912    ErrorMessage,
913    RpReadyMessage,
914    DisconnectedMessage,
915    CurrentUserUpdateMessage,
916    ActivityJoinMessage,
917    ActivitySpectateMessage,
918    ActivityJoinRequestMessage,
919    ActivityInviteMessage,
920    OverlayUpdateMessage,
921    RelationshipUpdateMessage
922);