send a start bot request

This commit is contained in:
WanderingPenwing 2024-03-07 18:55:06 +01:00
parent 5fb197390d
commit 5b5f4fb958
2 changed files with 70 additions and 71 deletions

View file

@ -26,8 +26,8 @@ impl EventHandler for Handler {
}
}
async fn start_discord_bot() -> Result<Client, String> {
let mut client = Client::new(token::TOKEN)
pub async fn start_discord_bot() -> Result<Client, String> {
let mut client = Client::builder(token::TOKEN)
.event_handler(Handler)
.await
.map_err(|why| format!("Client error: {:?}", why))?;

View file

@ -1,7 +1,7 @@
use eframe::egui;
use image::GenericImageView;
use serenity::prelude::*;
use std::{error::Error, sync::Arc, thread, time};
use std::{error::Error, sync::Arc, thread, time, future::Future};
mod bot;
@ -27,15 +27,15 @@ fn main() -> Result<(), eframe::Error> {
struct Jiji {
next_frame: time::Instant,
bot: Option<Client>,
bot_future: Option<Box<dyn Future<Output = Result<Client, String>>>>,
}
impl Default for Jiji {
fn default() -> Self {
// should start the bot
Self {
next_frame: time::Instant::now(),
bot: None,
//bot_process_reference
bot_future: Some(Box::new(bot::start_discord_bot())),
}
}
}
@ -47,8 +47,6 @@ impl eframe::App for Jiji {
));
self.next_frame = time::Instant::now();
//here if bot started put its reference in self.bot
self.draw_feed(ctx);
}
}
@ -59,6 +57,7 @@ impl Jiji {
ui.label("Hello there");
});
}
}
pub fn load_icon() -> Result<egui::IconData, Box<dyn Error>> {