From 1e453549166718daf13de8eea7e63d7ebd9c364f Mon Sep 17 00:00:00 2001 From: insert Date: Sat, 10 Aug 2024 16:07:44 -0400 Subject: [PATCH] Update --- rolebuttons.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rolebuttons.py b/rolebuttons.py index 3677f36..2056188 100644 --- a/rolebuttons.py +++ b/rolebuttons.py @@ -64,9 +64,27 @@ class rolebutton(commands.Cog): if msg.author.id != self.bot.application_id: await interaction.response.send_message("I can't edit that message", ephemeral=True) 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 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): bot.add_cog(rolebutton(bot)) \ No newline at end of file