Changed the List function to use project name instead of project id

This commit is contained in:
Dan
2024-05-04 19:35:01 -04:00
parent e8ce8575e8
commit 80becf1961
2 changed files with 13 additions and 2 deletions

View File

@@ -72,13 +72,18 @@ class TaskCommands(app_commands.Group):
@app_commands.command(name="list", description="List tasks for a project.")
async def list_tasks(self, interaction: discord.Interaction, project_id: int):
try:
project_name = await get_project_name(project_id)
if not project_name:
await interaction.response.send_message(f"No project found with ID {project_id}.", ephemeral=True)
return
tasks = await list_tasks_for_project(project_id)
if tasks:
message = "\n".join([f"ID: {id}, Description: {description}, Assignee: {assignee}, Deadline: {deadline}, Status: {status}, Priority: {priority}"
for id, description, assignee, deadline, status, priority in tasks])
await interaction.response.send_message(f"Tasks for Project ID {project_id}:\n{message}")
await interaction.response.send_message(f"Tasks for Project '{project_name}':\n{message}")
else:
await interaction.response.send_message(f"No tasks found for project ID {project_id}.")
await interaction.response.send_message(f"No tasks found for project '{project_name}'.")
except Exception as e:
await interaction.response.send_message(f"Failed to retrieve tasks for project ID {project_id}.", ephemeral=True)
logger.error(f"Error in list_tasks: {e}")