commit
e34df85f0c
3 changed files with 45 additions and 36 deletions
|
@ -6,10 +6,11 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0.71"
|
||||||
cron = "0.12.0"
|
cron = "0.12.0"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
mongodb = "2.6.0"
|
mongodb = "2.6.0"
|
||||||
poise = "0.5.5"
|
poise = "0.5.5"
|
||||||
serenity = { version = "0.11.6", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "http"] }
|
serenity = { version = "0.11.6", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "http"] }
|
||||||
serenity_utils = "0.7.0"
|
serenity_utils = "0.7.0"
|
||||||
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|
59
src/main.rs
59
src/main.rs
|
@ -2,12 +2,12 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use poise::serenity_prelude::GuildChannel;
|
use poise::serenity_prelude::GuildChannel;
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
|
use serenity::http::{self, Http};
|
||||||
use serenity::model::channel::Message;
|
use serenity::model::channel::Message;
|
||||||
use serenity::model::gateway::Ready;
|
use serenity::model::gateway::Ready;
|
||||||
use serenity::model::id::ChannelId;
|
use serenity::model::id::ChannelId;
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
use util::security::dotenv_var;
|
use util::security::dotenv_var;
|
||||||
use serenity::http::{self, Http};
|
|
||||||
|
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
|
@ -26,48 +26,37 @@ impl EventHandler for Handler {
|
||||||
async fn ready(&self, ctx: Context, ready: Ready) {
|
async fn ready(&self, ctx: Context, ready: Ready) {
|
||||||
println!("{} is connected!", ready.user.name);
|
println!("{} is connected!", ready.user.name);
|
||||||
// if (ready.user.name != "MOOver Debug") {
|
// if (ready.user.name != "MOOver Debug") {
|
||||||
let messages = ["AAAAAAAAAAAAAAAAAAAA", "Henlooo", "Good day y'all!",
|
let messages = [
|
||||||
"May have crashed...", "MOOOooo", "Heyyyyy!", "I'm baaaaack!",
|
"AAAAAAAAAAAAAAAAAAAA",
|
||||||
"Whom'st have summoned the ancient one?"];
|
"Henlooo",
|
||||||
|
"Good day y'all!",
|
||||||
// }
|
"May have crashed...",
|
||||||
let opt_token = dotenv_var("TOKEN");
|
"MOOOooo",
|
||||||
if opt_token.is_none() {
|
"Heyyyyy!",
|
||||||
return;
|
"I'm baaaaack!",
|
||||||
}
|
"Whom'st have summoned the ancient one?",
|
||||||
|
];
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
let channel = ctx.http.get_channel(780439236867653635).await.unwrap();
|
||||||
|
|
||||||
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]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let opt_token = dotenv_var("TOKEN");
|
use anyhow::Context;
|
||||||
if opt_token.is_none() {
|
let token = dotenv_var("TOKEN").context("No TOKEN in env")?;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let token = opt_token.unwrap();
|
|
||||||
|
|
||||||
let intents = GatewayIntents::GUILD_MESSAGES
|
let intents = GatewayIntents::GUILD_MESSAGES
|
||||||
| GatewayIntents::DIRECT_MESSAGES
|
| GatewayIntents::DIRECT_MESSAGES
|
||||||
| GatewayIntents::MESSAGE_CONTENT;
|
| GatewayIntents::MESSAGE_CONTENT;
|
||||||
|
|
||||||
let mut client = Client::builder(&token, intents)
|
let mut client = Client::builder(&token, intents)
|
||||||
.event_handler(Handler)
|
.event_handler(Handler)
|
||||||
.await.expect("Error creating client");
|
.await
|
||||||
|
.context("Failed to build client")?;
|
||||||
if let Err(why) = client.start().await {
|
|
||||||
println!("Client error: {:?}", why);
|
client.start().await?;
|
||||||
}
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
19
src/sample.rs
Normal file
19
src/sample.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
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<dyn Countable>) {
|
||||||
|
var.count();
|
||||||
|
}
|
Loading…
Reference in a new issue