Skip to content

Commit

Permalink
Add done button for each feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
TLNBS2405 committed Dec 30, 2023
1 parent 2454e94 commit 56ea5db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from src.module import util
from src.module import character
from src.resources import const
from src.module import button

from threading import Thread

Expand Down Expand Up @@ -48,8 +49,10 @@ async def on_ready(self):
logger.error(f'{time_now} \n Error: {e}')



@tree.command(name="fd", description="Frame data from a character move", guild=discord.Object("645011181739835397"))
async def self(interaction: discord.Interaction, character_name: str, move: str):

original_character_name = character_name
original_move = move
character_name = util.correct_character_name(original_character_name.lower())
Expand All @@ -67,6 +70,7 @@ async def self(interaction: discord.Interaction, character_name: str, move: str)
if character_move:
move_embed = embed.move_embed(character, character_move)
await interaction.response.send_message(embed=move_embed, ephemeral=False)

else:
similar_moves = json_movelist_reader.get_similar_moves(original_move, move_list)
similar_moves_embed = embed.similar_moves_embed(similar_moves, character_name)
Expand All @@ -93,20 +97,23 @@ def is_author_newly_created(interaction):

@tree.command(name="feedback", description="Send feedback incase of wrong data",
guild=discord.Object("645011181739835397"))
@discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary, emoji="😎")
async def self(interaction: discord.Interaction, message: str):

if not (is_author_blacklisted(interaction.user.id) or is_author_newly_created(interaction)):
try:
feedback_message = "Feedback from **{}** with ID **{}** in **{}** \n- {}\n".format(str(interaction.user.name), interaction.user.id,
interaction.guild, message)
channel = client.get_channel(feedback_channel_id)
await channel.send(feedback_message)
await channel.send(content=feedback_message,view=button.DoneButton())
result = embed.success_embed("Feedback sent")
except Exception as e:
result = embed.error_embed("Feedback couldn't be sent caused by: " + e)

await interaction.response.send_message(embed=result, ephemeral=True)



def create_json_movelists(character_list_path: str) -> List[character.Character]:
with open(character_list_path) as file:
all_characters = json.load(file)
Expand Down
10 changes: 10 additions & 0 deletions src/module/button.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import discord


class DoneButton(discord.ui.View):
def __init__(self):
super().__init__()

@discord.ui.button(label="Done", style=discord.ButtonStyle.green)
async def done(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.message.delete()

0 comments on commit 56ea5db

Please sign in to comment.