Skip to content

Commit

Permalink
first pass at help command
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Philion committed Aug 12, 2024
1 parent 24f4b23 commit 782ab6e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 7 additions & 2 deletions cog_tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ async def assign(self, ctx: discord.ApplicationContext, ticket_id:int):
await ctx.respond(f"Ticket {ticket_id} not found.") # print error


@ticket.command(name="edit", description="Edit a ticket")
@option("ticket_id", description="ticket ID")
# command disabled
#@ticket.command(name="edit", description="Edit a ticket")
#@option("ticket_id", description="ticket ID")
async def edit(self, ctx:discord.ApplicationContext, ticket_id: int):
"""Edit the fields of a ticket"""
# check team? admin?, provide reasonable error msg.
Expand Down Expand Up @@ -539,3 +540,7 @@ async def subject(self, ctx: discord.ApplicationContext, ticket_id:int, subject:
updated = self.bot.redmine.ticket_mgr.update(ticket_id, fields, user.login)

await ctx.respond(f"Updated {ticket_link} with new subject => {updated.subject}") #TODO return ticket summary.

@ticket.command(name="help", description="Display hepl about ticket management")
async def help(self, ctx: discord.ApplicationContext):
await ctx.respond(embed=self.bot.formatter.help_embed(ctx))
18 changes: 16 additions & 2 deletions formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ async def print_tickets(self, title:str, tickets:list[Ticket], ctx:discord.Appli
await ctx.respond(msg)


async def print_ticket(self, ticket, ctx):
async def print_ticket(self, ticket, ctx:discord.ApplicationContext):
await ctx.respond(embed=self.ticket_embed(ctx, ticket))

#msg = self.format_ticket_details(ticket)
#if len(msg) > MAX_MESSAGE_LEN:
# log.warning("message over {MAX_MESSAGE_LEN} chars. truncing.")
Expand Down Expand Up @@ -272,6 +271,21 @@ def ticket_embed(self, ctx: discord.ApplicationContext, ticket:Ticket) -> discor
return embed


def help_embed(self, ctx: discord.ApplicationContext) -> discord.Embed:
"""Build an embed panel with help"""
embed = discord.Embed(
title="Ticket Help",
description="Managing Redmine tickets with Discord commands",
)

embed.add_field(name="`/scn add <redmine-id>`", value="Register your Discord account with a Redmine account *<redmine-id>*. If that Redmine account doesn't exist, a new account will be registered for admin approval.", inline=False)
embed.add_field(name="`/ticket query me`", value="List *your* tickets.", inline=False)
embed.add_field(name="`/ticket subject <#>`", value="Update the subject of ticket *<#>*", inline=False)
embed.add_field(name="`/ticket create <subject>`", value="Create a new ticket with the subject *<subject>*.", inline=False)

return embed


def main():
pass
#redmine = Client.fromenv()
Expand Down

0 comments on commit 782ab6e

Please sign in to comment.