Skip to content

Commit 0c43754

Browse files
committed
Ability to update all plugins
1 parent af4a47b commit 0c43754

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
2626
- Updating one plugin will not update all other plugins (plugins are no longer separated by repos, but the plugin name itself).
2727
- Help command is in alphabetical order grouped by permissions.
2828
- Notes are no longer always blurple, its set to `MAIN_COLOR` now.
29+
- Added `?plugins update` for updating all installed plugins.
2930

3031
### Internal
3132

cogs/plugins.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,8 @@ async def plugins_remove(self, ctx, *, plugin_name: str):
413413
)
414414
await ctx.send(embed=embed)
415415

416-
@plugins.command(name="update")
417-
@checks.has_permissions(PermissionLevel.OWNER)
418-
async def plugins_update(self, ctx, *, plugin_name: str):
419-
"""
420-
Update a plugin for the bot.
421-
422-
`plugin_name` can be the name of the plugin found in `{prefix}plugin registry`, or a direct reference
423-
to a GitHub hosted plugin (in the format `user/repo/name[@branch]`).
424-
"""
425-
416+
async def update_plugin(self, ctx, plugin_name):
417+
logger.debug("Updating %s.", plugin_name)
426418
plugin = await self.parse_user_input(ctx, plugin_name, check_version=True)
427419
if plugin is None:
428420
return
@@ -441,13 +433,31 @@ async def plugins_update(self, ctx, *, plugin_name: str):
441433
except commands.ExtensionError:
442434
logger.warning("Plugin unload fail.", exc_info=True)
443435
await self.load_plugin(plugin)
444-
436+
logger.debug("Updated %s.", plugin_name)
445437
embed = discord.Embed(
446438
description=f"Successfully updated {plugin.name}.",
447439
color=self.bot.main_color,
448440
)
449441
return await ctx.send(embed=embed)
450442

443+
@plugins.command(name="update")
444+
@checks.has_permissions(PermissionLevel.OWNER)
445+
async def plugins_update(self, ctx, *, plugin_name: str = None):
446+
"""
447+
Update a plugin for the bot.
448+
449+
`plugin_name` can be the name of the plugin found in `{prefix}plugin registry`, or a direct reference
450+
to a GitHub hosted plugin (in the format `user/repo/name[@branch]`).
451+
452+
To update all plugins, do `{prefix}plugins update`.
453+
"""
454+
455+
if plugin_name is None:
456+
for plugin_name in self.bot.config["plugins"]:
457+
await self.update_plugin(ctx, plugin_name)
458+
else:
459+
await self.update_plugin(ctx, plugin_name)
460+
451461
@plugins.command(name="loaded", aliases=["enabled", "installed"])
452462
@checks.has_permissions(PermissionLevel.OWNER)
453463
async def plugins_loaded(self, ctx):

0 commit comments

Comments
 (0)