diff options
author | 2021-03-20 11:02:28 -0400 | |
---|---|---|
committer | 2021-03-20 11:02:28 -0400 | |
commit | 087b58209b52f835eef6493d2269d98867f39b0c (patch) | |
tree | 447e6d21126fd59638a60b229c0f853a3af3e9ea | |
parent | Forgot a comma for the tuple (diff) |
Follow style guildines and use better colours
-rw-r--r-- | bot/exts/evergreen/githubinfo.py | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/bot/exts/evergreen/githubinfo.py b/bot/exts/evergreen/githubinfo.py index da2b37ac..ec2f9d98 100644 --- a/bot/exts/evergreen/githubinfo.py +++ b/bot/exts/evergreen/githubinfo.py @@ -1,13 +1,12 @@ import logging import random from datetime import datetime -from typing import Optional import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType -from bot.constants import NEGATIVE_REPLIES +from bot.constants import NEGATIVE_REPLIES, Colours from bot.exts.utils.extensions import invoke_help_command log = logging.getLogger(__name__) @@ -34,25 +33,24 @@ class GithubInfo(commands.Cog): await invoke_help_command(ctx) @github_group.command(name='user', aliases=('userinfo',)) - async def github_user_info(self, ctx: commands.Context, username: Optional[str]) -> None: + async def github_user_info(self, ctx: commands.Context, username: str) -> None: """ Fetches a user's GitHub information. Username is optional and sends the help command if not specified. """ - if username is None: - await invoke_help_command(ctx) - ctx.command.reset_cooldown(ctx) - return - async with ctx.typing(): user_data = await self.fetch_data(f"{GITHUB_API_URL}/users/{username}") # User_data will not have a message key if the user exists if user_data.get('message') is not None: - await ctx.send(embed=discord.Embed(title=random.choice(NEGATIVE_REPLIES), - description=f"The profile for `{username}` was not found.", - colour=discord.Colour.red())) + embed = discord.Embed( + title=random.choice(NEGATIVE_REPLIES), + description=f"The profile for `{username}` was not found.", + colour=Colours.soft_red + ) + + await ctx.send() return org_data = await self.fetch_data(user_data['organizations_url']) @@ -72,7 +70,7 @@ class GithubInfo(commands.Cog): embed = discord.Embed( title=f"`{user_data['login']}`'s GitHub profile info", description=f"```{user_data['bio']}```\n" if user_data['bio'] is not None else "", - colour=0x7289da, + colour=discord.Colour.blurple(), url=user_data['html_url'], timestamp=datetime.strptime(user_data['created_at'], "%Y-%m-%dT%H:%M:%SZ") ) @@ -81,19 +79,27 @@ class GithubInfo(commands.Cog): if user_data['type'] == "User": - embed.add_field(name="Followers", - value=f"[{user_data['followers']}]({user_data['html_url']}?tab=followers)") - embed.add_field(name="Following", - value=f"[{user_data['following']}]({user_data['html_url']}?tab=following)") + embed.add_field( + name="Followers", + value=f"[{user_data['followers']}]({user_data['html_url']}?tab=followers)" + ) + embed.add_field( + name="Following", + value=f"[{user_data['following']}]({user_data['html_url']}?tab=following)" + ) - embed.add_field(name="Public repos", - value=f"[{user_data['public_repos']}]({user_data['html_url']}?tab=repositories)") + embed.add_field( + name="Public repos", + value=f"[{user_data['public_repos']}]({user_data['html_url']}?tab=repositories)" + ) if user_data['type'] == "User": embed.add_field(name="Gists", value=f"[{gists}](https://gist.github.com/{username})") - embed.add_field(name=f"Organization{'s' if len(orgs)!=1 else ''}", - value=orgs_to_add if orgs else "No organizations") + embed.add_field( + name=f"Organization{'s' if len(orgs)!=1 else ''}", + value=orgs_to_add if orgs else "No organizations" + ) embed.add_field(name="Website", value=blog) await ctx.send(embed=embed) @@ -113,7 +119,7 @@ class GithubInfo(commands.Cog): embed = discord.Embed( title=random.choice(NEGATIVE_REPLIES), description="The requested repository was not found.", - colour=discord.Colour.red() + colour=Colours.soft_red ) await ctx.send(embed=embed) |