diff --git a/rolebuttons.py b/rolebuttons.py index 8f1bd9b..d765900 100644 --- a/rolebuttons.py +++ b/rolebuttons.py @@ -6,12 +6,14 @@ import aiosqlite as sqlite3 import aiohttp from urllib.parse import urlparse import os +buttonlist = [] class RoleView(nextcord.ui.View): def __init__(self,bot): super().__init__(timeout=None) self.bot = bot - + for b in buttonlist: + 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 @@ -65,10 +67,11 @@ class rolebutton(commands.Cog): return 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: button = nextcord.ui.Button(label="r", style=nextcord.ButtonStyle.gray, custom_id=f"rolebutton:{r}") button.callback = RoleView.buttoncallback - RoleView.add_item(RoleView,button) + buttonlist.append(button) await message.edit(view=RoleView(self.bot)) await interaction.response.send_message("Edited!", ephemeral=True)