From 406556e8cf18f542c2278c5e106c005990a444a9 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 24 Sep 2021 22:03:03 +0200 Subject: [PATCH] Add if __name__ == "__main__" --- src/bot.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bot.py b/src/bot.py index 3108022..2959859 100644 --- a/src/bot.py +++ b/src/bot.py @@ -82,19 +82,19 @@ class Music(commands.Cog): ctx.voice_client.stop() -bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), description='Relatively simple music bot example') +if __name__ == "__main__": + bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), description='Relatively simple music bot example') + @bot.event + async def on_ready(): + print(f"Logged in as {bot.user} ({bot.user.id})") + print('------') -@bot.event -async def on_ready(): - print(f"Logged in as {bot.user} ({bot.user.id})") - print('------') + bot.add_cog(Music(bot)) -bot.add_cog(Music(bot)) + token = os.environ.get("BOT_TOKEN", None) + if not token: + print("No token fouund in BOT_TOKEN") + sys.exit(1) -token = os.environ.get("BOT_TOKEN", None) -if not token: - print("No token fouund in BOT_TOKEN") - sys.exit(1) - -bot.run(token) + bot.run(token)