FunkyBot/views/items/MatrixRefuserPenguinsButton.py

27 lines
1.1 KiB
Python

import discord
from libs.Roles import Roles
class MatrixRefuserPenguinsButton(discord.ui.Button):
def __init__(self):
super().__init__()
self.style = discord.ButtonStyle.red
self.label = "Matrix-Refuser Penguins"
self.disabled: bool = False
async def callback(self, interaction: discord.Interaction):
member = interaction.user
content = []
matrix_refuser_role = await Roles().get_role(interaction.guild, "Matrix-Refuser Penguins")
if matrix_refuser_role in member.roles:
if await Roles().remove_role(interaction.guild, "Matrix-Refuser Penguins", member):
content.append("Matrix-Refuser Penguins has been removed")
else:
if await Roles().remove_role(interaction.guild, "Matrix Penguins", member):
content.append("Matrix-Refuser Penguins has been removed")
if await Roles().add_role(interaction.guild, "Matrix-Refuser Penguins", member):
content.append("Matrix-Refuser Penguins has been added")
await interaction.response.send_message(" and ".join(content), delete_after=5, ephemeral=True)