Conversation
Fix Pipfile dependencies
[UPDATE] Ignored a silly rule from flake8.
| self.bot = bot | ||
|
|
||
| async def get_snek(self, name: str = None) -> Dict[str, Any]: | ||
| """ |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
| return snake_info | ||
|
|
||
| @command() | ||
| @command(name='get') |
There was a problem hiding this comment.
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.
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.
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.
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.
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()] |
There was a problem hiding this comment.
This will break if the snake isn't in the dict.
There was a problem hiding this comment.
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.
Maybe look into exception handling?
There was a problem hiding this comment.
So should it just not prompt the user if the snake cannot be found?
There was a problem hiding this comment.
Of course it should. But you can't send the message directly from this method.
There was a problem hiding this comment.
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.
You might prefer to return None or something, but yes
There was a problem hiding this comment.
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.
Well, the approach is up to you. Do what works for you.
No description provided.