Update
This commit is contained in:
parent
9c1a7b072b
commit
951771db0f
1 changed files with 7 additions and 1 deletions
|
@ -21,7 +21,13 @@ class RoleView(nextcord.ui.View):
|
||||||
self.add_item(button)
|
self.add_item(button)
|
||||||
|
|
||||||
async def buttoncallback(self, interaction: nextcord.Interaction) -> None:
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue