mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2025-01-02 10:59:13 -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
|
import discord
|
||||||
|
from os import environ
|
||||||
|
from sys import stderr
|
||||||
|
|
||||||
|
|
||||||
# main runtime function
|
# main runtime function
|
||||||
def main():
|
def main():
|
||||||
try:
|
if disToken := environ.get('DISCORD_TOKEN'):
|
||||||
disToken = os.environ['DISCORD_TOKEN'] # grabs the discord token from the environment variable, if not there, exit
|
print(f"Received discord token: {disToken}")
|
||||||
except:
|
# Call into main action here, basically launch the bot via import to a lower module
|
||||||
print("ERROR: unable to find discord token in environment variables!")
|
else:
|
||||||
|
print("Unable to access DISCORD_TOKEN in environment!", file=stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
print("hello world")
|
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user