Added a Char Limit to the report function. Updated the tasks to now inlcude choices

This commit is contained in:
Dan
2024-05-05 20:44:03 -04:00
parent bb5c034309
commit b904b1087d
2 changed files with 34 additions and 4 deletions

View File

@ -48,12 +48,24 @@ class ProjectCommands(app_commands.Group):
await interaction.response.send_message(f"Whoops! I failed to remove the project. Error: {e}", ephemeral=True) await interaction.response.send_message(f"Whoops! I failed to remove the project. Error: {e}", ephemeral=True)
logger.error(f"Preparation error in remove_project_command for Project ID {project_id}: {e}") logger.error(f"Preparation error in remove_project_command for Project ID {project_id}: {e}")
class TaskCommands(app_commands.Group): class TaskCommands(app_commands.Group):
def __init__(self): def __init__(self):
super().__init__(name="task", description="Manage tasks.") super().__init__(name="task", description="Manage tasks.")
@app_commands.command(name="add", description="Add a new task to a project.") @app_commands.command(name="add", description="Add a new task to a project.")
@app_commands.choices(priority=[
app_commands.Choice(name="Low", value="Low"),
app_commands.Choice(name="Medium", value="Medium"),
app_commands.Choice(name="High", value="High")
app_commands.Choice(name="Critical", value="Critical")
], status=[
app_commands.Choice(name="Not Started", value="Not Started"),
app_commands.Choice(name="In Progress", value="In Progress"),
app_commands.Choice(name="Blocked", value="Blocked"),
app_commands.Choice(name="In Testing", value="In Testing"),
app_commands.Choice(name="Needs Review", value="Needs Review"),
app_commands.Choice(name="Completed", value="Completed")
])
async def add_task(self, interaction: discord.Interaction, project_name: str, description: str, assignee: str, deadline: str, status: str, priority: str, reminder_time: str = None): async def add_task(self, interaction: discord.Interaction, project_name: str, description: str, assignee: str, deadline: str, status: str, priority: str, reminder_time: str = None):
try: try:
datetime.strptime(deadline, "%m/%d/%Y") # Validate deadline date format datetime.strptime(deadline, "%m/%d/%Y") # Validate deadline date format
@ -82,6 +94,19 @@ class TaskCommands(app_commands.Group):
logger.error(f"Unexpected error in add_task: {e}") logger.error(f"Unexpected error in add_task: {e}")
@app_commands.command(name="update", description="Update an existing task.") @app_commands.command(name="update", description="Update an existing task.")
@app_commands.choices(priority=[
app_commands.Choice(name="Low", value="Low"),
app_commands.Choice(name="Medium", value="Medium"),
app_commands.Choice(name="High", value="High")
app_commands.Choice(name="Critical", value="Critical")
], status=[
app_commands.Choice(name="Not Started", value="Not Started"),
app_commands.Choice(name="In Progress", value="In Progress"),
app_commands.Choice(name="Blocked", value="Blocked"),
app_commands.Choice(name="In Testing", value="In Testing"),
app_commands.Choice(name="Needs Review", value="Needs Review"),
app_commands.Choice(name="Completed", value="Completed")
])
async def update_task_command(self, interaction: discord.Interaction, task_id: int, description: str, assignee: str, deadline: str, status: str, priority: str, reminder_time: str = None): async def update_task_command(self, interaction: discord.Interaction, task_id: int, description: str, assignee: str, deadline: str, status: str, priority: str, reminder_time: str = None):
try: try:
datetime.strptime(deadline, "%m/%d/%Y") # Validate deadline date format datetime.strptime(deadline, "%m/%d/%Y") # Validate deadline date format

View File

@ -33,10 +33,15 @@ class Nessa(discord.Client):
@self.tree.command(name="report_issue", description="Send an anonymous issue report.") @self.tree.command(name="report_issue", description="Send an anonymous issue report.")
async def report_issue(interaction: discord.Interaction, message: str): async def report_issue(interaction: discord.Interaction, message: str):
# Check if the message exceeds 1000 characters
if len(message) > 1000:
await interaction.response.send_message("Wowie, that's a long message there. Chief asked for messages to be no longer than 1000 characters. Please shorten it and try again.", ephemeral=True)
return
# Your Discord user ID # Your Discord user ID
your_user_id = OWNER_ID your_user_id = OWNER_ID # Make sure OWNER_ID is defined somewhere in your code
# Fetch your user object using your ID # Fetch your user object using your ID
owner = await bot.fetch_user(your_user_id) owner = await self.fetch_user(your_user_id)
# Send the DM to you # Send the DM to you
await owner.send(f"Hey Chief, I got a report for you: {message}") await owner.send(f"Hey Chief, I got a report for you: {message}")
# Respond to the user to confirm the message has been sent # Respond to the user to confirm the message has been sent