diff --git a/rolebuttons.py b/rolebuttons.py new file mode 100644 index 0000000..507ad55 --- /dev/null +++ b/rolebuttons.py @@ -0,0 +1,38 @@ +import nextcord +from nextcord.ext import commands +from nextcord import TextInputStyle +from random import randint +import aiosqlite as sqlite3 +import aiohttp +from urllib.parse import urlparse +import os + +class RoleView(nextcord.ui.View): + def __init__(self,bot,guild): + super().__init__(timeout=None) + self.bot = bot + + #res = await self.bot.cur.execute(f"SELECT roleid FROM rolebutton WHERE serverid = {guild.id}") + + self.add_item(nextcord.ui.Button(label="Test", style=nextcord.ButtonStyle.gray, custom_id="rolebutton:821095192831852554")) + self.add_item(nextcord.ui.Button(label="Test 2", style=nextcord.ButtonStyle.gray, custom_id="rolebutton:1058708072064884736")) + + async def callback(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): + await interaction.response.send_message(f"user requested role {button.custom_id}", ephemeral=True) + return + +class speechbubble(commands.Cog): + + def __init__(self, bot: commands.Bot): + self.bot = bot + bot.add_view(RoleView()) + + @nextcord.slash_command( + name="roletest", + description="check if the buttons work", + ) + async def roletest(self, interaction: nextcord.Interaction, victim: nextcord.Member = nextcord.SlashOption(name="victim")): + await interaction.response.send_modal(view=RoleView(self.bot,interaction.guild)) + +def setup(bot: commands.Bot): + bot.add_cog(rolebuttons(bot)) \ No newline at end of file diff --git a/speechbubble.py b/speechbubble.py index 6c30c67..2b63b33 100644 --- a/speechbubble.py +++ b/speechbubble.py @@ -114,11 +114,8 @@ class speechbubble(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - - @commands.Cog.listener('on_ready') - async def ready(self): - self.add_view(ApplicationView()) - + bot.add_view(ApplicationView()) + @commands.Cog.listener('on_message') async def on_message(self,message): res = await self.bot.cur.execute(f"SELECT imagelink, chance FROM userinfo WHERE serverid = {message.guild.id} AND userid = {message.author.id} ORDER BY RANDOM() LIMIT 1")