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

Team 14 #21

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified Pipfile
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified bot/__init__.py
100644 → 100755
Empty file.
Empty file modified bot/cogs/__init__.py
100644 → 100755
Empty file.
Empty file modified bot/cogs/logging.py
100644 → 100755
Empty file.
Empty file modified bot/cogs/security.py
100644 → 100755
Empty file.
21 changes: 13 additions & 8 deletions bot/cogs/snakes.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# coding=utf-8
import logging
from typing import Any, Dict

from discord.ext.commands import AutoShardedBot, Context, command

log = logging.getLogger(__name__)

import discord
Copy link

Choose a reason for hiding this comment

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

This module level import should be at the top of the file.

Copy link

Choose a reason for hiding this comment

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

(preferably before from discord.ext.commands import AutoShardedBot, Context, command)


class Snakes:
Copy link

Choose a reason for hiding this comment

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

You should have two blank lines before a definition.

"""
Expand All @@ -18,29 +17,35 @@ def __init__(self, bot: AutoShardedBot):
async def get_snek(self, name: str = None) -> Dict[str, Any]:
"""
Go online and fetch information about a snake

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

:param name: Optional, the name of the snake to get information for - omit for a random snake
:return: A dict containing information on a snake

"""


@command()
async def get(self, ctx: Context, name: str = None):
async def get(self, ctx: Context, *, query: str = None):
"""
Go online and fetch information about a snake

This should make use of your `get_snek` method, using it to get information about a snake. This information
should be sent back to Discord in an embed.

:param ctx: Context object passed from discord.py
:param name: Optional, the name of the snake to get information for - omit for a random snake
"""

em = discord.Embed(title=str(query))
Copy link

Choose a reason for hiding this comment

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

There's nothing wrong with using embed as the variable name. It's much easier to follow.

em.set_footer(text='Powered by wikipedia.org')
async with self.bot.http_session.get(f"https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles={query}") as resp:
Copy link

Choose a reason for hiding this comment

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

You might want to have this string format defined on a separate line. Travis agrees.

data = await resp.json()
data = data['query']
em.description = (data["pages"][list(data["pages"].keys())[0]]["extract"])[:2000]
Copy link

Choose a reason for hiding this comment

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

This line would look a lot better split over several lines. There's no need to have it all on a single line.

await ctx.send(embed=em)


# Any additional commands can be placed here. Be creative, but keep it to a reasonable amount!


Expand Down
Empty file modified bot/constants.py
100644 → 100755
Empty file.
Empty file modified bot/decorators.py
100644 → 100755
Empty file.
Empty file modified bot/formatter.py
100644 → 100755
Empty file.
Empty file modified bot/pagination.py
100644 → 100755
Empty file.
Empty file modified bot/utils.py
100644 → 100755
Empty file.
Empty file modified doc/README.md
100644 → 100755
Empty file.
Empty file modified doc/bot-setup.md
100644 → 100755
Empty file.
Empty file modified doc/linting.md
100644 → 100755
Empty file.
Empty file modified doc/pipenv.md
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion run.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
# Commands, etc
bot.load_extension("bot.cogs.snakes")

bot.run(os.environ.get("BOT_TOKEN"))
bot.run(os.environ.get('BOT_TOKEN'))


bot.http_session.close() # Close the aiohttp session when the bot finishes running
Empty file modified tox.ini
100644 → 100755
Empty file.