-
-
Notifications
You must be signed in to change notification settings - Fork 16
Team 9 #17
base: master
Are you sure you want to change the base?
Team 9 #17
Conversation
Fix Pipfile dependencies
[UPDATE] Ignored a silly rule from flake8.
bot/cogs/snakes.py
Outdated
@@ -16,32 +19,88 @@ def __init__(self, bot: AutoShardedBot): | |||
self.bot = bot | |||
|
|||
async def get_snek(self, name: str = None) -> Dict[str, Any]: | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should bring back the docstring - why'd you remove it?
bot/cogs/snakes.py
Outdated
|
||
If "python" is given as the snake name, you should return information about the programming language, but with | ||
all the information you'd provide for a real snake. Try to have some fun with this! | ||
elif len(name) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can just be an else:
bot/cogs/snakes.py
Outdated
|
||
The information includes the name of the snake, a picture of the snake, and various other pieces of info. | ||
What information you get for the snake is up to you. Be creative! | ||
if name is None or len(name) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could replace this entire thing with if not name:
bot/cogs/snakes.py
Outdated
'location': snake['location'], | ||
'venomous': snake['venomous'], | ||
'image': snake['image'] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is how the information is stored, then you could just return snake
, there's no need to repackage the dict into another dict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean, I think I did that because I have different information for the Python Language. I guess I would only need to change snake
if they entered python
if I'm correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, no, I mean, the keys you're placing into the dict match the keys that you're pulling out of the snake dict. It's just redundant.
bot/cogs/snakes.py
Outdated
|
||
@command() | ||
@command(name='get') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, but nothing wrong with having it.
bot/cogs/snakes.py
Outdated
with open('bot/db/movies.json', 'r') as file: | ||
movies_dict = json.load(file) | ||
|
||
if movie_name is None or len(movie_name) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, could use if not movie_name:
bot/cogs/snakes.py
Outdated
) | ||
|
||
for movie in movies_dict.values(): | ||
embed.add_field(name=movie['title'], value=f"bot.movies('{movie['title'].lower()}')\n\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe .title()
this instead of .lower()
this?
bot/cogs/snakes.py
Outdated
|
||
embed.set_thumbnail(url="https://i.imgur.com/dB38NwN.png") | ||
|
||
elif len(movie_name) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, could just be else
bot/cogs/snakes.py
Outdated
|
||
elif len(movie_name) > 0: | ||
embed = Embed( | ||
title=movies_dict[movie_name]['title'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break if the movie isn't in the dict, or it isn't entirely lowercase. Should fix that.
bot/cogs/snakes.py
Outdated
If "python" is given as the snake name, you should return information about the programming language, but with | ||
all the information you'd provide for a real snake. Try to have some fun with this! | ||
elif len(name) > 0: | ||
snake = snakes_dict[name.lower()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break if the snake isn't in the dict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I send an error message to the discord chat if this is just a normal function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe look into exception handling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should it just not prompt the user if the snake cannot be found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course it should. But you can't send the message directly from this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesn't exist, could I return snake
as a string and test if it is a string in get()
and just send a message if it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might prefer to return None
or something, but yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do None
it returns a random snake, so I'm not sure what I would do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the approach is up to you. Do what works for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes made.
No description provided.