Skip to content

Commit

Permalink
Clean up embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhijeetKrishnan committed Mar 1, 2024
1 parent c91798a commit 263a1be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/framedb/framedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

logger = logging.getLogger("main")

# TODO: refactor the query methods - simplify + handle alts and aliases correctly


class FrameDb:
"""
Expand Down
22 changes: 16 additions & 6 deletions src/heihachi/embed.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Embeds for the Heihachi bot."""

import logging
from typing import Any, List

import discord

from framedb import Character, FrameDb, FrameService, Move, MoveType
from framedb import Character, FrameDb, FrameService, Move

logger = logging.getLogger("main")

MOVE_NOT_FOUND_TITLE = "Move not found"

Expand All @@ -24,12 +27,15 @@ def get_similar_moves_embed( # TODO: look into improving the similar moves flow
embed = discord.Embed(
title=MOVE_NOT_FOUND_TITLE,
colour=WARNING_COLOR,
description=f"Similar moves from {character.name.pretty()} -",
)

embed.add_field(name="Input", value="\n".join([move.input for move in similar_moves]))
if len(similar_moves) > 0:
embed.add_field(name="Similar Moves", value="\n".join([move.input for move in similar_moves]))
else:
embed.add_field(name="No similar moves found", value="")
embed.set_thumbnail(url=character.portrait)
embed.set_footer(text=frame_service.name, icon_url=frame_service.icon)
embed.set_author(name=character.name.pretty(), url=character.page)
return embed


Expand All @@ -41,13 +47,16 @@ def get_success_movelist_embed(
For e.g., to a move type
"""

desc_string = "\n".join(sorted([move.input for move in moves])) # TODO: add move links or more data?
desc_string = "\n".join(sorted([move.input for move in moves]))

embed = discord.Embed(
title=f"{character.name.pretty()} {title}:\n",
title=f"{title}\n",
colour=SUCCESS_COLOR,
description=desc_string,
)
embed.set_thumbnail(url=character.portrait)
embed.set_footer(text=frame_service.name, icon_url=frame_service.icon)
embed.set_author(name=character.name.pretty(), url=character.page)
return embed


Expand Down Expand Up @@ -103,7 +112,8 @@ def get_frame_data_embed(framedb: FrameDb, frame_service: FrameService, char_que
if character:
move_type = framedb.get_move_type(move_query)
if move_type:
moves_by_move_type = framedb.get_moves_by_move_type(character.name, move_type.name)
logger.info(f"Identified move query as move type {move_type}. Getting moves...")
moves_by_move_type = framedb.get_moves_by_move_type(character.name, move_type.value)
embed = get_success_movelist_embed(frame_service, character, moves_by_move_type, move_type.value)
else:
moves = framedb.search_move(character, move_query)
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

logger = logging.getLogger("main")
formatter = logging.Formatter(
"%(asctime)s %(levelname)s %(module)s:%(funcName)s:%(lineno)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S"
"%(asctime)s %(levelname)-8s %(module)s:%(funcName)s:%(lineno)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S"
)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
Expand Down

0 comments on commit 263a1be

Please sign in to comment.