Update
This commit is contained in:
parent
4bd4fb64a6
commit
1e45354916
1 changed files with 18 additions and 0 deletions
|
@ -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))
|
Loading…
Reference in a new issue