added bot
This commit is contained in:
parent
bccfbc7a3f
commit
6ed443b405
|
@ -8,3 +8,5 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = "0.26.2"
|
eframe = "0.26.2"
|
||||||
image = "0.24.9"
|
image = "0.24.9"
|
||||||
|
tokio = { version = "0.2", features = ["macros"] }
|
||||||
|
serenity = { default-features = false, features = ["client", "gateway", "model", "rustls_backend"], version = "0.9.0-rc.2"}
|
1
jiji.project
Normal file
1
jiji.project
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"categories":[{"name":"to do","content":[{"name":"run discord bot","description":"make it so the bot is running","id":1},{"name":"get incoming messages","description":"read","id":2},{"name":"sort messages by origin","description":"// Hello there","id":3},{"name":"fetch previous messages","description":"// Hello there","id":4},{"name":"ability to write messages","description":"// Hello there","id":5}]},{"name":"in progress","content":[]},{"name":"done","content":[]},{"name":"bugs","content":[]},{"name":"+","content":[]}]}
|
77
src/main.rs
77
src/main.rs
|
@ -5,32 +5,41 @@ use std::{
|
||||||
time,
|
time,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
error::Error,
|
error::Error,
|
||||||
|
env,
|
||||||
};
|
};
|
||||||
|
use serenity::{
|
||||||
|
async_trait,
|
||||||
|
model::{channel::Message, gateway::Ready},
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
|
||||||
|
mod token;
|
||||||
|
|
||||||
|
|
||||||
const MAX_FPS : f32 = 30.0;
|
const MAX_FPS : f32 = 30.0;
|
||||||
|
const HELP_MESSAGE: &str = "Hello there, Human! I am a messenger for the wandering penwing.";
|
||||||
|
const HELP_COMMAND: &str = "!jiji";
|
||||||
|
|
||||||
|
|
||||||
fn main() -> Result<(), eframe::Error> {
|
//fn main() -> Result<(), eframe::Error> {
|
||||||
let icon_data = load_icon().unwrap_or_default();
|
// let icon_data = load_icon().unwrap_or_default();
|
||||||
|
//
|
||||||
let options = eframe::NativeOptions {
|
// let options = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
// viewport: egui::ViewportBuilder::default()
|
||||||
.with_inner_size([1200.0, 800.0])
|
// .with_inner_size([1200.0, 800.0])
|
||||||
.with_icon(Arc::new(icon_data)),
|
// .with_icon(Arc::new(icon_data)),
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
eframe::run_native(
|
// eframe::run_native(
|
||||||
"Jiji",
|
// "Jiji",
|
||||||
options,
|
// options,
|
||||||
Box::new(move |_cc| Box::from(Jiji::default())),
|
// Box::new(move |_cc| Box::from(Jiji::default())),
|
||||||
)
|
// )
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
struct Jiji {
|
struct Jiji {
|
||||||
token: String,
|
|
||||||
next_frame: time::Instant,
|
next_frame: time::Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +47,6 @@ struct Jiji {
|
||||||
impl Default for Jiji {
|
impl Default for Jiji {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
token: "test".to_string(),
|
|
||||||
next_frame: time::Instant::now(),
|
next_frame: time::Instant::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,4 +86,37 @@ pub fn load_icon() -> Result<egui::IconData, Box<dyn Error>> {
|
||||||
width: icon_width,
|
width: icon_width,
|
||||||
height: icon_height,
|
height: icon_height,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct Handler;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl EventHandler for Handler {
|
||||||
|
async fn message(&self, ctx: Context, msg: Message) {
|
||||||
|
if msg.content == HELP_COMMAND {
|
||||||
|
if let Err(why) = msg.channel_id.say(&ctx.http, HELP_MESSAGE).await {
|
||||||
|
println!("Error sending message: {:?}", why);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn ready(&self, _: Context, ready: Ready) {
|
||||||
|
println!("{} is connected!", ready.user.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
//let token = env::var(token::TOKEN)
|
||||||
|
//.expect("Expected a token in the environment");
|
||||||
|
|
||||||
|
let mut client = Client::new(&token::TOKEN)
|
||||||
|
.event_handler(Handler)
|
||||||
|
.await
|
||||||
|
.expect("Err creating client");
|
||||||
|
|
||||||
|
if let Err(why) = client.start().await {
|
||||||
|
println!("Client error: {:?}", why);
|
||||||
|
}
|
||||||
}
|
}
|
1
src/token.rs
Normal file
1
src/token.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub const TOKEN : &str = "MTIxNTIwMzEyMTk5NTcxNDU4MQ.G2P14S.kMBadIiCH6Lo8Y_V_VU42WLmBVBkbI39CojiAo";
|
Loading…
Reference in a new issue