diff --git a/pybot-f.py b/pybot-f.py index 21990c9..8883724 100644 --- a/pybot-f.py +++ b/pybot-f.py @@ -3,6 +3,7 @@ import os import configparser import discord +import asyncio from discord.ext import commands description = '''Testing this bot stuff :)''' @@ -37,15 +38,20 @@ async def joined(ctx, member: discord.Member): """Says when a member joined.""" await ctx.send(f'{member.name} joined {discord.utils.format_dt(member.joined_at)}') -with os.scandir('./ext/') as dirs: - for entry in dirs: - if entry.name.endswith('.py'): - try: - print(entry.name) - await bot.load_extension('ext.' + entry.name) - except Exception as error: - print(f'Error loading {entry.name}: {error}') +async def scanext(): + with os.scandir('./ext/') as dirs: + for entry in dirs: + if entry.name.endswith('.py'): + try: + print(f"Loading extension: {entry.name}") + await bot.load_extension('ext.' + os.path.splitext(entry.name)[0]) + except Exception as error: + print(f'Error loading {entry.name}: {error}') -bot.load_extension('ext/test.py') -bot.run(bottoken) +async def main(): + async with bot: + await scanext() + await bot.start(bottoken) + +asyncio.run(main()) \ No newline at end of file