Skip to content

Commit

Permalink
Found a better way to reply to messages
Browse files Browse the repository at this point in the history
  • Loading branch information
xToxette committed Oct 21, 2023
1 parent 43dfd17 commit b207ff7
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 6 deletions.
78 changes: 78 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ env_logger = "0.10.0"
poise = "0.5.6"
songbird = { git = "https://github.com/serenity-rs/songbird.git", branch = "next" }
sqlx = { version = "0.7.2", features = ["runtime-tokio-rustls", "time", "sqlite"] }
sysinfo = "0.29.10"
tokio = { version = "1.33.0", features = ["rt-multi-thread"] }
47 changes: 43 additions & 4 deletions src/commands/utilities/common.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,57 @@
use poise::serenity_prelude::Timestamp;
use poise::{CreateReply, serenity_prelude as serenity};
use serenity::Timestamp;
use crate::{Context, Error};
use sysinfo::{CpuExt, System, SystemExt};

use serenity::builder::{CreateEmbed, CreateMessage};

/// Informs you about the meaning of ben's existence
#[poise::command(prefix_command, slash_command)]
#[poise::command(prefix_command, slash_command, ephemeral, broadcast_typing)]
pub async fn information(
ctx: Context<'_>,
) -> Result<(), Error> {
let msg = ctx.channel_id().send_message(&ctx.http(), |m| {
ctx.send(|m| {
m.content("Ben is currently being development")
.embed(|e| {
e.title("Development")
.description("Please contribute, otherwise I'm so lonely: https://github.com/xToxette/ben-rs")
.timestamp(Timestamp::now())
})
}).await;
}).await?;
Ok(())
}



#[derive(poise::ChoiceParameter)]
pub enum PerformanceType {
CPU,
RAM,
Disk,
Delay,
All
}

/// Check the current performance of ben
#[poise::command(slash_command, ephemeral, broadcast_typing)]
pub async fn performance(
ctx: Context<'_>,
#[description = "What to check"] category: PerformanceType
) -> Result<(), Error> {
let mut system = System::new_all();

match category {
PerformanceType::CPU => {
ctx.send(|m| {
m.content(format!("{}", system.global_cpu_info().cpu_usage()))
}).await?;
}
PerformanceType::RAM => {
ctx.send(|m| {
m.content(format!("RAM: {}gb used /{}gb total", system.available_memory() / 1073741824, system.total_memory() / 1073741824))
}).await?;
}
_ => {}
}
Ok(())
}
2 changes: 1 addition & 1 deletion src/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn main_handler<'a>(
dal::events::voice_state_update::insert(&data.conn_pool, &new).await?;
}
Event::Message { new_message } => {
println!("Message: {:#?}", new_message);
// println!("Message: {:#?}", new_message);
}
_ => {}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ async fn main() {

let options = poise::FrameworkOptions {
commands: vec![
commands::utilities::common::information()
commands::utilities::common::information(),
commands::utilities::common::performance(),
],
prefix_options: prefix_options(),
on_error: handlers::error::handler,
Expand Down

0 comments on commit b207ff7

Please sign in to comment.