2023-07-14 14:41:16 +00:00
|
|
|
use rand::random;
|
2023-07-05 09:06:04 +00:00
|
|
|
use serenity::async_trait;
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
use serenity::model::gateway::Ready;
|
|
|
|
use serenity::prelude::*;
|
2023-07-07 08:55:59 +00:00
|
|
|
use util::security::dotenv_var;
|
2023-09-23 19:15:19 +00:00
|
|
|
use other::msg::hello;
|
2023-07-05 09:06:04 +00:00
|
|
|
|
2023-07-15 09:18:08 +00:00
|
|
|
mod message_handler;
|
|
|
|
use message_handler::handle;
|
|
|
|
|
|
|
|
mod commands;
|
2023-07-07 08:55:59 +00:00
|
|
|
mod util;
|
2023-09-23 19:15:19 +00:00
|
|
|
mod other;
|
2023-07-05 09:06:04 +00:00
|
|
|
|
|
|
|
struct Handler;
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl EventHandler for Handler {
|
|
|
|
async fn message(&self, ctx: Context, msg: Message) {
|
2023-07-15 09:18:08 +00:00
|
|
|
handle(ctx, msg).await;
|
2023-07-05 09:06:04 +00:00
|
|
|
}
|
|
|
|
|
2023-07-07 08:55:59 +00:00
|
|
|
async fn ready(&self, ctx: Context, ready: Ready) {
|
2023-07-05 09:06:04 +00:00
|
|
|
println!("{} is connected!", ready.user.name);
|
2023-07-14 13:04:01 +00:00
|
|
|
let debug = match dotenv_var("DEBUG") {
|
|
|
|
Some(v) => v,
|
2023-07-14 14:41:16 +00:00
|
|
|
None => "OFF".to_string(),
|
2023-07-14 13:04:01 +00:00
|
|
|
};
|
2023-07-15 09:18:08 +00:00
|
|
|
if debug != "ON" {
|
2023-07-14 13:04:01 +00:00
|
|
|
let messages = [
|
|
|
|
"AAAAAAAAAAAAAAAAAAAA",
|
|
|
|
"Henlooo",
|
|
|
|
"Good day y'all!",
|
|
|
|
"May have crashed...",
|
|
|
|
"MOOOooo",
|
|
|
|
"Heyyyyy!",
|
|
|
|
"I'm baaaaack!",
|
|
|
|
"Whom'st have summoned the ancient one?",
|
2023-07-14 14:41:16 +00:00
|
|
|
];
|
|
|
|
|
2023-07-14 13:04:01 +00:00
|
|
|
let rand_num = random::<usize>() % messages.len();
|
|
|
|
let channel = ctx.http.get_channel(780439236867653635).await.unwrap().id();
|
|
|
|
match channel.say(&ctx.http, messages[rand_num]).await {
|
|
|
|
Err(e) => println!("Something went wrong: {e}"),
|
2023-07-14 14:41:16 +00:00
|
|
|
Ok(_) => return,
|
2023-07-14 13:04:01 +00:00
|
|
|
};
|
|
|
|
}
|
2023-09-23 19:15:19 +00:00
|
|
|
// if ready.user.name != "MOOver Debug" {
|
|
|
|
hello(ctx.http).await;
|
2023-07-07 10:16:25 +00:00
|
|
|
// }
|
2023-07-05 09:06:04 +00:00
|
|
|
}
|
|
|
|
}
|
2023-07-07 11:44:07 +00:00
|
|
|
|
2023-07-05 09:06:04 +00:00
|
|
|
#[tokio::main]
|
2023-07-07 10:16:25 +00:00
|
|
|
async fn main() -> anyhow::Result<()> {
|
|
|
|
use anyhow::Context;
|
|
|
|
let token = dotenv_var("TOKEN").context("No TOKEN in env")?;
|
2023-07-14 14:41:16 +00:00
|
|
|
let intents = GatewayIntents::GUILD_MESSAGES | GatewayIntents::MESSAGE_CONTENT;
|
|
|
|
|
2023-07-07 08:55:59 +00:00
|
|
|
let mut client = Client::builder(&token, intents)
|
2023-07-07 10:16:25 +00:00
|
|
|
.event_handler(Handler)
|
|
|
|
.await
|
|
|
|
.context("Failed to build client")?;
|
2023-07-14 14:41:16 +00:00
|
|
|
|
2023-07-07 10:16:25 +00:00
|
|
|
client.start().await?;
|
|
|
|
Ok(())
|
2023-07-05 09:06:04 +00:00
|
|
|
}
|