From 951771db0ffa325c0e5b81721c38b8e00db5d035 Mon Sep 17 00:00:00 2001 From: insert Date: Fri, 9 Aug 2024 15:14:33 -0400 Subject: [PATCH] Update --- rolebuttons.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rolebuttons.py b/rolebuttons.py index d547fef..f2f80d7 100644 --- a/rolebuttons.py +++ b/rolebuttons.py @@ -21,7 +21,13 @@ class RoleView(nextcord.ui.View): self.add_item(button) async def buttoncallback(self, interaction: nextcord.Interaction) -> None: - await interaction.response.send_message(f"user requested role {str(interaction.data)}", ephemeral=True) + role = int(interaction.data[custom_id].split(":")[1]) + if role in interaction.user.roles: + await interaction.user.remove_roles(role, reason=f"{interaction.user.display_name} used role button") + await interaction.response.send_message(f"Removed <@{role}> from you!", ephemeral=True, allowed_mentions=nextcord.AllowedMentions.none) + else: + await interaction.user.add_roles(role, reason=f"{interaction.user.display_name} used role button") + await interaction.response.send_message(f"Added <@{role}> to you!", ephemeral=True, allowed_mentions=nextcord.AllowedMentions.none) return