aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/evergreen/snakes/converter.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot/seasons/evergreen/snakes/converter.py')
-rw-r--r--bot/seasons/evergreen/snakes/converter.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/bot/seasons/evergreen/snakes/converter.py b/bot/seasons/evergreen/snakes/converter.py
index c091d9c1..ec9c9870 100644
--- a/bot/seasons/evergreen/snakes/converter.py
+++ b/bot/seasons/evergreen/snakes/converter.py
@@ -13,10 +13,14 @@ log = logging.getLogger(__name__)
class Snake(Converter):
+ """Snake converter for the Snakes Cog."""
+
snakes = None
special_cases = None
async def convert(self, ctx, name):
+ """Convert the input snake name to the closest matching Snake object."""
+
await self.build_list()
name = name.lower()
@@ -56,6 +60,8 @@ class Snake(Converter):
@classmethod
async def build_list(cls):
+ """Build list of snakes from the static snake resources."""
+
# Get all the snakes
if cls.snakes is None:
with (SNAKE_RESOURCES / "snake_names.json").open() as snakefile:
@@ -70,11 +76,14 @@ class Snake(Converter):
@classmethod
async def random(cls):
"""
- This is stupid. We should find a way to
- somehow get the global session into a
- global context, so I can get it from here.
+ Get a random Snake from the loaded resources.
+
+ This is stupid. We should find a way to somehow get the global session into a global context,
+ so I can get it from here.
+
:return:
"""
+
await cls.build_list()
names = [snake['scientific'] for snake in cls.snakes]
return random.choice(names)