clemsbot/src/app/task/tokens.rs

20 lines
540 B
Rust

use chrono::Duration;
use crate::app::State;
use std::sync::Arc;
pub async fn start_task(state: Arc<State>) {
tokio::task::spawn(async move {
loop {
if let Err(e) = state.twitch.bot_token().await {
eprintln!("could not get bot token: {:?}", e);
}
if let Err(e) = state.twitch.user_token().await {
eprintln!("could not get user token: {:?}", e);
}
tokio::time::sleep(Duration::minutes(5).to_std().unwrap()).await;
}
});
}