From e82284281be456a9b3f1f39096eddb7a63c440c8 Mon Sep 17 00:00:00 2001 From: mii443 Date: Tue, 8 Oct 2024 09:49:17 +0000 Subject: [PATCH] remove serenity, add poise --- Cargo.toml | 7 +------ src/docker.rs | 13 ++----------- src/language.rs | 6 +++--- src/main.rs | 23 ++++++++++++----------- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 362f4d0..243a9fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,12 +21,7 @@ strum = "0.24" strum_macros = "0.24" log = "0.4.0" env_logger = "0.9.0" - -[dependencies.serenity] -default-features = true -features = ["builder", "cache", "client", "gateway", "model", "utils", "unstable_discord_api", "collector", "rustls_backend", "framework"] -git = "https://github.com/serenity-rs/serenity" -branch = "next" +poise = "0.6.1" [dependencies.tokio] version = "1.0" diff --git a/src/docker.rs b/src/docker.rs index 5462d92..6c6e3c0 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -84,12 +84,7 @@ impl Container { attach_stdout: Some(true), attach_stdin: Some(true), attach_stderr: Some(true), - cmd: Some( - language - .get_run_command(file_name) - .split(" ") - .collect(), - ), + cmd: Some(language.get_run_command(file_name).split(" ").collect()), ..Default::default() }, ) @@ -188,11 +183,7 @@ impl Container { let tar_gz = File::create(&format!("code/{}.tar.gz", file_name)).unwrap(); let encoder = GzEncoder::new(tar_gz, Compression::default()); let mut tar = tar::Builder::new(encoder); - tar.append_file( - path.clone(), - &mut f, - ) - .unwrap(); + tar.append_file(path.clone(), &mut f).unwrap(); tar.finish().unwrap(); } diff --git a/src/language.rs b/src/language.rs index 3d5e46e..dd1803e 100644 --- a/src/language.rs +++ b/src/language.rs @@ -1,5 +1,5 @@ use bollard::{container::Config, service::HostConfig}; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Language { @@ -9,7 +9,7 @@ pub struct Language { pub path: String, pub run_command: String, pub compile_command: Option, - pub image: String + pub image: String, } impl Language { @@ -43,4 +43,4 @@ impl Language { ..Default::default() } } -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 16f2646..82353ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,14 +3,15 @@ mod docker; mod event_handler; mod language; -use std::{env, fs::File, io::Read, sync::{Arc, Mutex}}; +use std::{ + env, + fs::File, + io::Read, + sync::{Arc, Mutex}, +}; use config::Config; use event_handler::Handler; -use serenity::{ - framework::StandardFramework, http::Http, - prelude::{GatewayIntents, TypeMapKey}, Client, -}; struct ConfigStorage; @@ -61,12 +62,12 @@ async fn main() -> Result<(), ()> { GatewayIntents::MESSAGE_CONTENT | GatewayIntents::GUILD_MESSAGES | GatewayIntents::DIRECT_MESSAGES, - ) - .framework(framework) - .event_handler(Handler) - .await - .expect("Err creating client"); - + ) + .framework(framework) + .event_handler(Handler) + .await + .expect("Err creating client"); + { let mut data = client.data.write().await; data.insert::(Arc::new(Mutex::new(config)));