mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 15:19:12 -06:00
refactor: streamlining of main function
Update utilizing walrus operators, only importing the sub-namespace we need from os & sys.
This commit is contained in:
parent
074666786f
commit
a35755592c
@ -1,16 +1,16 @@
|
||||
import os
|
||||
import discord
|
||||
from os import environ
|
||||
from sys import stderr
|
||||
|
||||
|
||||
# main runtime function
|
||||
def main():
|
||||
try:
|
||||
disToken = os.environ['DISCORD_TOKEN'] # grabs the discord token from the environment variable, if not there, exit
|
||||
except:
|
||||
print("ERROR: unable to find discord token in environment variables!")
|
||||
if disToken := environ.get('DISCORD_TOKEN'):
|
||||
print(f"Received discord token: {disToken}")
|
||||
# Call into main action here, basically launch the bot via import to a lower module
|
||||
else:
|
||||
print("Unable to access DISCORD_TOKEN in environment!", file=stderr)
|
||||
exit(1)
|
||||
|
||||
print("hello world")
|
||||
|
||||
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user