Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,6 @@ import requests
|
|
5 |
import asyncio
|
6 |
from threading import Thread
|
7 |
|
8 |
-
# NOTE: This example requires the "intents" extra to be installed.
|
9 |
-
# By default, discord.py does not install it.
|
10 |
-
# To install it, run the following command in your terminal:
|
11 |
-
# python -m pip install -U discord.py[intents]
|
12 |
-
|
13 |
# --- Environment Variables & Setup ---
|
14 |
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
15 |
GLIF_API_TOKEN = os.getenv("GLIF_API_TOKEN")
|
@@ -87,8 +82,6 @@ async def hello_command(interaction):
|
|
87 |
await interaction.response.send_message("Hello there!")
|
88 |
|
89 |
# --- Bot Initialization and Event Loop ---
|
90 |
-
async def start_bot():
|
91 |
-
await client.start(DISCORD_BOT_TOKEN)
|
92 |
|
93 |
async def on_ready():
|
94 |
await tree.sync()
|
@@ -96,10 +89,11 @@ async def on_ready():
|
|
96 |
|
97 |
client.event(on_ready)
|
98 |
|
99 |
-
def
|
100 |
-
|
|
|
|
|
|
|
101 |
|
102 |
if __name__ == "__main__":
|
103 |
-
|
104 |
-
bot_thread = Thread(target=run_bot)
|
105 |
-
bot_thread.start()
|
|
|
5 |
import asyncio
|
6 |
from threading import Thread
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
# --- Environment Variables & Setup ---
|
9 |
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
10 |
GLIF_API_TOKEN = os.getenv("GLIF_API_TOKEN")
|
|
|
82 |
await interaction.response.send_message("Hello there!")
|
83 |
|
84 |
# --- Bot Initialization and Event Loop ---
|
|
|
|
|
85 |
|
86 |
async def on_ready():
|
87 |
await tree.sync()
|
|
|
89 |
|
90 |
client.event(on_ready)
|
91 |
|
92 |
+
async def main():
|
93 |
+
# Start the bot
|
94 |
+
async with client:
|
95 |
+
await client.start(DISCORD_BOT_TOKEN)
|
96 |
+
print("Bot has stopped.")
|
97 |
|
98 |
if __name__ == "__main__":
|
99 |
+
asyncio.run(main())
|
|
|
|