FunkyBot/libs/LanguageButton.py

22 lines
904 B
Python
Raw Normal View History

import discord
from libs.Roles import Roles
class LanguageButton(discord.ui.Button):
def __init__(self):
super().__init__()
self.style = discord.ButtonStyle.blurple
self.label = "Not Set"
self.disabled: bool = False
async def callback(self, interaction: discord.Interaction):
role = await Roles().get_role(interaction.guild, self.label)
message = None
if role in interaction.user.roles:
await Roles().remove_role(interaction.guild, self.label, interaction.user)
message = f"You are no longer associated with the {self.label} language group"
else:
await Roles().add_role(interaction.guild, self.label, interaction.user)
message = f"You are now associated with the {self.label} language group"
await interaction.response.send_message(message, delete_after=5, ephemeral=True)