SorovotPelo commited on
Commit
0a6b791
verified
1 Parent(s): 305dbaa

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +16 -8
bot.py CHANGED
@@ -1,12 +1,11 @@
1
  import discord
2
- from discord.ext import tasks
3
  import uvicorn
4
  from fastapi import FastAPI
5
- import os
6
 
7
  # Configuraci贸n del bot
8
  TOKEN = 'MTI4MDY2ODIxMzYwMzk5NTc5OQ.GfTdkI.C4wjED9fbiJWV_foqTrx9RVxX7KM3_EpPxAYMs'
9
- DISCORD_USER_ID = 1124342351146520740
10
 
11
  intents = discord.Intents.default()
12
  intents.messages = True
@@ -27,9 +26,18 @@ async def on_ready():
27
  if user:
28
  await user.send("隆Este es un mensaje de prueba para verificar que el bot est谩 funcionando!")
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  if __name__ == "__main__":
31
- # Iniciar el bot
32
- client.loop.create_task(client.start(TOKEN))
33
-
34
- # Iniciar el servidor FastAPI
35
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
1
  import discord
2
+ import asyncio
3
  import uvicorn
4
  from fastapi import FastAPI
 
5
 
6
  # Configuraci贸n del bot
7
  TOKEN = 'MTI4MDY2ODIxMzYwMzk5NTc5OQ.GfTdkI.C4wjED9fbiJWV_foqTrx9RVxX7KM3_EpPxAYMs'
8
+ DISCORD_USER_ID = 1122547004468367381
9
 
10
  intents = discord.Intents.default()
11
  intents.messages = True
 
26
  if user:
27
  await user.send("隆Este es un mensaje de prueba para verificar que el bot est谩 funcionando!")
28
 
29
+ async def start_bot():
30
+ await client.start(TOKEN)
31
+
32
+ def run_server():
33
+ uvicorn.run(app, host="0.0.0.0", port=7860)
34
+
35
+ async def main():
36
+ # Iniciar el bot y el servidor en paralelo
37
+ bot_task = asyncio.create_task(start_bot())
38
+ server_task = asyncio.to_thread(run_server)
39
+
40
+ await asyncio.gather(bot_task, server_task)
41
+
42
  if __name__ == "__main__":
43
+ asyncio.run(main())