Add a 5 minutes timeout to selectors

This commit is contained in:
Victor Mignot 2023-05-02 18:09:22 +02:00
parent a2dd37118a
commit ddbc1db052
No known key found for this signature in database
GPG key ID: FFE4EF056FB5E0D0

View file

@ -1,4 +1,4 @@
use std::collections::HashSet;
use std::{collections::HashSet, time::Duration};
use futures::StreamExt;
use log::warn;
@ -16,6 +16,7 @@ use crate::discord::commands::commons::CommandExecutionError;
use super::embed_builder::EmbedMessageBuilder;
const MAX_SELECTABLE_PER_PAGE: usize = 10;
const COLLECTOR_MAX_DURATION_SEC: u64 = 5000;
/*
* Match the Discord 0 to 9 icon (that are encoded with three utf-8 character)
@ -171,6 +172,7 @@ impl<'a> EmbedSelector<'a> {
.add_event_type(EventType::ReactionAdd)
.add_user_id(self.interaction.user.id)
.add_message_id(*answer.id.as_u64())
.timeout(Duration::from_secs(COLLECTOR_MAX_DURATION_SEC))
.build()
.map_err(|_e| {
CommandExecutionError::SelectorError(