From ebb422a9841c3924b0d68b4a96c56637f1047c3c Mon Sep 17 00:00:00 2001 From: insert Date: Sun, 11 Aug 2024 15:32:39 -0400 Subject: [PATCH] Update --- rolebuttons.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rolebuttons.py b/rolebuttons.py index 2318f82..47a6b1b 100644 --- a/rolebuttons.py +++ b/rolebuttons.py @@ -52,7 +52,15 @@ class rolebutton(commands.Cog): @commands.Cog.listener('on_ready') async def roleready(self): - self.bot.add_view(RoleView(self.bot)) + for g in self.bot.guilds: + res = await self.bot.cur.execute(f"SELECT roleid FROM rolebutton WHERE serverid = {g.id}") + res = await res.fetchall() + buttonlist.clear() + for [r] in res: + role = g.get_role(int(r)) + button = nextcord.ui.Button(label=role.name, style=nextcord.ButtonStyle.gray, custom_id=f"rolebutton:{role.id}") + buttonlist.append(button) + self.bot.add_view(RoleView(self.bot)) @nextcord.slash_command( name="rolebuttons", @@ -79,7 +87,6 @@ class rolebutton(commands.Cog): 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 message.edit(view=RoleView(self.bot))