update
This commit is contained in:
parent
08986386b3
commit
af7a4bce0a
2 changed files with 34 additions and 11 deletions
|
@ -15,7 +15,7 @@ class GameView(nextcord.ui.View):
|
||||||
@nextcord.ui.button(
|
@nextcord.ui.button(
|
||||||
label="Next Turn", style=nextcord.ButtonStyle.green, custom_id="gameutils:nextturn"
|
label="Next Turn", style=nextcord.ButtonStyle.green, custom_id="gameutils:nextturn"
|
||||||
)
|
)
|
||||||
async def approve(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
async def nextturn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||||
ogmsg = interaction.message.content.split("\n")
|
ogmsg = interaction.message.content.split("\n")
|
||||||
ogmsg.pop(0)
|
ogmsg.pop(0)
|
||||||
message = "It has been decreed..\n"
|
message = "It has been decreed..\n"
|
||||||
|
|
|
@ -15,21 +15,14 @@ class RoleView(nextcord.ui.View):
|
||||||
for b in buttonlist:
|
for b in buttonlist:
|
||||||
b.callback = self.buttoncallback
|
b.callback = self.buttoncallback
|
||||||
self.add_item(b)
|
self.add_item(b)
|
||||||
#res = await self.bot.cur.execute(f"SELECT roleid FROM rolebutton WHERE serverid = {self.bot.roleguild.id}")
|
|
||||||
button = nextcord.ui.Button(label="Test", style=nextcord.ButtonStyle.gray, custom_id="rolebutton:821095192831852554")
|
|
||||||
button.callback = self.buttoncallback
|
|
||||||
self.add_item(button)
|
|
||||||
button = nextcord.ui.Button(label="Test 2", style=nextcord.ButtonStyle.gray, custom_id="rolebutton:1058708072064884736")
|
|
||||||
button.callback = self.buttoncallback
|
|
||||||
self.add_item(button)
|
|
||||||
|
|
||||||
async def buttoncallback(self, interaction: nextcord.Interaction) -> None:
|
async def buttoncallback(self, interaction: nextcord.Interaction) -> None:
|
||||||
role = interaction.guild.get_role(int(interaction.data["custom_id"].split(":")[1]))
|
role = interaction.guild.get_role(int(interaction.data["custom_id"].split(":")[1]))
|
||||||
if role in interaction.user.roles:
|
if role in interaction.user.roles:
|
||||||
await interaction.user.remove_roles(role, reason=f"{interaction.user.display_name} used role button")
|
await interaction.user.remove_roles(role, reason=f"{interaction.user.name} used role button")
|
||||||
await interaction.response.send_message(f"Removed <@&{role.id}> from you!", ephemeral=True, allowed_mentions=nextcord.AllowedMentions.none())
|
await interaction.response.send_message(f"Removed <@&{role.id}> from you!", ephemeral=True, allowed_mentions=nextcord.AllowedMentions.none())
|
||||||
else:
|
else:
|
||||||
await interaction.user.add_roles(role, reason=f"{interaction.user.display_name} used role button")
|
await interaction.user.add_roles(role, reason=f"{interaction.user.name} used role button")
|
||||||
await interaction.response.send_message(f"Added <@&{role.id}> to you!", ephemeral=True, allowed_mentions=nextcord.AllowedMentions.none())
|
await interaction.response.send_message(f"Added <@&{role.id}> to you!", ephemeral=True, allowed_mentions=nextcord.AllowedMentions.none())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -60,9 +53,10 @@ class rolebutton(commands.Cog):
|
||||||
await interaction.response.send_message(view=RoleView(self.bot))
|
await interaction.response.send_message(view=RoleView(self.bot))
|
||||||
|
|
||||||
@nextcord.message_command(
|
@nextcord.message_command(
|
||||||
name="Refresh role buttons",
|
name="Refresh Role Buttons",
|
||||||
default_member_permissions=nextcord.Permissions(manage_roles=True),
|
default_member_permissions=nextcord.Permissions(manage_roles=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
@nextcord.ext.application_checks.has_permissions(manage_roles=True)
|
@nextcord.ext.application_checks.has_permissions(manage_roles=True)
|
||||||
async def rolerefresh(self, interaction: nextcord.Interaction, message: nextcord.Message):
|
async def rolerefresh(self, interaction: nextcord.Interaction, message: nextcord.Message):
|
||||||
if message.author.id != self.bot.application_id:
|
if message.author.id != self.bot.application_id:
|
||||||
|
@ -79,6 +73,24 @@ class rolebutton(commands.Cog):
|
||||||
await message.edit(view=RoleView(self.bot))
|
await message.edit(view=RoleView(self.bot))
|
||||||
await interaction.response.send_message("Edited!", ephemeral=True)
|
await interaction.response.send_message("Edited!", ephemeral=True)
|
||||||
|
|
||||||
|
@rolebuttons.subcommand(
|
||||||
|
name="create",
|
||||||
|
description="Create a role message",
|
||||||
|
)
|
||||||
|
|
||||||
|
@nextcord.ext.application_checks.has_permissions(manage_roles=True)
|
||||||
|
async def rolecreate(self, interaction: nextcord.Interaction, content: str):
|
||||||
|
res = await self.bot.cur.execute(f"SELECT roleid FROM rolebutton WHERE serverid = {interaction.guild.id}")
|
||||||
|
res = await res.fetchall()
|
||||||
|
buttonlist.clear()
|
||||||
|
for [r] in res:
|
||||||
|
role = interaction.guild.get_role(int(r))
|
||||||
|
role.name
|
||||||
|
button = nextcord.ui.Button(label=role.name, style=nextcord.ButtonStyle.gray, custom_id=f"rolebutton:{role.id}")
|
||||||
|
buttonlist.append(button)
|
||||||
|
await interaction.channel.send(content=content, view=RoleView(self.bot))
|
||||||
|
await interaction.response.send_message("Done", ephemeral=True)
|
||||||
|
|
||||||
@rolebuttons.subcommand(
|
@rolebuttons.subcommand(
|
||||||
name="add",
|
name="add",
|
||||||
description="add a role to the selection message",
|
description="add a role to the selection message",
|
||||||
|
@ -91,6 +103,17 @@ class rolebutton(commands.Cog):
|
||||||
await self.bot.db.commit()
|
await self.bot.db.commit()
|
||||||
await interaction.response.send_message("Done", ephemeral=True)
|
await interaction.response.send_message("Done", ephemeral=True)
|
||||||
|
|
||||||
|
@rolebuttons.subcommand(
|
||||||
|
name="remove",
|
||||||
|
description="remove a role from the selection message",
|
||||||
|
)
|
||||||
|
async def roleremove(self, interaction: nextcord.Interaction, role: nextcord.Role):
|
||||||
|
await self.bot.cur.execute(f"""
|
||||||
|
DELETE FROM rolebutton WHERE serverid = {interaction.guild.id} AND roleid = {role.id})
|
||||||
|
""")
|
||||||
|
await self.bot.db.commit()
|
||||||
|
await interaction.response.send_message("Done", ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: commands.Bot):
|
||||||
bot.add_cog(rolebutton(bot))
|
bot.add_cog(rolebutton(bot))
|
Loading…
Reference in a new issue