1use crate::common::initialize_field_with_doc;
10use bevy_ecs::prelude::*;
11
12#[cfg(feature = "bot")]
13use {crate::common::override_field_with_doc, serenity::all::*};
14
15#[cfg(feature = "bot")]
23#[cfg_attr(docsrs, doc(cfg(feature = "bot")))]
24#[derive(Default, Resource, Clone, Debug)]
25pub struct DiscordBotConfig {
26 pub(crate) token: String,
27 pub(crate) gateway_intents: GatewayIntents,
28 pub(crate) status: Option<OnlineStatus>,
29 pub(crate) activity: Option<ActivityData>,
30 pub(crate) shards: u32,
31}
32
33#[cfg(feature = "bot")]
34impl DiscordBotConfig {
35 initialize_field_with_doc!(token, String, "Sets the bot token.");
36 initialize_field_with_doc!(
37 gateway_intents,
38 GatewayIntents,
39 "Sets the bot [`GatewayIntents`]."
40 );
41 override_field_with_doc!(status, OnlineStatus, "Sets the initial status.");
42 override_field_with_doc!(activity, ActivityData, "Sets the initial activity.");
43 initialize_field_with_doc!(shards, u32, "The total number of shards to use.");
44}
45
46#[cfg(feature = "rich_presence")]
52#[cfg_attr(docsrs, doc(cfg(feature = "rich_presence")))]
53#[derive(Resource, Clone)]
54pub struct DiscordRichPresenceConfig {
55 pub(crate) app: discord_sdk::AppId,
56 pub(crate) subscriptions: discord_sdk::Subscriptions,
57}
58
59#[cfg(feature = "rich_presence")]
60impl std::fmt::Debug for DiscordRichPresenceConfig {
61 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
62 f.debug_struct("DiscordRichPresenceConfig")
63 .field("app", &self.app)
64 .field("subscriptions", &self.subscriptions.bits())
65 .finish()
66 }
67}
68
69#[cfg(feature = "rich_presence")]
70impl Default for DiscordRichPresenceConfig {
71 fn default() -> Self {
72 Self {
73 app: 0,
74 subscriptions: discord_sdk::Subscriptions::all(),
75 }
76 }
77}
78
79#[cfg(feature = "rich_presence")]
80impl DiscordRichPresenceConfig {
81 initialize_field_with_doc!(app, discord_sdk::AppId, "Set the Discord Application ID.");
82 initialize_field_with_doc!(
83 subscriptions,
84 discord_sdk::Subscriptions,
85 "Set the subscription for Rich Presence"
86 );
87}