Improved type-hinting and overall sanity checks implemented.
This commit is contained in:
18
cogs/fun.py
18
cogs/fun.py
@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class Fun(commands.Cog):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.client = client
|
||||
self.client: PycordBot = client
|
||||
|
||||
@slash_command(
|
||||
name="action",
|
||||
@@ -27,13 +27,13 @@ class Fun(commands.Cog):
|
||||
choices=sync_config_get("actions").keys(),
|
||||
)
|
||||
@option("user", description="Користувач")
|
||||
async def action_cmd(self, ctx: ApplicationContext, type: str, user: User):
|
||||
async def action_cmd(self, ctx: ApplicationContext, type: str, user: User) -> None:
|
||||
await ctx.defer()
|
||||
|
||||
action = await config_get("category", "actions", type)
|
||||
action_verb = await config_get("action", "actions", type)
|
||||
action: str = await config_get("category", "actions", type)
|
||||
action_verb: str = await config_get("action", "actions", type)
|
||||
|
||||
image = await waifu_pics.sfw(action)
|
||||
image_url: str = await waifu_pics.sfw(action)
|
||||
|
||||
logger.info(
|
||||
"User %s (%s) %s %s (%s) with image %s",
|
||||
@@ -42,17 +42,17 @@ class Fun(commands.Cog):
|
||||
action_verb,
|
||||
guild_name(user),
|
||||
user.id,
|
||||
image,
|
||||
image_url,
|
||||
)
|
||||
|
||||
embed = Embed(
|
||||
embed: Embed = Embed(
|
||||
description=f"**{guild_name(ctx.user)}** {action_verb} **{guild_name(user)}**",
|
||||
color=0x2F3136,
|
||||
)
|
||||
embed.set_image(url=image)
|
||||
embed.set_image(url=image_url)
|
||||
|
||||
await ctx.respond(embed=embed)
|
||||
|
||||
|
||||
def setup(client: PycordBot):
|
||||
def setup(client: PycordBot) -> None:
|
||||
client.add_cog(Fun(client))
|
||||
|
Reference in New Issue
Block a user