This commit is contained in:
insert 2024-08-10 16:07:44 -04:00
parent 4bd4fb64a6
commit 1e45354916
Signed by: insert
GPG key ID: A70775C389ACF105

View file

@ -64,9 +64,27 @@ class rolebutton(commands.Cog):
if msg.author.id != self.bot.application_id: if msg.author.id != self.bot.application_id:
await interaction.response.send_message("I can't edit that message", ephemeral=True) await interaction.response.send_message("I can't edit that message", ephemeral=True)
return return
res = await self.bot.cur.execute(f"SELECT roleid FROM rolebutton WHERE serverid = {interaction.guild.id}")
res = await res.fetchall()
for r in res:
button = nextcord.ui.Button(label="r", style=nextcord.ButtonStyle.gray, custom_id=f"rolebutton:{r}")
button.callback = RoleView.buttoncallback
RoleView.add_item(button)
await msg.edit(view=RoleView(self.bot)) await msg.edit(view=RoleView(self.bot))
await interaction.response.send_message("Edited!", ephemeral=True) await interaction.response.send_message("Edited!", ephemeral=True)
@rolebuttons.subcommand(
name="add",
description="add a role to the selection message",
)
async def roleadd(self, interaction: nextcord.Interaction, role: nextcord.Role):
await self.bot.cur.execute(f"""
INSERT INTO rolebutton VALUES
({interaction.guild_id}, {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))