aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/source.py
diff options
context:
space:
mode:
authorGravatar ToxicKidz <[email protected]>2021-05-05 13:46:08 -0400
committerGravatar ToxicKidz <[email protected]>2021-05-05 13:46:08 -0400
commit888f83170bce384315a0a5c47b87b7ffbfb5d8ea (patch)
treeb5b05078abe529ecaa3e9c644b3cf445490fef03 /bot/exts/evergreen/source.py
parentchore: Don't have defaults for typing.Optional[...] in commands (diff)
chore: Add all of the converters into bot/utils/converters.py
Diffstat (limited to 'bot/exts/evergreen/source.py')
-rw-r--r--bot/exts/evergreen/source.py23
1 files changed, 2 insertions, 21 deletions
diff --git a/bot/exts/evergreen/source.py b/bot/exts/evergreen/source.py
index 685b3111..8fb72143 100644
--- a/bot/exts/evergreen/source.py
+++ b/bot/exts/evergreen/source.py
@@ -1,32 +1,13 @@
import inspect
from pathlib import Path
-from typing import Optional, Tuple, Union
+from typing import Optional, Tuple
from discord import Embed
from discord.ext import commands
from bot.bot import Bot
from bot.constants import Source
-
-SourceType = Union[commands.Command, commands.Cog, str, commands.ExtensionNotLoaded]
-
-
-class SourceConverter(commands.Converter):
- """Convert an argument into a help command, tag, command, or cog."""
-
- async def convert(self, ctx: commands.Context, argument: str) -> SourceType:
- """Convert argument into source object."""
- cog = ctx.bot.get_cog(argument)
- if cog:
- return cog
-
- cmd = ctx.bot.get_command(argument)
- if cmd:
- return cmd
-
- raise commands.BadArgument(
- f"Unable to convert `{argument}` to valid command or Cog."
- )
+from bot.utils.converters import SourceConverter, SourceType
class BotSource(commands.Cog):