Team 9 #17
Team 9 #17
Conversation
Fix Pipfile dependencies
[UPDATE] Ignored a silly rule from flake8.
| @@ -16,32 +19,88 @@ def __init__(self, bot: AutoShardedBot): | |||
| self.bot = bot | |||
|
|
|||
| async def get_snek(self, name: str = None) -> Dict[str, Any]: | |||
| """ | |||
gdude2002
Mar 25, 2018
Contributor
You should bring back the docstring - why'd you remove it?
You should bring back the docstring - why'd you remove it?
|
|
||
| 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: |
gdude2002
Mar 25, 2018
Contributor
That can just be an else:
That can just be an else:
|
|
||
| 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: |
gdude2002
Mar 25, 2018
Contributor
You could replace this entire thing with if not name:
You could replace this entire thing with if not name:
| 'location': snake['location'], | ||
| 'venomous': snake['venomous'], | ||
| 'image': snake['image'] | ||
| } |
gdude2002
Mar 25, 2018
Contributor
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.
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.
samhallam03
Mar 25, 2018
Author
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.
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.
gdude2002
Mar 25, 2018
Contributor
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.
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.
|
|
||
| @command() | ||
| @command(name='get') |
gdude2002
Mar 25, 2018
Contributor
Not needed, but nothing wrong with having it.
Not needed, but nothing wrong with having it.
| with open('bot/db/movies.json', 'r') as file: | ||
| movies_dict = json.load(file) | ||
|
|
||
| if movie_name is None or len(movie_name) == 0: |
gdude2002
Mar 25, 2018
Contributor
Again, could use if not movie_name:
Again, could use if not movie_name:
| ) | ||
|
|
||
| for movie in movies_dict.values(): | ||
| embed.add_field(name=movie['title'], value=f"bot.movies('{movie['title'].lower()}')\n\n") |
gdude2002
Mar 25, 2018
Contributor
Maybe .title() this instead of .lower() this?
Maybe .title() this instead of .lower() this?
|
|
||
| embed.set_thumbnail(url="https://i.imgur.com/dB38NwN.png") | ||
|
|
||
| elif len(movie_name) > 0: |
gdude2002
Mar 25, 2018
Contributor
Again, could just be else
Again, could just be else
|
|
||
| elif len(movie_name) > 0: | ||
| embed = Embed( | ||
| title=movies_dict[movie_name]['title'], |
gdude2002
Mar 25, 2018
Contributor
This will break if the movie isn't in the dict, or it isn't entirely lowercase. Should fix that.
This will break if the movie isn't in the dict, or it isn't entirely lowercase. Should fix that.
| 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()] |
gdude2002
Mar 25, 2018
Contributor
This will break if the snake isn't in the dict.
This will break if the snake isn't in the dict.
samhallam03
Mar 25, 2018
Author
How can I send an error message to the discord chat if this is just a normal function?
How can I send an error message to the discord chat if this is just a normal function?
gdude2002
Mar 25, 2018
Contributor
You can't.
You can't.
gdude2002
Mar 25, 2018
Contributor
Maybe look into exception handling?
Maybe look into exception handling?
samhallam03
Mar 25, 2018
Author
So should it just not prompt the user if the snake cannot be found?
So should it just not prompt the user if the snake cannot be found?
gdude2002
Mar 25, 2018
Contributor
Of course it should. But you can't send the message directly from this method.
Of course it should. But you can't send the message directly from this method.
samhallam03
Mar 25, 2018
Author
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.
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.
gdude2002
Mar 25, 2018
Contributor
You might prefer to return None or something, but yes
You might prefer to return None or something, but yes
samhallam03
Mar 25, 2018
Author
If I do None it returns a random snake, so I'm not sure what I would do.
If I do None it returns a random snake, so I'm not sure what I would do.
gdude2002
Mar 25, 2018
Contributor
Well, the approach is up to you. Do what works for you.
Well, the approach is up to you. Do what works for you.
|
Changes made. |
No description provided.