From 06ee7b7330fcc03b1d39823a854a10e01a2dd123 Mon Sep 17 00:00:00 2001 From: tookender Date: Sun, 25 Aug 2024 21:14:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A9=20Add=20interaction=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/config/levelling.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/extensions/config/levelling.py b/extensions/config/levelling.py index 757e6d9..524aced 100644 --- a/extensions/config/levelling.py +++ b/extensions/config/levelling.py @@ -1,11 +1,11 @@ -import traceback +import traceback, random from typing import Optional import discord from discord.ext import commands from discord import app_commands -from utils import Embed, Interaction, Invalid +from utils import Embed, Interaction, Invalid, constants from ._base import ConfigBase @@ -99,6 +99,14 @@ def __init__(self): super().__init__(placeholder="Change an option...", min_values=1, max_values=1, options=options) + async def interaction_check(self, interaction: Interaction) -> bool: + if interaction.user and interaction.user.id in (self.ctx.bot.owner_id, self.ctx.author.id): + return True + + messages = random.choice(constants.NOT_YOUR_BUTTON) + await interaction.response.send_message(random.choice(messages).format(user=self.ctx.author.display_name), ephemeral=True) + return False + async def callback(self, interaction: Interaction): if interaction.guild: data = await interaction.client.pool.fetchrow( @@ -128,6 +136,14 @@ class ConfigLevelling(discord.ui.View): def __init__(self): super().__init__() self.add_item(ConfigLevellingDropdown()) + + async def interaction_check(self, interaction: Interaction) -> bool: + if interaction.user and interaction.user.id in (self.ctx.bot.owner_id, self.ctx.author.id): + return True + + messages = random.choice(constants.NOT_YOUR_BUTTON) + await interaction.response.send_message(random.choice(messages).format(user=self.ctx.author.display_name), ephemeral=True) + return False @discord.ui.button(label="View Announcement Message", emoji="💬", style=discord.ButtonStyle.blurple) async def view_message(self, interaction: Interaction, button: discord.ui.Button):