commit ig
This commit is contained in:
parent
6621bbbba9
commit
b756df8894
4 changed files with 56 additions and 16 deletions
|
@ -8,8 +8,8 @@ edition = "2021"
|
|||
[dependencies]
|
||||
cron = "0.12.0"
|
||||
dotenv = "0.15.0"
|
||||
mongodb = "2.4.0"
|
||||
poise = "0.5.2"
|
||||
serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
|
||||
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.21.2", features = ["macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
|
51
src/main.rs
51
src/main.rs
|
@ -1,13 +1,15 @@
|
|||
extern crate dotenv;
|
||||
|
||||
use std::env;
|
||||
use std::sync::Arc;
|
||||
|
||||
use poise::serenity_prelude::GuildChannel;
|
||||
use serenity::async_trait;
|
||||
use serenity::model::channel::Message;
|
||||
use serenity::model::gateway::Ready;
|
||||
use serenity::model::id::ChannelId;
|
||||
use serenity::prelude::*;
|
||||
use util::security::dotenv_var;
|
||||
use serenity::http::{self, Http};
|
||||
|
||||
use dotenv::dotenv;
|
||||
mod util;
|
||||
|
||||
struct Handler;
|
||||
|
||||
|
@ -21,25 +23,50 @@ impl EventHandler for Handler {
|
|||
}
|
||||
}
|
||||
|
||||
async fn ready(&self, _: Context, ready: Ready) {
|
||||
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?"];
|
||||
|
||||
// }
|
||||
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 =
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
dotenv().ok();
|
||||
let token;
|
||||
let key = "TOKEN";
|
||||
match env::var(key) {
|
||||
Ok(val) => token = val,
|
||||
Err(_) => return,
|
||||
let opt_token = dotenv_var("TOKEN");
|
||||
if opt_token.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let token = opt_token.unwrap();
|
||||
|
||||
let intents = GatewayIntents::GUILD_MESSAGES
|
||||
| GatewayIntents::DIRECT_MESSAGES
|
||||
| GatewayIntents::MESSAGE_CONTENT;
|
||||
|
||||
let mut client = Client::builder(&token, intents).event_handler(Handler).await.expect("Error creating client");
|
||||
let mut client = Client::builder(&token, intents)
|
||||
.event_handler(Handler)
|
||||
.await.expect("Error creating client");
|
||||
|
||||
if let Err(why) = client.start().await {
|
||||
println!("Client error: {:?}", why);
|
||||
|
|
1
src/util/mod.rs
Normal file
1
src/util/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod security;
|
12
src/util/security.rs
Normal file
12
src/util/security.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
|
||||
pub fn dotenv_var(key: &str) -> Option<String> {
|
||||
dotenv().ok();
|
||||
let key = "TOKEN";
|
||||
|
||||
match env::var(key) {
|
||||
Ok(val) => return Some(val),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue