from discord import Interaction, Message, NotFound, ui from redbot.core import commands from redbot.core.utils.mod import is_admin_or_superior class ProviderAddView(ui.View): def __init__(self, ctx: commands.Context, message: Message, timeout: int | None = None) -> None: super().__init__(timeout=timeout) self.ctx = ctx self.message = message async def on_timeout() -> None: try: await self.message.edit(view=None) except NotFound: pass async def interaction_check(self, interaction: Interaction) -> bool: if await interaction.client.is_owner(interaction.user) or (interaction.guild and await is_admin_or_superior(self.ctx.bot, interaction.author)): return True await interaction.response.send_message("This button is only for bot owners or server administrators.", ephemeral=True) return False