34 lines
1 KiB
Rust
34 lines
1 KiB
Rust
use crate::constants;
|
|
use std::{sync::Arc, time::Duration};
|
|
|
|
use ::std::collections::hash_map::HashMap;
|
|
use rand::{distributions::uniform::SampleRange, rngs::OsRng};
|
|
use serenity::all::{ActivityData, Cache, ShardId, ShardRunnerInfo};
|
|
use tokio::sync::Mutex;
|
|
|
|
pub async fn status_timer(
|
|
shard_runners: Arc<Mutex<HashMap<ShardId, ShardRunnerInfo>>>,
|
|
cache: Arc<Cache>,
|
|
) {
|
|
let mut rand = OsRng::default();
|
|
let activity_list = [
|
|
ActivityData::watching("my developer eat a watermelon whole."),
|
|
ActivityData::watching(format!(
|
|
"{} users in {} guilds.",
|
|
cache.user_count(),
|
|
cache.guild_count()
|
|
)),
|
|
ActivityData::watching(format!("for {}help", constants::COMMAND_PREFIX)),
|
|
ActivityData::listening("Infected Mushroom"),
|
|
];
|
|
|
|
loop {
|
|
for (_shard_id, shard_info) in shard_runners.lock().await.iter() {
|
|
shard_info.runner_tx.set_activity(Some(
|
|
activity_list[SampleRange::sample_single(0..activity_list.len() - 1, &mut rand)]
|
|
.clone(),
|
|
));
|
|
}
|
|
tokio::time::sleep(Duration::from_secs(20 * 60)).await;
|
|
}
|
|
}
|