feat: Implemented daily timer

- Bump version to 0.10.0
- Added /timer command
This commit is contained in:
Alexey 2025-12-18 15:58:18 +03:00
commit cc916c06ce
11 changed files with 187 additions and 32 deletions

View file

@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::{sync::{Arc, Mutex}};
use clap::Parser;
use dotenvy::dotenv;
@ -13,16 +13,42 @@ mod config;
mod account;
mod error;
mod strings;
mod timer;
const CONFIG_PATH: &str = "cfg/config.toml";
const DISCORD_TOKEN: &str = "DISCORD_TOKEN";
#[derive(Debug)]
struct InnerBool {
pub value: bool,
}
#[derive(Debug)]
struct Data {
pub config: Config,
pub discord: Arc<Mutex<DiscordConfig>>,
pub strings: Strings,
pub timer_set: Arc<Mutex<InnerBool>>,
}
impl Data {
pub fn timer(&self) {
let tm = self.timer_set.clone();
{
let mut guard = tm.lock().unwrap();
guard.value = true;
}
}
pub fn has_timer(&self) -> bool {
let tm = self.timer_set.clone();
{
let guard = tm.lock().unwrap();
guard.value
}
}
}
type Context<'a> = poise::Context<'a, Data, Error>;
#[tokio::main]
@ -43,10 +69,11 @@ async fn main() {
.options(poise::FrameworkOptions {
on_error: |err| Box::pin(error_handler(err)),
commands: vec![
//commands::register(),
commands::register(),
commands::quest::quest(),
commands::info(),
commands::init::init(),
commands::init::timer(),
commands::answer::answer(),
commands::social::social(),
commands::account::scoreboard(),
@ -57,12 +84,13 @@ async fn main() {
],
..Default::default()
})
.setup(|ctx, _ready, _framework| {
.setup(|_ctx, _ready, _framework| {
Box::pin(async move {
//poise::builtins::register_globally(ctx, &framework.options().commands).await?;
Ok(Data {
config,
discord: Arc::new(Mutex::new(discord)),
timer_set: Arc::new(Mutex::new(InnerBool { value: false })),
strings,
})
})