insert2-cogs/rolebuttons.py

39 lines
1.4 KiB
Python
Raw Normal View History

2024-08-09 12:41:32 +00:00
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):
2024-08-09 12:59:25 +00:00
def __init__(self,bot):
2024-08-09 12:41:32 +00:00
super().__init__(timeout=None)
self.bot = bot
2024-08-09 13:12:58 +00:00
#res = await self.bot.cur.execute(f"SELECT roleid FROM rolebutton WHERE serverid = {self.bot.roleguild.id}")
2024-08-09 12:41:32 +00:00
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
2024-08-09 12:59:25 +00:00
bot.add_view(RoleView(bot))
2024-08-09 12:41:32 +00:00
@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")):
2024-08-09 12:51:22 +00:00
self.bot.roleguild = interaction.guild
2024-08-09 12:59:25 +00:00
await interaction.response.send_modal(view=RoleView(self.bot))
2024-08-09 12:41:32 +00:00
def setup(bot: commands.Bot):
bot.add_cog(rolebuttons(bot))