This commit is contained in:
insert 2024-08-11 15:32:39 -04:00
parent 683e182e79
commit ebb422a984
Signed by: insert
GPG key ID: A70775C389ACF105

View file

@ -52,6 +52,14 @@ class rolebutton(commands.Cog):
@commands.Cog.listener('on_ready') @commands.Cog.listener('on_ready')
async def roleready(self): async def roleready(self):
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)) self.bot.add_view(RoleView(self.bot))
@nextcord.slash_command( @nextcord.slash_command(
@ -79,7 +87,6 @@ class rolebutton(commands.Cog):
buttonlist.clear() buttonlist.clear()
for [r] in res: for [r] in res:
role = interaction.guild.get_role(int(r)) 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}") button = nextcord.ui.Button(label=role.name, style=nextcord.ButtonStyle.gray, custom_id=f"rolebutton:{role.id}")
buttonlist.append(button) buttonlist.append(button)
await message.edit(view=RoleView(self.bot)) await message.edit(view=RoleView(self.bot))