|
|
|
@ -9,9 +9,9 @@ use serenity::prelude::*;
|
|
|
|
|
use sysinfo::{ProcessExt, SystemExt};
|
|
|
|
|
|
|
|
|
|
use crate::commands::common::handle_autodelete;
|
|
|
|
|
use crate::utils::context_data::get_database_from_context;
|
|
|
|
|
|
|
|
|
|
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
|
|
|
|
use crate::providers::music::queue::MusicQueue;
|
|
|
|
|
use crate::utils::context_data::{get_database_from_context, Store};
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
#[command]
|
|
|
|
|
#[description("Shows some statistics about the bot")]
|
|
|
|
@ -22,6 +22,7 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult {
|
|
|
|
|
let database = get_database_from_context(ctx).await;
|
|
|
|
|
let mut system = sysinfo::System::new_all();
|
|
|
|
|
system.refresh_all();
|
|
|
|
|
|
|
|
|
|
let kernel_version = system.get_kernel_version().unwrap_or("n/a".to_string());
|
|
|
|
|
let own_process = system.get_process(process::id() as i32).unwrap();
|
|
|
|
|
let memory_usage = own_process.memory();
|
|
|
|
@ -39,11 +40,18 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult {
|
|
|
|
|
let discord_info = format!(
|
|
|
|
|
r#"
|
|
|
|
|
Version: {}
|
|
|
|
|
Compiled with: rustc {}
|
|
|
|
|
Owner: <@{}>
|
|
|
|
|
Guilds: {}
|
|
|
|
|
Voice Connections: {}
|
|
|
|
|
Times Used: {}
|
|
|
|
|
"#,
|
|
|
|
|
VERSION, bot_info.owner.id, guild_count, total_commands_executed
|
|
|
|
|
crate::VERSION,
|
|
|
|
|
rustc_version_runtime::version(),
|
|
|
|
|
bot_info.owner.id,
|
|
|
|
|
guild_count,
|
|
|
|
|
get_queue_count(ctx).await,
|
|
|
|
|
total_commands_executed
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
log::trace!("Discord info {}", discord_info);
|
|
|
|
@ -79,3 +87,27 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult {
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns the total number of queues that are not
|
|
|
|
|
/// flagged to leave
|
|
|
|
|
async fn get_queue_count(ctx: &Context) -> usize {
|
|
|
|
|
let queues: Vec<Arc<Mutex<MusicQueue>>> = {
|
|
|
|
|
let data = ctx.data.read().await;
|
|
|
|
|
let store = data.get::<Store>().unwrap();
|
|
|
|
|
|
|
|
|
|
store
|
|
|
|
|
.music_queues
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|(_, q)| Arc::clone(q))
|
|
|
|
|
.collect()
|
|
|
|
|
};
|
|
|
|
|
let mut count = 0;
|
|
|
|
|
for queue in queues {
|
|
|
|
|
let queue = queue.lock().await;
|
|
|
|
|
if !queue.leave_flag {
|
|
|
|
|
count += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
count
|
|
|
|
|
}
|
|
|
|
|