Skip to content

Commit 0c174e5

Browse files
authored
Update plugins.py
1 parent 252d0ae commit 0c174e5

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

cogs/plugins.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,14 @@ async def populate_registry(self):
134134
async with self.bot.session.get(url) as resp:
135135
self.registry = json.loads(await resp.text())
136136

137-
async def initial_load_plugins(self):
138-
for plugin_name in list(self.bot.config["plugins"]):
137+
def _get_forced_plugins(self) -> list[str]:
138+
env_list = os.getenv("FORCED_PLUGINS")
139+
if env_list is None:
140+
return []
141+
plugins = env_list.split(",")
142+
143+
144+
async def _init_load_plugin(plugin_name: str):
139145
try:
140146
plugin = Plugin.from_string(plugin_name, strict=True)
141147
except InvalidPluginError:
@@ -162,6 +168,18 @@ async def initial_load_plugins(self):
162168
)
163169
continue
164170

171+
172+
async def initial_load_plugins(self):
173+
self.forced_plugins = _get_forced_plugins()
174+
logger.debug("loading forced plugins")
175+
for plugin_name in self.forced_plugins
176+
_init_plugin_load(plugin_name)
177+
178+
logger.debug("loading config plugins")
179+
180+
for plugin_name in list(self.bot.config["plugins"]):
181+
_init_plugin_load(plugin_name)
182+
165183
logger.debug("Finished loading all plugins.")
166184

167185
self.bot.dispatch("plugins_ready")
@@ -429,6 +447,10 @@ async def plugins_remove(self, ctx, *, plugin_name: str):
429447
if plugin is None:
430448
return
431449

450+
if str(plugin) in self.forced_plugins:
451+
await ctx.send(embed=discord.Embed(description="This plugin cannot be removed. Contact your admin for more information.", color=self.bot.error_color))
452+
return
453+
432454
if str(plugin) not in self.bot.config["plugins"]:
433455
embed = discord.Embed(description="Plugin is not installed.", color=self.bot.error_color)
434456
return await ctx.send(embed=embed)

0 commit comments

Comments
 (0)