Silly mistake made by having an await outside of the box.pin
This commit is contained in:
parent
37af7715e8
commit
2ac6929ab1
|
|
@ -378,12 +378,8 @@ pub async fn discord_main_loop(event_holder: EventHolder) {
|
|||
..Default::default()
|
||||
})
|
||||
.setup(|ctx, _ready, framework| {
|
||||
event_holder
|
||||
.discord_ctx
|
||||
.lock()
|
||||
.unwrap()
|
||||
.replace(ctx.clone());
|
||||
Box::pin(async move {
|
||||
event_holder.discord_ctx.lock().await.replace(ctx.clone());
|
||||
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||
Ok(Data { event_holder })
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
use crate::votes::EventHolder;
|
||||
use chrono::{DateTime, Local, NaiveDate};
|
||||
use poise::serenity_prelude::{CacheHttp, ChannelId};
|
||||
use serde::Serialize;
|
||||
use poise::serenity_prelude::{self, CacheHttp, ChannelId, Message};
|
||||
|
||||
/// The main scheduler waiting and dispatch loop.
|
||||
///
|
||||
|
|
@ -28,7 +27,7 @@ use serde::Serialize;
|
|||
#[cfg(not(tarpaulin_include))] // This loop is untestable instead the logic is kept to the minimal
|
||||
pub async fn main_scheduler_loop(mut interval: tokio::time::Interval, ev_ctx: EventHolder) {
|
||||
loop {
|
||||
fk_around(&ev_ctx);
|
||||
fk_around(&ev_ctx).await;
|
||||
interval.tick().await;
|
||||
// tokio::spawn(async {watchdog_update().await;}); // For async task
|
||||
let ev = ev_ctx.clone();
|
||||
|
|
@ -37,22 +36,21 @@ pub async fn main_scheduler_loop(mut interval: tokio::time::Interval, ev_ctx: Ev
|
|||
}
|
||||
|
||||
/// Close to finding out
|
||||
fn fk_around(ev_ctx: &EventHolder) {
|
||||
async fn fk_around(ev_ctx: &EventHolder) {
|
||||
println!(
|
||||
"In the fk_around function ({}):",
|
||||
Local::now() // &ev_ctx
|
||||
);
|
||||
// if let Some(discord_ctx) = ev_ctx.discord_ctx.lock().unwrap().as_mut() {
|
||||
// println!("Fking around : {:#?}", discord_ctx);
|
||||
// let _ = discord_ctx
|
||||
// .http()
|
||||
// .send_message(
|
||||
// ChannelId::new(1300786300143800351),
|
||||
// Vec::new(),
|
||||
// &"This is a message".to_owned(),
|
||||
// )
|
||||
// .await;
|
||||
// }
|
||||
if let Some(discord_ctx) = ev_ctx.discord_ctx.lock().await.as_mut() {
|
||||
println!("Fking around : {:#?}", discord_ctx);
|
||||
let mut m = serenity_prelude::Message::default();
|
||||
m.content = "Bob".into();
|
||||
let r = discord_ctx
|
||||
.http()
|
||||
.send_message(ChannelId::new(1300786300143800351), Vec::new(), &m)
|
||||
.await;
|
||||
println!("{:?}", r);
|
||||
}
|
||||
}
|
||||
|
||||
/// The `watchdog_update` function updates the state of the watchdog and executes the necessary tasks.
|
||||
|
|
|
|||
Loading…
Reference in New Issue