Fixed bot being started multiple times.
This commit is contained in:
4
main.py
4
main.py
@@ -9,6 +9,7 @@ from webui import create_ui
|
|||||||
from bot_instance import bot
|
from bot_instance import bot
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
bot_started = False # prolly only need this in dev mode
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
TOKEN = os.getenv("TOKEN")
|
TOKEN = os.getenv("TOKEN")
|
||||||
if not TOKEN:
|
if not TOKEN:
|
||||||
@@ -32,7 +33,10 @@ async def start_discord_bot():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
global bot_started
|
||||||
create_ui()
|
create_ui()
|
||||||
|
if not bot_started:
|
||||||
|
bot_started = True
|
||||||
ui.timer(0, lambda: asyncio.create_task(start_discord_bot()), once=True)
|
ui.timer(0, lambda: asyncio.create_task(start_discord_bot()), once=True)
|
||||||
ui.run()
|
ui.run()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user