Skip to content

Commit

Permalink
Update TK4.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tooruche520 committed Oct 13, 2022
1 parent e644e19 commit ba0eebb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions TK4.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,20 @@

@bot.event
async def on_ready():
print("Bot in ready")
log.info("Bot in ready")

@bot.command()
async def reload(ctx, extension):
log.info(f"reloading {extension}")
await bot.reload_extension(f"cogs.{extension}")
log.info(f"Completed reloading {extension}")
await ctx.send(f"reloaded {extension}")

@bot.command()
async def reload_all(ctx):
print(f"reloading all extensions...")
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
await bot.reload_extension(f"cogs.{filename[:-3]}")
log.info(f"Completed reloading all extensions.")
await ctx.send(f"reloaded all")
# await bot.reload_extension(f"cogs.{extension}")

Expand All @@ -60,15 +59,21 @@ async def reload_all(ctx):


async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
await bot.load_extension(f"cogs.{filename[:-3]}")
try:
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
await bot.load_extension(f"cogs.{filename[:-3]}")
except Exception as e:
log.error(e)

async def main():
async with bot:
await load_extensions()
await bot.start(token)

asyncio.run(main())
try:
asyncio.run(main())
except Exception as e:
log.error(f'Bot ended: {e.message}')


bot.run(token)

0 comments on commit ba0eebb

Please sign in to comment.