diff --git a/.gitignore b/.gitignore index 0b745e2..c6e07b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target -.env \ No newline at end of file +.env + +/src/.* \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4c9aee3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "rust-analyzer.linkedProjects": [ + "./Cargo.toml" + ], + "rust-analyzer.showUnlinkedFileNotification": false +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 1bed005..40153bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +rand = "0.8.5" anyhow = "1.0.71" -cron = "0.12.0" +# cron = "0.12.0" dotenv = "0.15.0" -mongodb = "2.6.0" -poise = "0.5.5" +# mongodb = "2.6.0" +# poise = "0.5.5" serenity = { version = "0.11.6", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "http"] } serenity_utils = "0.7.0" tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } diff --git a/src/main.rs b/src/main.rs index e9522dc..5759477 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,12 @@ -use std::sync::Arc; - -use poise::serenity_prelude::GuildChannel; use serenity::async_trait; -use serenity::http::{self, Http}; use serenity::model::channel::Message; use serenity::model::gateway::Ready; -use serenity::model::id::ChannelId; use serenity::prelude::*; use util::security::dotenv_var; +use other::msg::hello; mod util; +mod other; struct Handler; @@ -25,22 +22,9 @@ impl EventHandler for Handler { async fn ready(&self, ctx: Context, ready: Ready) { println!("{} is connected!", ready.user.name); - // if (ready.user.name != "MOOver Debug") { - let messages = [ - "AAAAAAAAAAAAAAAAAAAA", - "Henlooo", - "Good day y'all!", - "May have crashed...", - "MOOOooo", - "Heyyyyy!", - "I'm baaaaack!", - "Whom'st have summoned the ancient one?", - ]; - + // if ready.user.name != "MOOver Debug" { + hello(ctx.http).await; // } - - let channel = ctx.http.get_channel(780439236867653635).await.unwrap(); - } } diff --git a/src/other/mod.rs b/src/other/mod.rs new file mode 100644 index 0000000..12c5537 --- /dev/null +++ b/src/other/mod.rs @@ -0,0 +1 @@ +pub mod msg; \ No newline at end of file diff --git a/src/other/msg.rs b/src/other/msg.rs new file mode 100644 index 0000000..fd4ad4c --- /dev/null +++ b/src/other/msg.rs @@ -0,0 +1,23 @@ +use serenity::http::Http; +use std::sync::Arc; + +pub async fn hello(http: Arc) { + let messages = [ + "AAAAAAAAAAAAAAAAAAAA", + "Henlooo", + "Good day y'all!", + "May have crashed...", + "MOOOooo", + "Heyyyyy!", + "I'm baaaaack!", + "Whom'st have summoned the ancient one?", + ]; + + let channel = http.get_channel(780439236867653635).await.unwrap(); + + let num = rand::random::() % messages.len(); + + if let Err(why) = channel.id().say(http, messages[num]).await { + print!("Error sending message: {:?}", why); + }; +} \ No newline at end of file diff --git a/src/sample.rs b/src/sample.rs deleted file mode 100644 index f5c9e80..0000000 --- a/src/sample.rs +++ /dev/null @@ -1,19 +0,0 @@ -struct MyStruct { - niečo: String, -} -impl MyStruct { - fn add(&mut self) { - self.niečo.push(char::from_digit(2, 2).unwrap()); - } -} -trait Countable { - fn count(&self) -> usize; -} -impl Countable for MyStruct { - fn count(&self) -> usize { - self.niečo.len() - } -} -fn smt(var: Box) { - var.count(); -} \ No newline at end of file diff --git a/src/util/security.rs b/src/util/security.rs index b33047d..3930652 100644 --- a/src/util/security.rs +++ b/src/util/security.rs @@ -3,10 +3,9 @@ use std::env; pub fn dotenv_var(key: &str) -> Option { dotenv().ok(); - let key = "TOKEN"; match env::var(key) { Ok(val) => return Some(val), Err(_) => None, } -} +} \ No newline at end of file