diff --git a/docs/cog_guides/downloader.rst b/docs/cog_guides/downloader.rst index cd8169e41..95b8cddad 100644 --- a/docs/cog_guides/downloader.rst +++ b/docs/cog_guides/downloader.rst @@ -83,7 +83,7 @@ cog info .. code-block:: none - [p]cog info + [p]cog info **Description** @@ -94,8 +94,8 @@ Example: **Arguments** -- ```` The repo to get cog info from. -- ```` The cog to get info on. +- ```` The repo to get cog info from. +- ```` The cog to get info on. .. _downloader-command-cog-install: @@ -107,7 +107,7 @@ cog install .. code-block:: none - [p]cog install + [p]cog install **Description** @@ -119,8 +119,8 @@ Examples: **Arguments** -- ```` The name of the repo to install cogs from. -- ```` The cog or cogs to install. +- ```` The name of the repo to install cogs from. +- ```` The cog or cogs to install. .. _downloader-command-cog-installversion: @@ -132,7 +132,7 @@ cog installversion .. code-block:: none - [p]cog installversion + [p]cog installversion **Description** @@ -148,9 +148,9 @@ Example: **Arguments** -- ```` The name of the repo to install cogs from. +- ```` The name of the repo to install cogs from. - ```` The revision to install from. -- ```` The cog or cogs to install. +- ```` The cog or cogs to install. .. _downloader-command-cog-list: @@ -162,7 +162,7 @@ cog list .. code-block:: none - [p]cog list + [p]cog list **Description** @@ -173,7 +173,7 @@ Example: **Arguments** -- ```` The repo to list cogs from. +- ```` The repo to list cogs from. .. _downloader-command-cog-listpinned: @@ -201,7 +201,7 @@ cog pin .. code-block:: none - [p]cog pin + [p]cog pin **Description** @@ -213,7 +213,7 @@ Examples: **Arguments** -- ```` The cog or cogs to pin. Must already be installed. +- ```` The cog or cogs to pin. Must already be installed. .. _downloader-command-cog-uninstall: @@ -225,7 +225,7 @@ cog uninstall .. code-block:: none - [p]cog uninstall + [p]cog uninstall **Description** @@ -240,7 +240,7 @@ Examples: **Arguments** -- ```` The cog or cogs to uninstall. +- ```` The cog or cogs to uninstall. .. _downloader-command-cog-unpin: @@ -252,7 +252,7 @@ cog unpin .. code-block:: none - [p]cog unpin + [p]cog unpin **Description** @@ -264,7 +264,7 @@ Examples: **Arguments** -- ```` The cog or cogs to unpin. Must already be installed and pinned. +- ```` The cog or cogs to unpin. Must already be installed and pinned. .. _downloader-command-cog-update: @@ -300,7 +300,7 @@ cog updateallfromrepos .. code-block:: none - [p]cog updateallfromrepos + [p]cog updateallfromrepos **Description** @@ -312,7 +312,7 @@ Examples: **Arguments** -- ```` The repo or repos to update all cogs from. +- ```` The repo or repos to update all cogs from. .. _downloader-command-cog-updatetoversion: @@ -324,7 +324,7 @@ cog updatetoversion .. code-block:: none - [p]cog updatetoversion [cogs] + [p]cog updatetoversion [cogs...] **Description** @@ -341,9 +341,9 @@ Example: **Arguments** -- ```` The repo or repos to update all cogs from. +- ```` The repo or repos to update all cogs from. - ```` The revision to update to. -- ``[cogs]`` The cog or cogs to update. +- ``[cogs...]`` The cog or cogs to update. .. _downloader-command-findcog: @@ -382,7 +382,7 @@ pipinstall .. code-block:: none - [p]pipinstall [deps...] + [p]pipinstall **Description** @@ -396,7 +396,7 @@ Improper usage of this command can break your bot, be careful. **Arguments** -- ``[deps...]`` The package or packages you wish to install. +- ```` The package or packages you wish to install. .. _downloader-command-repo: @@ -455,7 +455,7 @@ repo delete .. code-block:: none - [p]repo delete + [p]repo delete .. tip:: Aliases: ``repo remove``, ``repo del`` @@ -468,7 +468,7 @@ Example: **Arguments** -- ```` The name of an already added repo +- ```` The name of an already added repo .. _downloader-command-repo-info: @@ -480,7 +480,7 @@ repo info .. code-block:: none - [p]repo info + [p]repo info **Description** @@ -491,7 +491,7 @@ Example: **Arguments** -- ```` The name of the repo to show info about. +- ```` The name of the repo to show info about. .. _downloader-command-repo-list: diff --git a/docs/cog_guides/streams.rst b/docs/cog_guides/streams.rst index e221489ff..ed8afdee3 100644 --- a/docs/cog_guides/streams.rst +++ b/docs/cog_guides/streams.rst @@ -191,7 +191,7 @@ streamset message mention .. code-block:: none - [p]streamset message mention [message] + [p]streamset message mention **Description** @@ -205,7 +205,7 @@ For example: ``[p]streamset message mention {mention}, {stream} is live!`` **Arguments** -* ``[message]``: Your alert message +* ````: Your alert message .. _streams-command-streamset-message-nomention: @@ -217,7 +217,7 @@ streamset message nomention .. code-block:: none - [p]streamset message nomention [message] + [p]streamset message nomention **Description** @@ -229,7 +229,7 @@ For example: ``[p]streamset message nomention {stream} is live!`` **Arguments** -* ``[message]``: Your alert message +* ````: Your alert message .. _streams-command-streamset-message-clear: diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index eb01aa9cf..39235674e 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -478,7 +478,7 @@ class Downloader(commands.Cog): for page in pagify(content): await target.send(page) - @commands.command() + @commands.command(require_var_positional=True) @checks.is_owner() async def pipinstall(self, ctx: commands.Context, *deps: str) -> None: """ @@ -492,11 +492,8 @@ class Downloader(commands.Cog): **Arguments** - - `[deps...]` The package or packages you wish to install. + - `` The package or packages you wish to install. """ - if not deps: - await ctx.send_help() - return repo = Repo("", "", "", "", Path.cwd()) async with ctx.typing(): success = await repo.install_raw_requirements(deps, self.LIB_PATH) @@ -582,7 +579,7 @@ class Downloader(commands.Cog): if repo.install_msg: await ctx.send(repo.install_msg.replace("[p]", ctx.clean_prefix)) - @repo.command(name="delete", aliases=["remove", "del"], usage="") + @repo.command(name="delete", aliases=["remove", "del"]) async def _repo_del(self, ctx: commands.Context, repo: Repo) -> None: """ Remove a repo and its files. @@ -592,7 +589,7 @@ class Downloader(commands.Cog): **Arguments** - - `` The name of an already added repo + - `` The name of an already added repo """ await self._repo_manager.delete_repo(repo.name) @@ -612,7 +609,7 @@ class Downloader(commands.Cog): for page in pagify(joined, ["\n"], shorten_by=16): await ctx.send(box(page.lstrip(" "), lang="diff")) - @repo.command(name="info", usage="") + @repo.command(name="info") async def _repo_info(self, ctx: commands.Context, repo: Repo) -> None: """Show information about a repo. @@ -621,7 +618,7 @@ class Downloader(commands.Cog): **Arguments** - - `` The name of the repo to show info about. + - `` The name of the repo to show info about. """ made_by = ", ".join(repo.author) or _("Missing from info.json") @@ -737,7 +734,7 @@ class Downloader(commands.Cog): ) ) - @cog.command(name="install", usage=" ") + @cog.command(name="install", usage=" ", require_var_positional=True) async def _cog_install(self, ctx: commands.Context, repo: Repo, *cog_names: str) -> None: """Install a cog from the given repo. @@ -747,14 +744,16 @@ class Downloader(commands.Cog): **Arguments** - - `` The name of the repo to install cogs from. - - `` The cog or cogs to install. + - `` The name of the repo to install cogs from. + - `` The cog or cogs to install. """ await self._cog_installrev(ctx, repo, None, cog_names) - @cog.command(name="installversion", usage=" ") + @cog.command( + name="installversion", usage=" ", require_var_positional=True + ) async def _cog_installversion( - self, ctx: commands.Context, repo: Repo, rev: str, *cog_names: str + self, ctx: commands.Context, repo: Repo, revision: str, *cog_names: str ) -> None: """Install a cog from the specified revision of given repo. @@ -768,18 +767,15 @@ class Downloader(commands.Cog): **Arguments** - - `` The name of the repo to install cogs from. + - `` The name of the repo to install cogs from. - `` The revision to install from. - - `` The cog or cogs to install. + - `` The cog or cogs to install. """ - await self._cog_installrev(ctx, repo, rev, cog_names) + await self._cog_installrev(ctx, repo, revision, cog_names) async def _cog_installrev( self, ctx: commands.Context, repo: Repo, rev: Optional[str], cog_names: Iterable[str] ) -> None: - if not cog_names: - await ctx.send_help() - return commit = None async with ctx.typing(): if rev is not None: @@ -859,8 +855,8 @@ class Downloader(commands.Cog): "\nYou can load them using {command_1}." " To see end user data statements, you can use {command_2}." ).format( - command_1=inline(f"{ctx.clean_prefix}load "), - command_2=inline(f"{ctx.clean_prefix}cog info "), + command_1=inline(f"{ctx.clean_prefix}load "), + command_2=inline(f"{ctx.clean_prefix}cog info "), ) + message ) @@ -870,7 +866,7 @@ class Downloader(commands.Cog): if cog.install_msg: await ctx.send(cog.install_msg.replace("[p]", ctx.clean_prefix)) - @cog.command(name="uninstall", usage="") + @cog.command(name="uninstall", require_var_positional=True) async def _cog_uninstall(self, ctx: commands.Context, *cogs: InstalledCog) -> None: """Uninstall cogs. @@ -883,11 +879,8 @@ class Downloader(commands.Cog): **Arguments** - - `` The cog or cogs to uninstall. + - `` The cog or cogs to uninstall. """ - if not cogs: - await ctx.send_help() - return async with ctx.typing(): uninstalled_cogs = [] failed_cogs = [] @@ -923,7 +916,7 @@ class Downloader(commands.Cog): ) await self.send_pagified(ctx, message) - @cog.command(name="pin", usage="") + @cog.command(name="pin", require_var_positional=True) async def _cog_pin(self, ctx: commands.Context, *cogs: InstalledCog) -> None: """Pin cogs - this will lock cogs on their current version. @@ -933,11 +926,8 @@ class Downloader(commands.Cog): **Arguments** - - `` The cog or cogs to pin. Must already be installed. + - `` The cog or cogs to pin. Must already be installed. """ - if not cogs: - await ctx.send_help() - return already_pinned = [] pinned = [] for cog in set(cogs): @@ -955,7 +945,7 @@ class Downloader(commands.Cog): message += _("\nThese cogs were already pinned: ") + humanize_list(already_pinned) await self.send_pagified(ctx, message) - @cog.command(name="unpin", usage="") + @cog.command(name="unpin", require_var_positional=True) async def _cog_unpin(self, ctx: commands.Context, *cogs: InstalledCog) -> None: """Unpin cogs - this will remove the update lock from those cogs. @@ -965,10 +955,7 @@ class Downloader(commands.Cog): **Arguments** - - `` The cog or cogs to unpin. Must already be installed and pinned.""" - if not cogs: - await ctx.send_help() - return + - `` The cog or cogs to unpin. Must already be installed and pinned.""" not_pinned = [] unpinned = [] for cog in set(cogs): @@ -1062,7 +1049,7 @@ class Downloader(commands.Cog): """ await self._cog_update_logic(ctx, cogs=cogs) - @cog.command(name="updateallfromrepos", usage="") + @cog.command(name="updateallfromrepos", require_var_positional=True) async def _cog_updateallfromrepos(self, ctx: commands.Context, *repos: Repo) -> None: """Update all cogs from repos of your choosing. @@ -1072,16 +1059,13 @@ class Downloader(commands.Cog): **Arguments** - - `` The repo or repos to update all cogs from. + - `` The repo or repos to update all cogs from. """ - if not repos: - await ctx.send_help() - return await self._cog_update_logic(ctx, repos=repos) - @cog.command(name="updatetoversion", usage=" [cogs]") + @cog.command(name="updatetoversion") async def _cog_updatetoversion( - self, ctx: commands.Context, repo: Repo, rev: str, *cogs: InstalledCog + self, ctx: commands.Context, repo: Repo, revision: str, *cogs: InstalledCog ) -> None: """Update all cogs, or ones of your choosing to chosen revision of one repo. @@ -1096,11 +1080,11 @@ class Downloader(commands.Cog): **Arguments** - - `` The repo or repos to update all cogs from. + - `` The repo or repos to update all cogs from. - `` The revision to update to. - - `[cogs]` The cog or cogs to update. + - `[cogs...]` The cog or cogs to update. """ - await self._cog_update_logic(ctx, repo=repo, rev=rev, cogs=cogs) + await self._cog_update_logic(ctx, repo=repo, rev=revision, cogs=cogs) async def _cog_update_logic( self, @@ -1219,7 +1203,7 @@ class Downloader(commands.Cog): if updates_available and updated_cognames: await self._ask_for_cog_reload(ctx, updated_cognames) - @cog.command(name="list", usage="") + @cog.command(name="list") async def _cog_list(self, ctx: commands.Context, repo: Repo) -> None: """List all available cogs from a single repo. @@ -1228,7 +1212,7 @@ class Downloader(commands.Cog): **Arguments** - - `` The repo to list cogs from. + - `` The repo to list cogs from. """ installed = await self.installed_cogs() installed_str = "" @@ -1251,7 +1235,7 @@ class Downloader(commands.Cog): for page in pagify(cogs, ["\n"], shorten_by=16): await ctx.send(box(page.lstrip(" "), lang="diff")) - @cog.command(name="info", usage=" ") + @cog.command(name="info", usage=" ") async def _cog_info(self, ctx: commands.Context, repo: Repo, cog_name: str) -> None: """List information about a single cog. @@ -1260,8 +1244,8 @@ class Downloader(commands.Cog): **Arguments** - - `` The repo to get cog info from. - - `` The cog to get info on. + - `` The repo to get cog info from. + - `` The cog to get info on. """ cog = discord.utils.get(repo.available_cogs, name=cog_name) if cog is None: @@ -1490,7 +1474,7 @@ class Downloader(commands.Cog): _("\nEnd user data statements of these cogs have changed: ") + humanize_list(tuple(map(inline, cogs_with_changed_eud_statement))) + _("\nYou can use {command} to see the updated statements.\n").format( - command=inline(f"{ctx.clean_prefix}cog info ") + command=inline(f"{ctx.clean_prefix}cog info ") ) ) if failed_cogs: diff --git a/redbot/cogs/image/image.py b/redbot/cogs/image/image.py index 87aa23d49..a90947c0d 100644 --- a/redbot/cogs/image/image.py +++ b/redbot/cogs/image/image.py @@ -176,14 +176,8 @@ class Image(commands.Cog): @commands.guild_only() @commands.command() - async def gif(self, ctx, *keywords): + async def gif(self, ctx, *, keywords): """Retrieve the first search result from Giphy.""" - if keywords: - keywords = "+".join(keywords) - else: - await ctx.send_help() - return - giphy_api_key = (await ctx.bot.get_shared_api_tokens("GIPHY")).get("api_key") if not giphy_api_key: await ctx.send( @@ -193,11 +187,8 @@ class Image(commands.Cog): ) return - url = "http://api.giphy.com/v1/gifs/search?&api_key={}&q={}".format( - giphy_api_key, keywords - ) - - async with self.session.get(url) as r: + url = "http://api.giphy.com/v1/gifs/search" + async with self.session.get(url, params={"api_key": giphy_api_key, "q": keywords}) as r: result = await r.json() if r.status == 200: if result["data"]: @@ -209,14 +200,8 @@ class Image(commands.Cog): @commands.guild_only() @commands.command() - async def gifr(self, ctx, *keywords): + async def gifr(self, ctx, *, keywords): """Retrieve a random GIF from a Giphy search.""" - if keywords: - keywords = "+".join(keywords) - else: - await ctx.send_help() - return - giphy_api_key = (await ctx.bot.get_shared_api_tokens("GIPHY")).get("api_key") if not giphy_api_key: await ctx.send( @@ -226,11 +211,8 @@ class Image(commands.Cog): ) return - url = "http://api.giphy.com/v1/gifs/random?&api_key={}&tag={}".format( - giphy_api_key, keywords - ) - - async with self.session.get(url) as r: + url = "http://api.giphy.com/v1/gifs/random" + async with self.session.get(url, params={"api_key": giphy_api_key, "tag": keywords}) as r: result = await r.json() if r.status == 200: if result["data"]: diff --git a/redbot/cogs/mod/kickban.py b/redbot/cogs/mod/kickban.py index e87005ff6..64550a448 100644 --- a/redbot/cogs/mod/kickban.py +++ b/redbot/cogs/mod/kickban.py @@ -362,7 +362,7 @@ class KickBanMixin(MixinMeta): await ctx.send(message) - @commands.command(aliases=["hackban"]) + @commands.command(aliases=["hackban"], usage=" [days] [reason]") @commands.guild_only() @commands.bot_has_permissions(ban_members=True) @checks.admin_or_permissions(ban_members=True) diff --git a/redbot/cogs/permissions/permissions.py b/redbot/cogs/permissions/permissions.py index f19636ed8..fcc24bc92 100644 --- a/redbot/cogs/permissions/permissions.py +++ b/redbot/cogs/permissions/permissions.py @@ -374,9 +374,7 @@ class Permissions(commands.Cog): await self._permissions_acl_set(ctx, guild_id=ctx.guild.id, update=True) @checks.is_owner() - @permissions.command( - name="addglobalrule", usage=" ..." - ) + @permissions.command(name="addglobalrule", require_var_positional=True) async def permissions_addglobalrule( self, ctx: commands.Context, @@ -391,11 +389,8 @@ class Permissions(commands.Cog): `` is the cog or command to add the rule to. This is case sensitive. - `` is one or more users, channels or roles the rule is for. + `` is one or more users, channels or roles the rule is for. """ - if not who_or_what: - await ctx.send_help() - return for w in who_or_what: await self._add_rule( rule=cast(bool, allow_or_deny), @@ -408,9 +403,7 @@ class Permissions(commands.Cog): @commands.guild_only() @checks.guildowner_or_permissions(administrator=True) @permissions.command( - name="addserverrule", - usage=" ...", - aliases=["addguildrule"], + name="addserverrule", aliases=["addguildrule"], require_var_positional=True ) async def permissions_addguildrule( self, @@ -426,11 +419,8 @@ class Permissions(commands.Cog): `` is the cog or command to add the rule to. This is case sensitive. - `` is one or more users, channels or roles the rule is for. + `` is one or more users, channels or roles the rule is for. """ - if not who_or_what: - await ctx.send_help() - return for w in who_or_what: await self._add_rule( rule=cast(bool, allow_or_deny), @@ -441,7 +431,7 @@ class Permissions(commands.Cog): await ctx.send(_("Rule added.")) @checks.is_owner() - @permissions.command(name="removeglobalrule", usage=" ...") + @permissions.command(name="removeglobalrule", require_var_positional=True) async def permissions_removeglobalrule( self, ctx: commands.Context, @@ -453,11 +443,8 @@ class Permissions(commands.Cog): `` is the cog or command to remove the rule from. This is case sensitive. - `` is one or more users, channels or roles the rule is for. + `` is one or more users, channels or roles the rule is for. """ - if not who_or_what: - await ctx.send_help() - return for w in who_or_what: await self._remove_rule(cog_or_cmd=cog_or_command, model_id=w.id, guild_id=GLOBAL) await ctx.send(_("Rule removed.")) @@ -465,9 +452,7 @@ class Permissions(commands.Cog): @commands.guild_only() @checks.guildowner_or_permissions(administrator=True) @permissions.command( - name="removeserverrule", - usage=" ...", - aliases=["removeguildrule"], + name="removeserverrule", aliases=["removeguildrule"], require_var_positional=True ) async def permissions_removeguildrule( self, @@ -480,11 +465,8 @@ class Permissions(commands.Cog): `` is the cog or command to remove the rule from. This is case sensitive. - `` is one or more users, channels or roles the rule is for. + `` is one or more users, channels or roles the rule is for. """ - if not who_or_what: - await ctx.send_help() - return for w in who_or_what: await self._remove_rule( cog_or_cmd=cog_or_command, model_id=w.id, guild_id=ctx.guild.id diff --git a/redbot/cogs/streams/streams.py b/redbot/cogs/streams/streams.py index 339a6523b..ac81d9327 100644 --- a/redbot/cogs/streams/streams.py +++ b/redbot/cogs/streams/streams.py @@ -299,12 +299,9 @@ class Streams(commands.Cog): pass @streamalert.group(name="twitch", invoke_without_command=True) - async def _twitch(self, ctx: commands.Context, channel_name: str = None): + async def _twitch(self, ctx: commands.Context, channel_name: str): """Manage Twitch stream notifications.""" - if channel_name is not None: - await ctx.invoke(self.twitch_alert_channel, channel_name) - else: - await ctx.send_help() + await ctx.invoke(self.twitch_alert_channel, channel_name) @_twitch.command(name="channel") async def twitch_alert_channel(self, ctx: commands.Context, channel_name: str): @@ -528,7 +525,7 @@ class Streams(commands.Cog): @message.command(name="mention") @commands.guild_only() - async def with_mention(self, ctx: commands.Context, *, message: str = None): + async def with_mention(self, ctx: commands.Context, *, message: str): """Set stream alert message when mentions are enabled. Use `{mention}` in the message to insert the selected mentions. @@ -536,28 +533,22 @@ class Streams(commands.Cog): For example: `[p]streamset message mention {mention}, {stream} is live!` """ - if message is not None: - guild = ctx.guild - await self.config.guild(guild).live_message_mention.set(message) - await ctx.send(_("Stream alert message set!")) - else: - await ctx.send_help() + guild = ctx.guild + await self.config.guild(guild).live_message_mention.set(message) + await ctx.send(_("Stream alert message set!")) @message.command(name="nomention") @commands.guild_only() - async def without_mention(self, ctx: commands.Context, *, message: str = None): + async def without_mention(self, ctx: commands.Context, *, message: str): """Set stream alert message when mentions are disabled. Use `{stream}` in the message to insert the channel or user name. For example: `[p]streamset message nomention {stream} is live!` """ - if message is not None: - guild = ctx.guild - await self.config.guild(guild).live_message_nomention.set(message) - await ctx.send(_("Stream alert message set!")) - else: - await ctx.send_help() + guild = ctx.guild + await self.config.guild(guild).live_message_nomention.set(message) + await ctx.send(_("Stream alert message set!")) @message.command(name="clear") @commands.guild_only() diff --git a/redbot/cogs/trivia/trivia.py b/redbot/cogs/trivia/trivia.py index 5a3036672..64b2ec22c 100644 --- a/redbot/cogs/trivia/trivia.py +++ b/redbot/cogs/trivia/trivia.py @@ -279,7 +279,7 @@ class Trivia(commands.Cog): else: await ctx.send(_("Trivia file was not found.")) - @commands.group(invoke_without_command=True) + @commands.group(invoke_without_command=True, require_var_positional=True) @commands.guild_only() async def trivia(self, ctx: commands.Context, *categories: str): """Start trivia session on the specified category. @@ -287,9 +287,6 @@ class Trivia(commands.Cog): You may list multiple categories, in which case the trivia will involve questions from all of them. """ - if not categories: - await ctx.send_help() - return categories = [c.lower() for c in categories] session = self._get_trivia_session(ctx.channel) if session is not None: diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index feefc046c..7c82cff0d 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -1282,12 +1282,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): except asyncio.TimeoutError: await ctx.send(_("Response timed out.")) - @commands.command() + @commands.command(require_var_positional=True) @checks.is_owner() async def load(self, ctx: commands.Context, *cogs: str): """Loads packages.""" - if not cogs: - return await ctx.send_help() cogs = tuple(map(lambda cog: cog.rstrip(","), cogs)) async with ctx.typing(): ( @@ -1393,12 +1391,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): page = page[2:] await ctx.send(page) - @commands.command() + @commands.command(require_var_positional=True) @checks.is_owner() async def unload(self, ctx: commands.Context, *cogs: str): """Unloads packages.""" - if not cogs: - return await ctx.send_help() cogs = tuple(map(lambda cog: cog.rstrip(","), cogs)) unloaded, failed = await self._unload(cogs) @@ -1431,12 +1427,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): for page in pagify(total_message): await ctx.send(page) - @commands.command(name="reload") + @commands.command(require_var_positional=True) @checks.is_owner() async def reload(self, ctx: commands.Context, *cogs: str): """Reloads packages.""" - if not cogs: - return await ctx.send_help() cogs = tuple(map(lambda cog: cog.rstrip(","), cogs)) async with ctx.typing(): ( @@ -1944,7 +1938,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.bot.change_presence(status=status, activity=game) await ctx.send(_("Status changed to {}.").format(status)) - @_set.command(name="streaming", aliases=["stream"]) + @_set.command(name="streaming", aliases=["stream"], usage="[( )]") @checks.bot_in_a_guild() @checks.is_owner() async def stream(self, ctx: commands.Context, streamer=None, *, stream_title=None): @@ -2026,13 +2020,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): else: await ctx.send(_("Done.")) - @_set.command(aliases=["prefixes"]) + @_set.command(aliases=["prefixes"], require_var_positional=True) @checks.is_owner() async def prefix(self, ctx: commands.Context, *prefixes: str): """Sets [botname]'s global prefix(es).""" - if not prefixes: - await ctx.send_help() - return await ctx.bot.set_prefixes(guild=None, prefixes=prefixes) await ctx.send(_("Prefix set.")) @@ -2252,7 +2243,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): for page in pagify(joined, ["\n"], shorten_by=16): await ctx.send(box(page.lstrip(" "), lang="diff")) - @api.command(name="remove") + @api.command(name="remove", require_var_positional=True) async def api_remove(self, ctx: commands.Context, *services: str): """Remove the given services with all their keys and tokens.""" bot_services = (await ctx.bot.get_shared_api_tokens()).keys() @@ -2756,15 +2747,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): """ pass - @allowlist.command(name="add", usage="...") + @allowlist.command(name="add", require_var_positional=True) async def allowlist_add(self, ctx: commands.Context, *users: Union[discord.Member, int]): """ Adds a user to the allowlist. """ - if not users: - await ctx.send_help() - return - uids = {getattr(user, "id", user) for user in users} await self.bot._whiteblacklist_cache.add_to_whitelist(None, uids) @@ -2788,15 +2775,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): for page in pagify(msg): await ctx.send(box(page)) - @allowlist.command(name="remove", usage="...") + @allowlist.command(name="remove", require_var_positional=True) async def allowlist_remove(self, ctx: commands.Context, *users: Union[discord.Member, int]): """ Removes user from the allowlist. """ - if not users: - await ctx.send_help() - return - uids = {getattr(user, "id", user) for user in users} await self.bot._whiteblacklist_cache.remove_from_whitelist(None, uids) @@ -2818,15 +2801,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): """ pass - @blocklist.command(name="add", usage="...") + @blocklist.command(name="add", require_var_positional=True) async def blocklist_add(self, ctx: commands.Context, *users: Union[discord.Member, int]): """ Adds a user to the blocklist. """ - if not users: - await ctx.send_help() - return - for user in users: if isinstance(user, int): user_obj = discord.Object(id=user) @@ -2859,15 +2838,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): for page in pagify(msg): await ctx.send(box(page)) - @blocklist.command(name="remove", usage="...") + @blocklist.command(name="remove", require_var_positional=True) async def blocklist_remove(self, ctx: commands.Context, *users: Union[discord.Member, int]): """ Removes user from the blocklist. """ - if not users: - await ctx.send_help() - return - uids = {getattr(user, "id", user) for user in users} await self.bot._whiteblacklist_cache.remove_from_blacklist(None, uids) @@ -2890,17 +2865,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): """ pass - @localallowlist.command(name="add", usage="...") + @localallowlist.command(name="add", require_var_positional=True) async def localallowlist_add( self, ctx: commands.Context, *users_or_roles: Union[discord.Member, discord.Role, int] ): """ Adds a user or role to the server allowlist. """ - if not users_or_roles: - await ctx.send_help() - return - names = [getattr(u_or_r, "name", u_or_r) for u_or_r in users_or_roles] uids = {getattr(u_or_r, "id", u_or_r) for u_or_r in users_or_roles} if not (ctx.guild.owner == ctx.author or await self.bot.is_owner(ctx.author)): @@ -2937,17 +2908,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): for page in pagify(msg): await ctx.send(box(page)) - @localallowlist.command(name="remove", usage="...") + @localallowlist.command(name="remove", require_var_positional=True) async def localallowlist_remove( self, ctx: commands.Context, *users_or_roles: Union[discord.Member, discord.Role, int] ): """ Removes user or role from the allowlist. """ - if not users_or_roles: - await ctx.send_help() - return - names = [getattr(u_or_r, "name", u_or_r) for u_or_r in users_or_roles] uids = {getattr(u_or_r, "id", u_or_r) for u_or_r in users_or_roles} if not (ctx.guild.owner == ctx.author or await self.bot.is_owner(ctx.author)): @@ -2984,17 +2951,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): """ pass - @localblocklist.command(name="add", usage="...") + @localblocklist.command(name="add", require_var_positional=True) async def localblocklist_add( self, ctx: commands.Context, *users_or_roles: Union[discord.Member, discord.Role, int] ): """ Adds a user or role to the blocklist. """ - if not users_or_roles: - await ctx.send_help() - return - for user_or_role in users_or_roles: uid = discord.Object(id=getattr(user_or_role, "id", user_or_role)) if uid.id == ctx.author.id: @@ -3032,17 +2995,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): for page in pagify(msg): await ctx.send(box(page)) - @localblocklist.command(name="remove", usage="...") + @localblocklist.command(name="remove", require_var_positional=True) async def localblocklist_remove( self, ctx: commands.Context, *users_or_roles: Union[discord.Member, discord.Role, int] ): """ Removes user or role from blocklist. """ - if not users_or_roles: - await ctx.send_help() - return - names = [getattr(u_or_r, "name", u_or_r) for u_or_r in users_or_roles] uids = {getattr(u_or_r, "id", u_or_r) for u_or_r in users_or_roles} await self.bot._whiteblacklist_cache.remove_from_blacklist(ctx.guild, uids)