Skip to content

Commit

Permalink
use custom timeout for each view
Browse files Browse the repository at this point in the history
  • Loading branch information
circuitsacul committed Jan 14, 2023
1 parent aa2a68c commit 97258af
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/interactions/commands/chat/moststarred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ async fn scrolling_paginator(
&["moststarred_scroller::next"],
message_id.unwrap(),
user_id,
60 * 5,
)
.await;

Expand Down
10 changes: 8 additions & 2 deletions src/utils/views/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ pub async fn wait_for_result(
message_id: Id<MessageMarker>,
user_id: Id<UserMarker>,
) -> Option<(ComponentCtx, bool)> {
let btn_ctx =
wait_for_button(bot, &["confirm::yes", "confirm::no"], message_id, user_id).await?;
let btn_ctx = wait_for_button(
bot,
&["confirm::yes", "confirm::no"],
message_id,
user_id,
30,
)
.await?;

let conf = match &*btn_ctx.data.custom_id {
"confirm::yes" => true,
Expand Down
1 change: 1 addition & 0 deletions src/utils/views/paginator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub async fn simple(
],
msg_id,
user_id,
60 * 5,
)
.await;

Expand Down
3 changes: 2 additions & 1 deletion src/utils/views/wait_for.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub async fn wait_for_button(
button_ids: &'static [&'static str],
message_id: Id<MessageMarker>,
user_id: Id<UserMarker>,
timeout: u64,
) -> Option<ComponentCtx> {
let check = move |int: &Interaction| {
let data = match &int.data {
Expand Down Expand Up @@ -43,7 +44,7 @@ pub async fn wait_for_button(
};

let event = tokio::time::timeout(
Duration::from_secs(30),
Duration::from_secs(timeout),
bot.standby.wait_for_component(message_id, check),
)
.await
Expand Down

0 comments on commit 97258af

Please sign in to comment.