From eaae9e12e142afc0cde6ce5e33b4a6cc2b380536 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Sat, 9 Mar 2024 13:32:25 +0100 Subject: [PATCH] Add activity --- src/config.rs | 2 ++ src/main.rs | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 0f3f9fd..a784919 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,6 +9,7 @@ fn get_env(env: &'static str) -> String { pub struct Config { pub discord_bot_token: String, pub discord_channel_id: u64, + pub discord_bot_activity: String, pub telegram_bot_token: String, pub telgram_channel_id: i128, } @@ -19,6 +20,7 @@ impl Config { Config { discord_bot_token: get_env("DISCORD_BOT_TOKEN"), discord_channel_id: get_env("DISCORD_CHANNEL_ID").parse().unwrap(), + discord_bot_activity: get_env("DISCORD_BOT_ACTIVITY"), telegram_bot_token: get_env("TELEGRAM_BOT_TOKEN"), telgram_channel_id: get_env("TELEGRAM_CHANNEL_ID").parse().unwrap(), } diff --git a/src/main.rs b/src/main.rs index a249c20..e60f9a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use serenity::all::ActivityData; use serenity::async_trait; use serenity::model::channel::Message; use serenity::prelude::*; @@ -38,7 +39,12 @@ async fn main() { | GatewayIntents::MESSAGE_CONTENT; let mut client = - Client::builder(&config::CONFIG.discord_bot_token, intents).event_handler(Handler).await.expect("Err creating client"); + Client::builder(&config::CONFIG.discord_bot_token, intents) + .event_handler(Handler) + .status(serenity::all::OnlineStatus::Online) + .activity(ActivityData::playing(&config::CONFIG.discord_bot_activity)) + .await + .expect("Err creating client"); if let Err(why) = client.start().await { println!("Client error: {why:?}");