Skip to content

Commit

Permalink
Mkae discord token only necessary when run directly
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonDane committed May 16, 2023
1 parent ab15f29 commit 8132606
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions autoRSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@
# Initialize .env file
load_dotenv()

# Get discord token and channel from .env file, setting channel to None if not found
if not os.environ["DISCORD_TOKEN"]:
raise Exception("DISCORD_TOKEN not found in .env file, please add it")
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
DISCORD_CHANNEL = os.getenv("DISCORD_CHANNEL", None)
if DISCORD_CHANNEL:
DISCORD_CHANNEL = int(DISCORD_CHANNEL)

# If first arg is "docker", run in docker mode
if len(sys.argv) > 1 and sys.argv[1] == "docker":
docker_mode = True
Expand Down Expand Up @@ -195,6 +187,14 @@ async def place_order(wanted_action, wanted_amount, wanted_stock, single_broker,
await ctx.send("Unable to place order: Market is closed")

if __name__ == "__main__":
# Get discord token and channel from .env file, setting channel to None if not found
if not os.environ["DISCORD_TOKEN"]:
raise Exception("DISCORD_TOKEN not found in .env file, please add it")
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
DISCORD_CHANNEL = os.getenv("DISCORD_CHANNEL", None)
if DISCORD_CHANNEL:
DISCORD_CHANNEL = int(DISCORD_CHANNEL)

# Initialize Accounts
print("==========================================================")
print("Initializing Accounts...")
Expand Down

0 comments on commit 8132606

Please sign in to comment.