# custom button class class RoleButton(discord.ui.Button): def __init__(self, isRoleActive: bool, btnName: str, cb: Callable): # Set the style of the button based on the role's state btnStyle = discord.ButtonStyle.primary if isRoleActive else discord.ButtonStyle.secondary # Call the superclass' __init__ method with the style and label for the button super().__init__(style=btnStyle, label=btnName) # Set the callback method for the button self.cb = cb async def callback(self, interaction: discord.Interaction): await self.cb(interaction) # This is our actual role View class RoleView(discord.ui.View): def __init__(self): super().__init__() # Create the buttons and add them to the view roles = ['FPS', 'MMO', 'MOBA', 'RPG', 'RTS'] # For each role, create a button and add it to the view for role in roles: self.add_item(RoleButton(True, role, self.fps_callback)) async def fps_callback(self): pass