-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathload_cogs_from_folder.py
37 lines (26 loc) · 1.01 KB
/
load_cogs_from_folder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import discord
from discord.ext import commands
import settings
logger = settings.logging.getLogger("bot")
def run():
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
logger.info(f"User: {bot.user} (ID: {bot.user.id})")
for cog_file in settings.COGS_DIR.glob("*.py"):
if cog_file.name != "__init__.py":
await bot.load_extension(f"cogs.{cog_file.name[:-3]}")
@bot.command()
async def load(ctx, cog: str):
await bot.load_extension(f"cogs.{cog.lower()}")
@bot.command()
async def unload(ctx, cog: str):
await bot.unload_extension(f"cogs.{cog.lower()}")
@bot.command()
async def reload(ctx, cog: str):
await bot.reload_extension(f"cogs.{cog.lower()}")
bot.run(settings.DISCORD_API_SECRET, root_logger=True)
if __name__ == "__main__":
run()