-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathload_plugins.py
More file actions
33 lines (29 loc) · 1.16 KB
/
load_plugins.py
File metadata and controls
33 lines (29 loc) · 1.16 KB
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
# [loads plugins if any]
from importlib import import_module
from os import listdir
import time
from libs.extras import print
class LoadPlugin:
def __init__(self, bot):
self.bot = bot
def load_plugins(self):
load_time = 0
_loaded_plugins: list[dict] = []
for file in listdir("./plugins"):
if file.endswith("_plugin.py"):
try:
plugin_load_start = time.time() * 1000
class_plug = import_module(
f'plugins.{file.replace(".py", "")}')
data = class_plug.setup(self.bot)
self.bot.add_cog(data.get('Object'))
load_time += round(abs(plugin_load_start -
time.time() * 1000))
_loaded_plugins.append(data)
print(f"Plugin \"{data.get('name')}\" Loaded!")
except ImportError:
print(f"Plugin Loading Failed!")
finally:
pass
print(f"Loaded All Plugins In {load_time}ms")
return {"LoadedPlugins": _loaded_plugins, "LoadTime": load_time}