disnog / netranger-bot

The custom bot for the Networking Discord server
https://networking-discord.github.io
3 stars 5 forks source link

Program should exit gracefully if token is not set. #39

Closed FlyingScotsman closed 4 years ago

FlyingScotsman commented 4 years ago

If token is not set and therefore detected as None, it should sys.exit, otherwise an unhandled exception is generated later.

Warning: Environment variable TOKEN is not defined. Defaulting to None.
Warning: Environment variable GUILD_NAME is not defined. Defaulting to Networking-Dev.
Warning: Environment variable WELCOMECHANNEL_NAME is not defined. Defaulting to test-welcome.
Warning: Environment variable EGGSROLE_NAME is not defined. Defaulting to !eggs.
Warning: Environment variable MEMBERROLE_NAME is not defined. Defaulting to Members.
Warning: Environment variable MEMBERCHANNEL_NAME is not defined. Defaulting to test-general.
Warning: Environment variable LOGCHANNEL_NAME is not defined. Defaulting to test-cnc.
Warning: Environment variable MIRRORCHANNEL_NAME is not defined. Defaulting to mirror.
Warning: Environment variable BOT_DESCRIPTION is not defined. Defaulting to Network Ranger.
Warning: Environment variable COMMAND_PREFIX is not defined. Defaulting to $.
Warning: Environment variable SMTP_USERNAME is not defined. Defaulting to None.
Warning: Environment variable SMTP_PASSWORD is not defined. Defaulting to None.
Warning: Environment variable SMTP_SERVER is not defined. Defaulting to None.
Warning: Environment variable SMTP_PORT is not defined. Defaulting to None.
Warning: Environment variable SMTP_FROMEMAIL is not defined. Defaulting to None.
Warning: Environment variable SECRETKEY is not defined. Defaulting to None.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "network_ranger/__main__.py", line 526, in <module>
    bot.run(conf.get("token"))
  File "/usr/local/lib/python3.7/site-packages/discord/client.py", line 640, in run
    return future.result()
  File "/usr/local/lib/python3.7/site-packages/discord/client.py", line 621, in runner
    await self.start(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/discord/client.py", line 584, in start
    await self.login(*args, bot=bot)
  File "/usr/local/lib/python3.7/site-packages/discord/client.py", line 442, in login
    await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'