Skip to content

Commit

Permalink
Add character tree command
Browse files Browse the repository at this point in the history
  • Loading branch information
TLNBS2405 committed Feb 3, 2024
1 parent 0dc0eaa commit ead0869
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ The executable is `src/main.py`. Don't forget to put this project into your PYTH
```
Slash Command
/fd <character> <move> - get frame data of a move from a character
/<character> <move> - same as above
```
229 changes: 226 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_frame_data_embed(name: str, move: str) -> discord.Embed:
character_name = util.correct_character_name(name.lower())
if character_name:
character = util.get_character_by_name(character_name, character_list)
move_list = json_movelist_reader.get_movelist(character_name,JSON_PATH)
move_list = json_movelist_reader.get_movelist(character_name, JSON_PATH)
move_type = util.get_move_type(move)

if move_type:
Expand Down Expand Up @@ -90,6 +90,230 @@ async def self(interaction: discord.Interaction, character_name: str, move: str)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="alisa", description="Frame data from alisa")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("alisa", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="asuka", description="Frame data from asuka")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("asuka", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="azucena", description="Frame data from azucena")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("azucena", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="bryan", description="Frame data from bryan")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("bryan", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="claudio", description="Frame data from claudio")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("claudio", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="devil_jin", description="Frame data from devil_jin")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("devil_jin", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="dragunov", description="Frame data from dragunov")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("dragunov", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="feng", description="Frame data from feng")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("feng", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="hwoarang", description="Frame data from hwoarang")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("hwoarang", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="jack-8", description="Frame data from jack-8")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("jack-8", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="jin", description="Frame data from jin")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("jin", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="jun", description="Frame data from jun")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("jun", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="kazuya", description="Frame data from kazuya")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("kazuya", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="king", description="Frame data from king")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("king", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="kuma", description="Frame data from kuma")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("kuma", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="lars", description="Frame data from lars")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("lars", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="law", description="Frame data from law")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("law", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="lee", description="Frame data from lee")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("lee", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="leo", description="Frame data from leo")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("leo", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="leroy", description="Frame data from leroy")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("leroy", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="lili", description="Frame data from lili")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("lili", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="nina", description="Frame data from nina")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("nina", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="panda", description="Frame data from panda")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("panda", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="paul", description="Frame data from paul")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("paul", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="raven", description="Frame data from raven")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("raven", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="reina", description="Frame data from reina")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("reina", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="shaheen", description="Frame data from shaheen")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("shaheen", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="steve", description="Frame data from steve")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("steve", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="victor", description="Frame data from victor")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("victor", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="xiaoyu", description="Frame data from xiaoyu")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("xiaoyu", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="yoshimitsu", description="Frame data from yoshimitsu")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("yoshimitsu", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="zafina", description="Frame data from zafina")
async def self(interaction: discord.Interaction, move: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
embed = create_frame_data_embed("zafina", move)
await interaction.response.send_message(embed=embed, ephemeral=False)


@tree.command(name="feedback", description="Send feedback incase of wrong data")
async def self(interaction: discord.Interaction, message: str):
if not (util.is_user_blacklisted(interaction.user.id) or util.is_author_newly_created(interaction)):
Expand All @@ -99,7 +323,7 @@ async def self(interaction: discord.Interaction, message: str):
interaction.guild, message)
channel = hei.get_channel(feedback_channel_id)
actioned_channel = hei.get_channel(actioned_channel_id)
await channel.send(content=feedback_message,view=button.DoneButton(actioned_channel))
await channel.send(content=feedback_message, view=button.DoneButton(actioned_channel))
result = embed.success_embed("Feedback sent")
except Exception as e:
result = embed.error_embed("Feedback couldn't be sent caused by: " + e)
Expand All @@ -115,7 +339,6 @@ async def self(interaction: discord.Interaction, message: str):
scheduler_thread = threading.Thread(target=util.periodic_function,
args=(scheduler, 3600, util.create_json_movelists, CHARACTER_LIST_PATH))
scheduler_thread.start()

hei.run(discord_token)

except Exception as e:
Expand Down
13 changes: 13 additions & 0 deletions src/module/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@ def periodic_function(scheduler, interval, function, character_list_path: str):
while True:
scheduler.enter(interval, 1, function, (character_list_path,))
scheduler.run()


def create_character_tree_commands(character_list):
f = open("out.txt", "a")
for c in character_list:
fd_command = ("@tree.command(name=\"{}\", description=\"Frame data from {}\") \n async def self("
"interaction: discord.Interaction, move: str): \n\tif not (util.is_user_blacklisted("
"interaction.user.id) or util.is_author_newly_created(interaction)): \n\t\tembed = "
"create_frame_data_embed(\"{}\", move) \n\t\tawait interaction.response.send_message(embed=embed,"
"ephemeral=False) \n").format(c.name, c.name, c.name)
f.write(fd_command + "\n")
f.close()
print("done")

0 comments on commit ead0869

Please sign in to comment.