Skip to content
This repository was archived by the owner on Mar 14, 2021. It is now read-only.

Team 9 #17

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Team 9 #17

wants to merge 18 commits into from

Conversation

samhallam03
Copy link

No description provided.

@@ -16,32 +19,88 @@ def __init__(self, bot: AutoShardedBot):
self.bot = bot

async def get_snek(self, name: str = None) -> Dict[str, Any]:
"""
Copy link
Contributor

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?


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:
Copy link
Contributor

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:


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:
Copy link
Contributor

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:

'location': snake['location'],
'venomous': snake['venomous'],
'image': snake['image']
}
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.


@command()
@command(name='get')
Copy link
Contributor

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.

with open('bot/db/movies.json', 'r') as file:
movies_dict = json.load(file)

if movie_name is None or len(movie_name) == 0:
Copy link
Contributor

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:

)

for movie in movies_dict.values():
embed.add_field(name=movie['title'], value=f"bot.movies('{movie['title'].lower()}')\n\n")
Copy link
Contributor

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?


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

elif len(movie_name) > 0:
Copy link
Contributor

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


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

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.

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()]
Copy link
Contributor

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.

Copy link
Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't.

Copy link
Contributor

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?

Copy link
Author

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?

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

@samhallam03 samhallam03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants