From e0dd4fce18c2b3fddf69ee55d79e2e465b378275 Mon Sep 17 00:00:00 2001 From: insert Date: Fri, 9 Aug 2024 17:48:13 -0400 Subject: [PATCH] Update --- speechbubble.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/speechbubble.py b/speechbubble.py index dd1361c..68117de 100644 --- a/speechbubble.py +++ b/speechbubble.py @@ -4,6 +4,7 @@ from nextcord import TextInputStyle from random import randint import aiosqlite as sqlite3 import aiohttp +import asyncio from urllib.parse import urlparse import os @@ -54,10 +55,6 @@ class ApplicationView(nextcord.ui.View): class ApplicationModal(nextcord.ui.Modal): def __init__(self,user,bot): - res = await bot.cur.execute("SELECT name FROM sqlite_master WHERE name='userinfo'") - if await res.fetchone() is None: - await bot.cur.execute("CREATE TABLE userinfo(serverid INTEGER, userid INTEGER, imagelink TEXT, chance INTEGER)") - await bot.db.commit() self.victim = user self.bot = bot super().__init__( @@ -114,9 +111,16 @@ class ApplicationModal(nextcord.ui.Modal): await interaction.send(f"<@{self.victim.id}> {interaction.user.name} proposes the following speech bubble for you:", embed=embed, view=ApplicationView(self.bot)) +async def dbcheck(db,cur): + res = await bot.cur.execute("SELECT name FROM sqlite_master WHERE name='userinfo'") + if await res.fetchone() is None: + await cur.execute("CREATE TABLE userinfo(serverid INTEGER, userid INTEGER, imagelink TEXT, chance INTEGER)") + await db.commit() + class speechbubble(commands.Cog): def __init__(self, bot: commands.Bot): + asyncio.run(dbcheck(bot.db,bot.cur)) self.bot = bot bot.add_view(ApplicationView(bot))