-
Notifications
You must be signed in to change notification settings - Fork 0
/
cogs_manager.py
32 lines (31 loc) · 1.38 KB
/
cogs_manager.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
import os
import disnake
from disnake.ext import commands
class Manager:
def loadCogs(bot):
print("Идёт загрузка расширений...")
# Check for ignored cogs.
isWhitelist = False
loadItems = []
with open(os.path.dirname(os.path.realpath(__file__)) + '\cogs_load.conf', 'r') as file:
for line in file:
if line.startswith('#') or line == '\n' or line == '\n'or line == ')':
continue
if line == "only=(":
isWhitelist = True
loadItems.append(line.strip(',').strip())
# Load cogs.
loadedExt = False
for filename in os.listdir("cogs"):
if filename.endswith(".py"):
loadedExt = False
for item in loadItems:
if loadedExt: break
if isWhitelist and filename == item:
bot.load_extension(f"cogs.{filename[:-3]}")
print(f"Расширение {filename[:-3]} было загружено.")
loadedExt = True
elif not isWhitelist and filename != item:
bot.load_extension(f"cogs.{filename[:-3]}")
print(f"Расширение {filename[:-3]} было загружено.")
loadedExt = True