guard ext loading
This commit is contained in:
parent
a1b1787612
commit
47003d0f61
13
main.py
13
main.py
|
@ -11,13 +11,22 @@ config = build_config()
|
|||
# spawn discord bot instance
|
||||
# init token from config
|
||||
bot = Bot(command_prefix="~ak ")
|
||||
token = config['AUTH']['token']
|
||||
TOKEN = config['AUTH']['token']
|
||||
|
||||
# load extensions
|
||||
for file in os.listdir("src/ext"):
|
||||
if file.endswith(".py"):
|
||||
name = file[:-3]
|
||||
try:
|
||||
bot.load_extension(f"src.ext.{name}")
|
||||
except NoEntryPointError:
|
||||
logging.error(f"Extension {name} cannot be loaded. [No setup function]")
|
||||
except ExtensionFailed:
|
||||
logging.error(f"Extension {name} failed to load. [Execution error]")
|
||||
|
||||
logging.info("Finished loading extensions.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
bot.run(token)
|
||||
logging.info("Starting bot...")
|
||||
# use token from config
|
||||
bot.run(TOKEN)
|
Loading…
Reference in New Issue