moover_rust/src/main.rs

74 lines
2.1 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;
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;
use serenity::http::{self, Http};
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") {
let messages = ["AAAAAAAAAAAAAAAAAAAA", "Henlooo", "Good day y'all!",
"May have crashed...", "MOOOooo", "Heyyyyy!", "I'm baaaaack!",
"Whom'st have summoned the ancient one?"];
// }
let opt_token = dotenv_var("TOKEN");
if opt_token.is_none() {
return;
}
let token = opt_token.unwrap();
let channel_result = ctx.http.get_channel(780439236867653635).await;
let channel = channel_result.unwrap();
// let channel = await http.get_channel(780439236867653635);
// GuildChannel::say(&self, http, content)
// self.message(ctx, new_message)
// C = ;
// const debug_channel =
2023-07-05 09:06:04 +00:00
}
}
2023-07-07 08:55:59 +00:00
2023-07-05 09:06:04 +00:00
#[tokio::main]
async fn main() {
2023-07-07 08:55:59 +00:00
let opt_token = dotenv_var("TOKEN");
if opt_token.is_none() {
return;
2023-07-05 09:06:04 +00:00
}
2023-07-07 08:55:59 +00:00
let token = opt_token.unwrap();
2023-07-05 09:06:04 +00:00
let intents = GatewayIntents::GUILD_MESSAGES
| GatewayIntents::DIRECT_MESSAGES
| GatewayIntents::MESSAGE_CONTENT;
2023-07-07 08:55:59 +00:00
let mut client = Client::builder(&token, intents)
.event_handler(Handler)
.await.expect("Error creating client");
2023-07-05 09:06:04 +00:00
if let Err(why) = client.start().await {
println!("Client error: {:?}", why);
}
}