moover_rust/src/main.rs

63 lines
1.6 KiB
Rust
Raw Normal View History

2023-07-07 08:55:59 +00:00
use std::sync::Arc;
2023-07-05 09:06:04 +00:00
2023-07-07 08:55:59 +00:00
use poise::serenity_prelude::GuildChannel;
2023-07-05 09:06:04 +00:00
use serenity::async_trait;
2023-07-07 10:16:25 +00:00
use serenity::http::{self, Http};
2023-07-05 09:06:04 +00:00
use serenity::model::channel::Message;
use serenity::model::gateway::Ready;
2023-07-07 08:55:59 +00:00
use serenity::model::id::ChannelId;
2023-07-05 09:06:04 +00:00
use serenity::prelude::*;
2023-07-07 08:55:59 +00:00
use util::security::dotenv_var;
2023-07-05 09:06:04 +00:00
2023-07-07 08:55:59 +00:00
mod util;
2023-07-05 09:06:04 +00:00
struct Handler;
#[async_trait]
impl EventHandler for Handler {
async fn message(&self, ctx: Context, msg: Message) {
if msg.content == "!ping" {
if let Err(why) = msg.channel_id.say(&ctx.http, "Pong!").await {
println!("Error sending message: {:?}", why);
}
}
}
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-07 08:55:59 +00:00
// if (ready.user.name != "MOOver Debug") {
2023-07-07 10:16:25 +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-07 08:55:59 +00:00
2023-07-07 10:16:25 +00:00
// }
2023-07-07 11:44:07 +00:00
let channel = ctx.http.get_channel(780439236867653635).await.unwrap();
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-05 09:06:04 +00:00
let intents = GatewayIntents::GUILD_MESSAGES
| GatewayIntents::DIRECT_MESSAGES
| GatewayIntents::MESSAGE_CONTENT;
2023-07-07 11:44:07 +00:00
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-07 11:44:07 +00:00
2023-07-07 10:16:25 +00:00
client.start().await?;
Ok(())
2023-07-05 09:06:04 +00:00
}