25 lines
767 B
Python
25 lines
767 B
Python
from typing import Optional
|
|
|
|
import discord
|
|
from utils.base import BasicView
|
|
|
|
|
|
class DeleteButton(BasicView):
|
|
def __init__(self, timeout: Optional[float] = 60.0):
|
|
super().__init__(timeout=timeout, clear=True)
|
|
|
|
async def interaction_check(self, i: discord.Interaction):
|
|
if i.message.channel.permissions_for(i.user).manage_messages:
|
|
return True
|
|
return await super().interaction_check(i)
|
|
|
|
async def on_timeout(self):
|
|
await super().on_timeout()
|
|
|
|
@discord.ui.button(
|
|
emoji="<:trash:1066023933662466080>", style=discord.ButtonStyle.red
|
|
)
|
|
async def delete(self, interaction: discord.Interaction, button: discord.ui.Button):
|
|
"""delete a message"""
|
|
await interaction.message.delete()
|