[V3] Custom context class (#988)

* Create custom context class

* Documentation

* Remove old help method, replace with new

* Update from rebase
This commit is contained in:
Tobotimus
2017-10-16 12:02:51 +11:00
committed by Will
parent 36b3fbd5bc
commit 86b18c702c
14 changed files with 78 additions and 32 deletions

View File

@@ -167,7 +167,7 @@ class Admin:
async def editrole(self, ctx: commands.Context):
"""Edits roles settings"""
if ctx.invoked_subcommand is None:
await ctx.bot.send_cmd_help(ctx)
await ctx.send_help()
@editrole.command(name="colour", aliases=["color", ])
async def editrole_colour(self, ctx: commands.Context, role: discord.Role,

View File

@@ -184,7 +184,7 @@ class Alias:
async def alias(self, ctx: commands.Context):
"""Manage per-server aliases for commands"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@alias.group(name="global")
async def global_(self, ctx: commands.Context):
@@ -193,7 +193,7 @@ class Alias:
"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@alias.command(name="add")
@commands.guild_only()

View File

@@ -54,7 +54,7 @@ class Bank:
async def bankset(self, ctx: commands.Context):
"""Base command for bank settings"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@bankset.command(name="toggleglobal")
@checks.is_owner()

View File

@@ -164,7 +164,7 @@ class CustomCommands:
ctx: commands.Context):
"""Custom commands management"""
if not ctx.invoked_subcommand:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@customcom.group(name="add")
@checks.mod_or_permissions(administrator=True)
@@ -176,7 +176,7 @@ class CustomCommands:
"""
if not ctx.invoked_subcommand or isinstance(ctx.invoked_subcommand,
commands.Group):
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@cc_add.command(name='random')
@checks.mod_or_permissions(administrator=True)

View File

@@ -179,7 +179,7 @@ class Downloader:
Command group for managing Downloader repos.
"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@repo.command(name="add")
@install_agreement()
@@ -231,7 +231,7 @@ class Downloader:
Command group for managing installable Cogs.
"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@cog.command(name="install")
async def _cog_install(self, ctx, repo_name: Repo, cog_name: str):

View File

@@ -141,7 +141,7 @@ class Economy:
async def _bank(self, ctx: commands.Context):
"""Bank operations"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@_bank.command()
async def balance(self, ctx: commands.Context, user: discord.Member = None):
@@ -405,7 +405,7 @@ class Economy:
"""Changes economy module settings"""
guild = ctx.guild
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
if await bank.is_global():
slot_min = await self.config.SLOT_MIN()
slot_max = await self.config.SLOT_MAX()

View File

@@ -32,7 +32,7 @@ class Image:
Make sure to set the client ID using
[p]imgurcreds"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
@_imgur.command(name="search")
async def imgur_search(self, ctx, *, term: str):
@@ -70,7 +70,7 @@ class Image:
await ctx.send(_("Only 'new' and 'top' are a valid sort type."))
return
elif window not in ("day", "week", "month", "year", "all"):
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
return
if sort_type == "new":
@@ -120,7 +120,7 @@ class Image:
if keywords:
keywords = "+".join(keywords)
else:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
return
url = ("http://api.giphy.com/v1/gifs/search?&api_key={}&q={}"
@@ -142,7 +142,7 @@ class Image:
if keywords:
keywords = "+".join(keywords)
else:
await self.bot.send_cmd_help(ctx)
await ctx.send_help()
return
url = ("http://api.giphy.com/v1/gifs/random?&api_key={}&tag={}"