-
-
Notifications
You must be signed in to change notification settings - Fork 16
Team 8 #4
base: master
Are you sure you want to change the base?
Team 8 #4
Conversation
Fix Pipfile dependencies
Exclude virtualenv from Flake8 linting. Again.
bot/cogs/snakes.py
Outdated
| def setup(bot): | ||
| bot.add_cog(Snakes(bot)) | ||
| log.info("Cog loaded: Snakes") | ||
| bot.loop.create_task(Snakes(bot).cache_snakelist()) |
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.
Instead of creating two instances of the same class, the __init__ method of the class should create the task to cache the data.
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.
Runew0lf wrote it.
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.
Ruinew0lf fixed it.
…e-jam-1 into bisk # Conflicts: # bot/cogs/snakes.py
[UPDATE] Ignored a silly rule from flake8.
Doing comments.
lemonsaurus
left a comment
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 is a pretty solid PR all in all. The game is fun, and appears to work well. Your get_snek is one of the better ones in the whole jam. all in all a job well done.
bot/cogs/snakes.py
Outdated
| EMPTY = u'\u200b' | ||
|
|
||
| # Results | ||
| TICK_EMOJI = "\u2705" # Correct Peg, Correct Hole |
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.
Why Are You Capitalizing Every Word In This Comment
bot/cogs/snakes.py
Outdated
| # Results | ||
| TICK_EMOJI = "\u2705" # Correct Peg, Correct Hole | ||
| CROSS_EMOJI = "\u274C" # Wrong | ||
| BLANK_EMOJI = "\u26AA" # Correct Peg Wrong Hole |
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.
missing comma, lol
| # This caches the very expensive snake list operation on load | ||
| self.setup = bot.loop.create_task(self.cache_snake_list()) | ||
|
|
||
| async def cache_snake_list(self): |
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 may be a little overengineered considering you only ever call get_snake_list() from this method. It may be better to just merge those two methods into one unless you plan on using get_snake_list for anything else.
| """ | ||
| Go online and fetch information about a snake | ||
| self.snake_cache = await self.get_snake_list() | ||
| return |
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 line does nothing. A method that has no return will also return None at the end of the method, so there's no reason to do it explicitly.
| snake_list = sorted(list(set(snake_list))) | ||
| return snake_list | ||
|
|
||
| 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.
the docstring for this method is bad.
bot/cogs/snakes.py
Outdated
| return ( | ||
| # Conditions for a successful pagination: | ||
| all(( | ||
| # Reaction is on this message |
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.
these should probably be inline, and it'd be nice if they all lined up.
| ) | ||
|
|
||
| while True: | ||
| try: |
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 is a huge try, which is an anti-pattern. You should only try the code that can actually fail.
bot/cogs/snakes.py
Outdated
| page_guess_list[antidote_tries] = " ".join(antidote_guess_list) | ||
| log.info(f"Guess: {' '.join(antidote_guess_list)}") | ||
|
|
||
| # Now Check Guess |
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.
Okay Then, Captain CapWords.
bot/cogs/snakes.py
Outdated
| page_result_list[antidote_tries] = " ".join(guess_result) | ||
| log.info(f"Guess Result: {' '.join(guess_result)}") | ||
|
|
||
| # Rebuild the board |
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.
pls no more floating comments.
bot/cogs/snakes.py
Outdated
| # Redisplay the board | ||
| await board_id.edit(embed=antidote_embed) | ||
|
|
||
| if win is True: |
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.
why are you using a while True with conditions and breaks at the end instead of just putting the conditions in the while?
gdude2002
left a comment
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.
A very nice, readable PR. Since you're using async_timeout, you'll need to pipenv install it - or you could remove it, and stick with aiohttp.Timeout(interval).
bot/cogs/snakes.py
Outdated
|
|
||
| import aiohttp | ||
|
|
||
| import async_timeout |
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 just use aiohttp.Timeout
bot/cogs/snakes.py
Outdated
| @command(name="antidote") | ||
| async def build_board(self, ctx: Context): | ||
| """ | ||
| Antidote - Can you create the antivenom before the patient dies! |
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.
!! ??
lemonsaurus
left a comment
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.
Nice try though.
| TICK_EMOJI = "\u2705" # Correct peg, correct hole | ||
| CROSS_EMOJI = "\u274C" # Wrong | ||
| BLANK_EMOJI = "\u26AA" # Correct Peg Wrong Hole | ||
| BLANK_EMOJI = "\u26AA" # Correct peg, wrong hle |
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.
hle? seriously? 👍
| ANTIDOTE_EMOJI = [FIRST_EMOJI, SECOND_EMOJI, THIRD_EMOJI, FOURTH_EMOJI, FIFTH_EMOJI] | ||
|
|
||
|
|
||
| def to_lower(argument): |
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 don't see why this helper function is useful. it's also error prone. if you pass anything into it that isn't a string, it'll crash the program. Just use the str.lower() method instead of having this helper function at all.
|
|
||
| @command() | ||
| async def get(self, ctx: Context, name: str = None): | ||
| async def get(self, ctx: Context, name: to_lower = None): |
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 typehint something to a function. to_lower is not a type, and as far as I can tell name is still a str
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 do that, discord.py will convert the string to lowercase automatically
|
|
||
| # Check to see if the bot can remove reactions | ||
| if not ctx.channel.permissions_for(ctx.guild.me).manage_messages: | ||
| await ctx.send("Unable to start game as I dont have manage_messages permissions") |
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.
*don't
| # There were no restrictions | ||
| no_restrictions | ||
| reaction_.message.id == board_id.id, # Reaction is on this message | ||
| reaction_.emoji in ANTIDOTE_EMOJI, # Reaction is one of the pagination emotes |
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.
best to line these comments up with each other, much better readability. PEP8 only says there should be at least 2 spaces, but does not say anything about not being allowed to use five if it helps your program become more readable. so this:
something = something # do a useless thing
something = not something # oh okay why did we even do the previous thing thenis encouraged.
The stuff 'n' that.