Сheck for the existence of target user have been added

This commit is contained in:
doryan 2024-06-08 03:08:00 +04:00
parent ac9fbcf344
commit 89119936c8

View File

@ -22,8 +22,20 @@ pub async fn dice_handler(bot: Bot, message: Message) -> HandlerResult {
let handler_entity: HandlerEntity = HandlerEntity::new(bot, message, sender); let handler_entity: HandlerEntity = HandlerEntity::new(bot, message, sender);
let (mute_time, emoji): (TimeMetrics, &str) = (TimeMetrics::Days(dice.value), &dice.emoji); let (mute_time, emoji): (TimeMetrics, &str) = (TimeMetrics::Days(dice.value), &dice.emoji);
let target: TargetUser = TargetUser::Reply(handler_entity.message_reciever.clone()); let target: TargetUser = TargetUser::Reply(handler_entity.message_reciever.clone());
if !target.exist() {
handler_entity
.message_sender_builder
.text("Нет ответа на сообщение пользователя.")
.build()
.send(&handler_entity.bot_instance)
.await?;
return Ok(EventReturn::Cancel);
}
match emoji { match emoji {
"🎲" => { "🎲" => {
mute_member(handler_entity, chat_id, target, (mute_time, DICE_DELAY_MS)).await?; mute_member(handler_entity, chat_id, target, (mute_time, DICE_DELAY_MS)).await?;