From 6cdb02ce0f2903daa502820fed92a3cd48c5f970 Mon Sep 17 00:00:00 2001 From: minneelyyyy Date: Tue, 1 Apr 2025 23:47:24 -0400 Subject: [PATCH] add message to interactions with other user's game --- src/commands/gambling/blackjack.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/commands/gambling/blackjack.rs b/src/commands/gambling/blackjack.rs index e8dd681..0f150ec 100644 --- a/src/commands/gambling/blackjack.rs +++ b/src/commands/gambling/blackjack.rs @@ -1,6 +1,6 @@ use crate::common::{Context, Error, Data}; use std::{cmp::Ordering, fmt::Display, time::Duration}; -use poise::serenity_prelude::{self as serenity}; +use poise::serenity_prelude::{self as serenity, CreateInteractionResponseMessage}; use rand::seq::SliceRandom; #[derive(Clone)] @@ -208,16 +208,20 @@ pub async fn blackjack(ctx: Context<'_>, amount: String) -> Result<(), Error> msg.edit(ctx, reply).await?; - let author_id = ctx.author().id; - let Some(mci) = serenity::ComponentInteractionCollector::new(ctx.serenity_context()) .timeout(Duration::from_secs(120)) - .filter(move |mci| mci.data.custom_id.starts_with("blackjack") - && mci.member.as_ref().unwrap().user.id == author_id).await else { + .filter(move |mci| mci.data.custom_id.starts_with("blackjack")).await else { ctx.reply("failed interaction!").await?; return Ok(()); }; + if mci.member.clone().unwrap().user.id == ctx.author().id { + mci.create_response(ctx, + serenity::CreateInteractionResponse::Message( + CreateInteractionResponseMessage::new().ephemeral(true).content("You cannot interact with this message."))).await?; + continue; + } + mci.create_response(ctx, serenity::CreateInteractionResponse::Acknowledge).await?; match &mci.data.custom_id[..] {