diff options
| -rw-r--r-- | bot/cogs/source.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/bot/cogs/source.py b/bot/cogs/source.py index c628c6b29..22b75e2ee 100644 --- a/bot/cogs/source.py +++ b/bot/cogs/source.py @@ -1,9 +1,9 @@ import inspect import os -from typing import Union +from typing import Optional, Union from discord import Embed -from discord.ext.commands import BadArgument, Cog, Command, Context, Converter, HelpCommand, command +from discord.ext.commands import Cog, Command, Context, Converter, HelpCommand, command from bot.bot import Bot from bot.constants import URLs @@ -18,7 +18,7 @@ COG_CHECK_PASS = "You can use commands from this Cog." class SourceConverter(Converter): """Convert argument to help command, command or Cog.""" - async def convert(self, ctx: Context, argument: str) -> Union[HelpCommand, Command, Cog]: + async def convert(self, ctx: Context, argument: str) -> Union[HelpCommand, Command, Cog, None]: """ Convert argument into source object. @@ -39,7 +39,7 @@ class SourceConverter(Converter): if cog: return cog - raise BadArgument(f"Unable to convert `{argument}` to help command, command or cog.") + return None class Source(Cog): @@ -49,8 +49,14 @@ class Source(Cog): self.bot = bot @command(name="source", aliases=("src",)) - async def source_command(self, ctx: Context, *, source_item: SourceConverter) -> None: + async def source_command(self, ctx: Context, *, source_item: Optional[SourceConverter] = None) -> None: """Get GitHub link and information about help command, command or Cog.""" + if not source_item: + embed = Embed(title="Bot GitHub Repository", url=URLs.github_bot_repo) + embed.add_field(name="Repository", value=f"[Go to GitHub]({URLs.github_bot_repo})") + await ctx.send(embed=embed) + return + url = self.get_source_link(source_item) await ctx.send(embed=await self.build_embed(url, source_item, ctx)) |