Code Cleanup

This commit is contained in:
Robert 2020-01-08 02:26:36 +01:00
parent d2622e25e8
commit fa34f8510d
13 changed files with 98 additions and 50 deletions

View file

@ -1,3 +1,8 @@
'''
This is the cog that allows users to
fetch an AI-generated inspirational quote
made by Inspirobot
'''
import discord
from discord.ext import commands
@ -6,12 +11,12 @@ from util import config
class Inspirobot(commands.Cog):
def __init__(self, client):
def __init__(self, client : discord.Client):
self.client = client
@commands.command(name="Inspirobot", description="Sends a randomly generated inspirational quote", aliases=["inspiration", "inspiro"])
@commands.cooldown(1, 5)
async def inspirobot(self, ctx):
async def inspirobot(self, ctx : commands.Context):
image = inspirobot.get_inspirational_quote()
if image is None:
await ctx.message.add_reaction("⚠️")
@ -20,5 +25,5 @@ class Inspirobot(commands.Cog):
embed.set_image(url=image)
await ctx.send(embed=embed)
def setup(client):
def setup(client : discord.Client):
client.add_cog(Inspirobot(client))

View file

@ -1,3 +1,7 @@
'''
This cog is capable of communicating with the
NASA API
'''
import discord
from discord.ext import commands
from api import nasa
@ -5,12 +9,12 @@ from util import config
class Nasa(commands.Cog):
def __init__(self, client):
def __init__(self, client: discord.Client):
self.client = client
@commands.command(name="APOD", description="Posts NASA's picture of the day.")
@commands.cooldown(1, 30)
async def apod(self, ctx):
async def apod(self, ctx: commands.Context):
url = nasa.image_of_the_day()
embed = discord.Embed(title="Astronomy Picture of the day", color=int(config.settings["color"], 16))
embed.set_image(url=url)
@ -18,5 +22,5 @@ class Nasa(commands.Cog):
await ctx.send(embed=embed)
def setup(client):
def setup(client: discord.Client):
client.add_cog(Nasa(client))

View file

@ -1,15 +1,19 @@
'''
This cog can fetch data from the
Steam WebAPI
'''
import discord
from discord.ext import commands
from api import steam
class Steam(commands.Cog):
def __init__(self, client):
def __init__(self, client: discord.Client):
self.client = client
@commands.command(name="SteamLevel", description="Finds the steam level of a user", usage="SteamLevel <Vanity URL>", aliases=["level"])
@commands.cooldown(1, 2)
async def SteamLevel(self, ctx, vanity_url):
async def SteamLevel(self, ctx: commands.Context, vanity_url: str):
level = steam.get_steam_level(vanity_url)
if level is None:
@ -17,9 +21,7 @@ class Steam(commands.Cog):
else:
percentile = round(float(steam.get_steam_level_distribution(level)), 2)
await ctx.send(f"{vanity_url} is level {level}! This makes him better than {percentile}% of Steam users!")
def setup(client):
def setup(client: discord.Client):
client.add_cog(Steam(client))