send a start bot request
This commit is contained in:
parent
5fb197390d
commit
5b5f4fb958
|
@ -26,8 +26,8 @@ impl EventHandler for Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start_discord_bot() -> Result<Client, String> {
|
pub async fn start_discord_bot() -> Result<Client, String> {
|
||||||
let mut client = Client::new(token::TOKEN)
|
let mut client = Client::builder(token::TOKEN)
|
||||||
.event_handler(Handler)
|
.event_handler(Handler)
|
||||||
.await
|
.await
|
||||||
.map_err(|why| format!("Client error: {:?}", why))?;
|
.map_err(|why| format!("Client error: {:?}", why))?;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use image::GenericImageView;
|
use image::GenericImageView;
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
use std::{error::Error, sync::Arc, thread, time};
|
use std::{error::Error, sync::Arc, thread, time, future::Future};
|
||||||
|
|
||||||
mod bot;
|
mod bot;
|
||||||
|
|
||||||
|
@ -27,15 +27,15 @@ fn main() -> Result<(), eframe::Error> {
|
||||||
struct Jiji {
|
struct Jiji {
|
||||||
next_frame: time::Instant,
|
next_frame: time::Instant,
|
||||||
bot: Option<Client>,
|
bot: Option<Client>,
|
||||||
|
bot_future: Option<Box<dyn Future<Output = Result<Client, String>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Jiji {
|
impl Default for Jiji {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
// should start the bot
|
|
||||||
Self {
|
Self {
|
||||||
next_frame: time::Instant::now(),
|
next_frame: time::Instant::now(),
|
||||||
bot: None,
|
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();
|
self.next_frame = time::Instant::now();
|
||||||
|
|
||||||
//here if bot started put its reference in self.bot
|
|
||||||
|
|
||||||
self.draw_feed(ctx);
|
self.draw_feed(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +57,7 @@ impl Jiji {
|
||||||
ui.label("Hello there");
|
ui.label("Hello there");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_icon() -> Result<egui::IconData, Box<dyn Error>> {
|
pub fn load_icon() -> Result<egui::IconData, Box<dyn Error>> {
|
||||||
|
|
Loading…
Reference in a new issue