Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,20 @@
|
|
1 |
import discord
|
2 |
from discord import app_commands
|
3 |
import aiohttp
|
|
|
|
|
|
|
4 |
|
|
|
5 |
intents = discord.Intents.default()
|
6 |
intents.message_content = True
|
7 |
bot = discord.Client(intents=intents)
|
8 |
tree = app_commands.CommandTree(bot)
|
9 |
|
|
|
|
|
|
|
|
|
10 |
@tree.command(name="petsimgo", description="get info on pet on petsgo u")
|
11 |
async def petsimgo(interaction: discord.Interaction, petname: str):
|
12 |
await interaction.response.defer()
|
@@ -65,4 +73,12 @@ async def on_ready():
|
|
65 |
await tree.sync()
|
66 |
print(f"{bot.user} is now online!")
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import discord
|
2 |
from discord import app_commands
|
3 |
import aiohttp
|
4 |
+
import asyncio
|
5 |
+
from fastapi import FastAPI
|
6 |
+
import uvicorn
|
7 |
|
8 |
+
app = FastAPI()
|
9 |
intents = discord.Intents.default()
|
10 |
intents.message_content = True
|
11 |
bot = discord.Client(intents=intents)
|
12 |
tree = app_commands.CommandTree(bot)
|
13 |
|
14 |
+
@app.get("/")
|
15 |
+
async def read_root():
|
16 |
+
return {"Hello": "World"}
|
17 |
+
|
18 |
@tree.command(name="petsimgo", description="get info on pet on petsgo u")
|
19 |
async def petsimgo(interaction: discord.Interaction, petname: str):
|
20 |
await interaction.response.defer()
|
|
|
73 |
await tree.sync()
|
74 |
print(f"{bot.user} is now online!")
|
75 |
|
76 |
+
async def run_bot():
|
77 |
+
await bot.start("YOUR_BOT_TOKEN_HERE")
|
78 |
+
|
79 |
+
@app.on_event("startup")
|
80 |
+
async def startup_event():
|
81 |
+
asyncio.create_task(run_bot())
|
82 |
+
|
83 |
+
if __name__ == "__main__":
|
84 |
+
uvicorn.run("app:app", host="0.0.0.0", port=7860)
|