Skip to content

Commit

Permalink
misc: put blacklist check in all views
Browse files Browse the repository at this point in the history
  • Loading branch information
laggron42 committed Sep 25, 2022
1 parent 8d2e1ad commit dd2d68e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ballsdex/core/utils/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion ballsdex/packages/countryballs/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion ballsdex/packages/players/exchange_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand Down

0 comments on commit dd2d68e

Please sign in to comment.