★ wanayoo — archive 1999 https://github.com/python-discord/code-jam-1/pull/17Nouvelle recherche | Portail wanayoo
Skip to content
This repository has been archived by the owner. It is now read-only.

Team 9 #17

Open
wants to merge 18 commits into
base: master
from
Open

Team 9 #17

wants to merge 18 commits into from

Conversation

@samhallam03
Copy link

@samhallam03 samhallam03 commented Mar 24, 2018

No description provided.

samhallam03 added 13 commits Mar 23, 2018
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]:
"""

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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:

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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:

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

You could replace this entire thing with if not name:

'location': snake['location'],
'venomous': snake['venomous'],
'image': snake['image']
}

This comment has been minimized.

@gdude2002

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.

This comment has been minimized.

@samhallam03

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.

This comment has been minimized.

@gdude2002

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.


@command()
@command(name='get')

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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:

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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")

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

Maybe .title() this instead of .lower() this?


embed.set_thumbnail(url="https://i.imgur.com/dB38NwN.png")

elif len(movie_name) > 0:

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

Again, could just be else


elif len(movie_name) > 0:
embed = Embed(
title=movies_dict[movie_name]['title'],

This comment has been minimized.

@gdude2002

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.

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()]

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

This will break if the snake isn't in the dict.

This comment has been minimized.

@samhallam03

samhallam03 Mar 25, 2018
Author

How can I send an error message to the discord chat if this is just a normal function?

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

You can't.

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

Maybe look into exception handling?

This comment has been minimized.

@samhallam03

samhallam03 Mar 25, 2018
Author

So should it just not prompt the user if the snake cannot be found?

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

Of course it should. But you can't send the message directly from this method.

This comment has been minimized.

@samhallam03

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.

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

You might prefer to return None or something, but yes

This comment has been minimized.

@samhallam03

samhallam03 Mar 25, 2018
Author

If I do None it returns a random snake, so I'm not sure what I would do.

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

Well, the approach is up to you. Do what works for you.

Copy link
Author

@samhallam03 samhallam03 left a comment

Changes made.

samhallam03 added 2 commits Mar 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.