Skip to content

Commit 12b8582

Browse files
committed
Add ability to specify a plugin
1 parent ef84531 commit 12b8582

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

cogs/plugins.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,32 @@ async def plugin_enabled(self, ctx):
268268

269269
@plugin.command(name='registry', aliases=['list'])
270270
@checks.has_permissions(PermissionLevel.OWNER)
271-
async def plugin_registry(self, ctx):
271+
async def plugin_registry(self, ctx, plugin_name=None):
272272
"""Shows a list of all approved plugins."""
273273

274274
embeds = []
275275

276+
277+
276278
registry = list(self.registry.items())
277279
random.shuffle(registry)
278280

281+
def find_index(name):
282+
index = 0
283+
for n, info in registry:
284+
if name == n:
285+
return index
286+
index += 1
287+
288+
if plugin_name and plugin_name in self.registry:
289+
index = find_index(plugin_name)
290+
else:
291+
return await ctx.send(embed=discord.Embed(
292+
color=discord.Color.red(),
293+
description=f'Could not find a plugin with name "{plugin_name}" within the registry.'
294+
)
295+
)
296+
279297
for name, info in registry:
280298
repo = f"https://github.com/{info['repository']}"
281299

@@ -297,11 +315,10 @@ async def plugin_registry(self, ctx):
297315
embeds.append(em)
298316

299317
paginator = PaginatorSession(ctx, *embeds)
318+
paginator.current = index
300319
await paginator.run()
301320

302321

303322

304-
305-
306323
def setup(bot):
307324
bot.add_cog(Plugins(bot))

0 commit comments

Comments
 (0)