diff --git a/Cargo.toml b/Cargo.toml index 2804d09..a2a7bab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,5 @@ edition = "2021" [dependencies] eframe = "0.26.2" image = "0.24.9" +tokio = { version = "0.2", features = ["macros"] } +serenity = { default-features = false, features = ["client", "gateway", "model", "rustls_backend"], version = "0.9.0-rc.2"} \ No newline at end of file diff --git a/jiji.project b/jiji.project new file mode 100644 index 0000000..0e181a5 --- /dev/null +++ b/jiji.project @@ -0,0 +1 @@ +{"categories":[{"name":"to do","content":[{"name":"run discord bot","description":"make it so the bot is running","id":1},{"name":"get incoming messages","description":"read","id":2},{"name":"sort messages by origin","description":"// Hello there","id":3},{"name":"fetch previous messages","description":"// Hello there","id":4},{"name":"ability to write messages","description":"// Hello there","id":5}]},{"name":"in progress","content":[]},{"name":"done","content":[]},{"name":"bugs","content":[]},{"name":"+","content":[]}]} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index dfd291e..ed24ea8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,32 +5,41 @@ use std::{ time, sync::Arc, error::Error, + env, }; +use serenity::{ + async_trait, + model::{channel::Message, gateway::Ready}, + prelude::*, +}; + +mod token; const MAX_FPS : f32 = 30.0; +const HELP_MESSAGE: &str = "Hello there, Human! I am a messenger for the wandering penwing."; +const HELP_COMMAND: &str = "!jiji"; -fn main() -> Result<(), eframe::Error> { - let icon_data = load_icon().unwrap_or_default(); - - let options = eframe::NativeOptions { - viewport: egui::ViewportBuilder::default() - .with_inner_size([1200.0, 800.0]) - .with_icon(Arc::new(icon_data)), - ..Default::default() - }; - - eframe::run_native( - "Jiji", - options, - Box::new(move |_cc| Box::from(Jiji::default())), - ) -} +//fn main() -> Result<(), eframe::Error> { +// let icon_data = load_icon().unwrap_or_default(); +// +// let options = eframe::NativeOptions { +// viewport: egui::ViewportBuilder::default() +// .with_inner_size([1200.0, 800.0]) +// .with_icon(Arc::new(icon_data)), +// ..Default::default() +// }; +// +// eframe::run_native( +// "Jiji", +// options, +// Box::new(move |_cc| Box::from(Jiji::default())), +// ) +//} struct Jiji { - token: String, next_frame: time::Instant, } @@ -38,7 +47,6 @@ struct Jiji { impl Default for Jiji { fn default() -> Self { Self { - token: "test".to_string(), next_frame: time::Instant::now(), } } @@ -78,4 +86,37 @@ pub fn load_icon() -> Result> { width: icon_width, height: icon_height, }) +} + + +struct Handler; + +#[async_trait] +impl EventHandler for Handler { + async fn message(&self, ctx: Context, msg: Message) { + if msg.content == HELP_COMMAND { + if let Err(why) = msg.channel_id.say(&ctx.http, HELP_MESSAGE).await { + println!("Error sending message: {:?}", why); + } + } +} + +async fn ready(&self, _: Context, ready: Ready) { + println!("{} is connected!", ready.user.name); + } +} + +#[tokio::main] +async fn main() { + //let token = env::var(token::TOKEN) + //.expect("Expected a token in the environment"); + + let mut client = Client::new(&token::TOKEN) + .event_handler(Handler) + .await + .expect("Err creating client"); + + if let Err(why) = client.start().await { + println!("Client error: {:?}", why); + } } \ No newline at end of file diff --git a/src/token.rs b/src/token.rs new file mode 100644 index 0000000..ca66a66 --- /dev/null +++ b/src/token.rs @@ -0,0 +1 @@ +pub const TOKEN : &str = "MTIxNTIwMzEyMTk5NTcxNDU4MQ.G2P14S.kMBadIiCH6Lo8Y_V_VU42WLmBVBkbI39CojiAo"; \ No newline at end of file