use telers::{ event::{telegram::HandlerResult, EventReturn}, types::{Dice, Message}, Bot, }; use crate::{ actions::{ban::ban_member, mute::mute_member}, types::{ enums::{target_user::TargetUser, time_metrics::TimeMetrics}, structs::{handler_entity::HandlerEntity, message_sender::MessageSender}, }, }; const DICE_DELAY_MS: u64 = 4000u64; const CASINO_DELAY_MS: u64 = 1500u64; pub async fn dice_handler(bot: Bot, message: Message) -> HandlerResult { let (chat_id, dice): (i64, Dice) = (message.chat().id(), message.dice().unwrap().clone()); let sender = MessageSender::builder(chat_id); let mut handler_entity = HandlerEntity::new(bot, message, sender); let (mute_time, emoji): (TimeMetrics, &str) = (TimeMetrics::Days(dice.value), &dice.emoji); let target = TargetUser::Reply(handler_entity.message_reciever.clone()); match emoji { "🎲" => { mute_member(handler_entity, chat_id, target, (mute_time, DICE_DELAY_MS)).await?; } "🎰" => { if dice.value == 64 { ban_member(handler_entity, chat_id, target, CASINO_DELAY_MS).await?; } else { mute_member( handler_entity, chat_id, target, (mute_time, CASINO_DELAY_MS), ) .await?; } } _ => () } Ok(EventReturn::Finish) }