coollsd commited on
Commit
c0051e3
1 Parent(s): 3e2913e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -1,9 +1,9 @@
1
- # app.py or main.py
2
  import discord
3
  from discord import app_commands
4
  from fastapi import FastAPI
5
  import uvicorn
6
  import asyncio
 
7
 
8
  from shared import user_cash, user_bets, fetch_nhl_scores
9
  from petsimgo import petsimgo
@@ -17,16 +17,21 @@ from database import database
17
  from sportbet import sportbet
18
  from roulette import roulette
19
 
 
20
  app = FastAPI()
21
  intents = discord.Intents.default()
22
  intents.message_content = True
23
  bot = discord.Client(intents=intents)
24
  tree = app_commands.CommandTree(bot)
25
 
 
 
 
26
  @app.get("/")
27
  async def read_root():
28
  return {"Hello": "World"}
29
 
 
30
  tree.add_command(petsimgo)
31
  tree.add_command(petroll)
32
  tree.add_command(cash)
@@ -44,7 +49,9 @@ async def on_ready():
44
  print(f"{bot.user} is now online!")
45
 
46
  async def run_bot():
47
- await bot.start("MTI5MjkxMDYzMjg3MzQ5MjU4Mw.GbVmvy.8kEhPZyNLrACzBWYEorT7UqNRME7gp6Lvz6lg8")
 
 
48
 
49
  @app.on_event("startup")
50
  async def startup_event():
 
 
1
  import discord
2
  from discord import app_commands
3
  from fastapi import FastAPI
4
  import uvicorn
5
  import asyncio
6
+ import os
7
 
8
  from shared import user_cash, user_bets, fetch_nhl_scores
9
  from petsimgo import petsimgo
 
17
  from sportbet import sportbet
18
  from roulette import roulette
19
 
20
+ # Initialize FastAPI and Discord client
21
  app = FastAPI()
22
  intents = discord.Intents.default()
23
  intents.message_content = True
24
  bot = discord.Client(intents=intents)
25
  tree = app_commands.CommandTree(bot)
26
 
27
+ # Environment variable for token
28
+ TOKEN = os.getenv("token")
29
+
30
  @app.get("/")
31
  async def read_root():
32
  return {"Hello": "World"}
33
 
34
+ # Add commands to the command tree
35
  tree.add_command(petsimgo)
36
  tree.add_command(petroll)
37
  tree.add_command(cash)
 
49
  print(f"{bot.user} is now online!")
50
 
51
  async def run_bot():
52
+ if not TOKEN:
53
+ raise ValueError("No Discord token found. Please set the DISCORD_TOKEN environment variable.")
54
+ await bot.start(TOKEN)
55
 
56
  @app.on_event("startup")
57
  async def startup_event():