From dd2d68e89563ca07c258fab51e62ec93d00a45a9 Mon Sep 17 00:00:00 2001 From: retke Date: Mon, 26 Sep 2022 00:20:21 +0200 Subject: [PATCH] misc: put blacklist check in all views --- ballsdex/core/utils/paginator.py | 3 +++ ballsdex/packages/countryballs/components.py | 7 ++++++- ballsdex/packages/players/exchange_interaction.py | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ballsdex/core/utils/paginator.py b/ballsdex/core/utils/paginator.py index 5e7897c2e..fce811b7c 100644 --- a/ballsdex/core/utils/paginator.py +++ b/ballsdex/core/utils/paginator.py @@ -142,6 +142,9 @@ async def show_checked_page(self, interaction: discord.Interaction, page_number: pass async def interaction_check(self, interaction: discord.Interaction) -> bool: + bot = cast("BallsDexBot", interaction.client) + if not await bot.blacklist_check(interaction): + return False if interaction.user and interaction.user.id in ( self.bot.owner_id, self.original_interaction.user.id, diff --git a/ballsdex/packages/countryballs/components.py b/ballsdex/packages/countryballs/components.py index 0c9b5525a..fb9a51146 100755 --- a/ballsdex/packages/countryballs/components.py +++ b/ballsdex/packages/countryballs/components.py @@ -2,12 +2,13 @@ import discord import random -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, cast from discord.ui import Modal, TextInput, Button, View from ballsdex.core.models import Player, BallInstance if TYPE_CHECKING: + from ballsdex.core.bot import BallsDexBot from ballsdex.packages.countryballs.countryball import CountryBall @@ -78,6 +79,10 @@ def __init__(self, ball: "CountryBall"): self.button = CatchButton(ball) self.add_item(self.button) + async def interaction_check(self, interaction: discord.Interaction, /) -> bool: + bot = cast("BallsDexBot", interaction.client) + return await bot.blacklist_check(interaction) + async def on_timeout(self): self.button.disabled = True if self.ball.message: diff --git a/ballsdex/packages/players/exchange_interaction.py b/ballsdex/packages/players/exchange_interaction.py index eacd025fc..822c44ef6 100755 --- a/ballsdex/packages/players/exchange_interaction.py +++ b/ballsdex/packages/players/exchange_interaction.py @@ -25,8 +25,11 @@ def __init__(self, player1: ExchangePlayer, player2: ExchangePlayer): self.player2 = player2 async def interaction_check(self, interaction: discord.Interaction) -> bool: + bot = cast("BallsDexBot", interaction.client) + if not await bot.blacklist_check(interaction): + return False if interaction.user and interaction.user.id in ( - cast("BallsDexBot", interaction.client).owner_id, + bot.owner_id, self.player1.user.id, self.player2.user.id, ):