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))