From 04687c91397f1eee2ff07dce1a41aaab33775b81 Mon Sep 17 00:00:00 2001 From: Wolveric Date: Mon, 30 Dec 2024 12:37:16 +0000 Subject: [PATCH 1/6] tickets: Switch to variable for closing message It has been highlighted by one uses, that the lack of granularity from the closing message, concerns them. Consequently, this commit updates the ticket closing function, to use a variable for the closing message, as opposed to the const. msg. used currently. This acts largely as a prelude to the subsequent commits, which will add more to the message, conditionally, based on the logs YAGPDB will create. --- tickets/tickets_bot.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index 58b9c2733..3a96c28ed 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -193,8 +193,6 @@ func openTicket(ctx context.Context, gs *dstate.GuildSet, ms *dstate.MemberState var closingTickets = make(map[int64]bool) var closingTicketsLock sync.Mutex -const closingTicketMsg = "Closing ticket, creating logs, downloading attachments and so on.\nThis may take a while if the ticket is big." - func closeTicket(gs *dstate.GuildSet, currentTicket *Ticket, ticketCS *dstate.ChannelState, conf *models.TicketConfig, member *discordgo.User, reason string, ctx context.Context) (string, error) { // protect again'st calling close multiple times at the sime time closingTicketsLock.Lock() @@ -210,8 +208,10 @@ func closeTicket(gs *dstate.GuildSet, currentTicket *Ticket, ticketCS *dstate.Ch closingTicketsLock.Unlock() }() + closingMsg := "Closing ticket." + // send a heads up that this can take a while - common.BotSession.ChannelMessageSend(currentTicket.Ticket.ChannelID, closingTicketMsg) + common.BotSession.ChannelMessageSend(currentTicket.Ticket.ChannelID, closingMsg) currentTicket.Ticket.ClosedAt.Time = time.Now() currentTicket.Ticket.ClosedAt.Valid = true From 2535de2db833f87131669cd9fe687da7c4aa9ee9 Mon Sep 17 00:00:00 2001 From: Wolveric Date: Mon, 30 Dec 2024 12:44:24 +0000 Subject: [PATCH 2/6] tickets: Replace closing msg. when creating logs This commit adds the initial condition for updating the closing message, if logs will be created. For both conditions, we want to add a prompt that closing the ticket may take a while, if logs are being created. So this change, creates a builder from the initial message, and adds this reminder, if logs would be created. --- tickets/tickets_bot.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index 3a96c28ed..f5773892b 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -210,6 +210,16 @@ func closeTicket(gs *dstate.GuildSet, currentTicket *Ticket, ticketCS *dstate.Ch closingMsg := "Closing ticket." + // We only need to build up a more detailed closing msg. + // if we're creating logs. + if conf.TicketsUseTXTTranscripts || conf.DownloadAttachments { + var closingMsgBuilder strings.Builder + closingMsgBuilder.WriteString(closingMsg) + + closingMsgBuilder.WriteString("\nThis may take a while, if the ticket is long.") + closingMsg = closingMsgBuilder.String() + } + // send a heads up that this can take a while common.BotSession.ChannelMessageSend(currentTicket.Ticket.ChannelID, closingMsg) From 04452e9da5a6f644b2f745a328c538837ce846b6 Mon Sep 17 00:00:00 2001 From: Wolveric Date: Mon, 30 Dec 2024 12:52:49 +0000 Subject: [PATCH 3/6] tickets: Add log creation reminder to closing msg. --- tickets/tickets_bot.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index f5773892b..40e888dc2 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -216,6 +216,10 @@ func closeTicket(gs *dstate.GuildSet, currentTicket *Ticket, ticketCS *dstate.Ch var closingMsgBuilder strings.Builder closingMsgBuilder.WriteString(closingMsg) + if conf.TicketsUseTXTTranscripts { + closingMsgBuilder.WriteString("\nCreating logs.") + } + closingMsgBuilder.WriteString("\nThis may take a while, if the ticket is long.") closingMsg = closingMsgBuilder.String() } From f6938d75c78408373d1683bc879c1d18449ebc6c Mon Sep 17 00:00:00 2001 From: Wolveric Date: Mon, 30 Dec 2024 13:02:19 +0000 Subject: [PATCH 4/6] tickets: Add attachment download closing prompt --- tickets/tickets_bot.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index 40e888dc2..01a3c2163 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -220,6 +220,10 @@ func closeTicket(gs *dstate.GuildSet, currentTicket *Ticket, ticketCS *dstate.Ch closingMsgBuilder.WriteString("\nCreating logs.") } + if conf.DownloadAttachments { + closingMsgBuilder.WriteString("\nDownloading attachments.") + } + closingMsgBuilder.WriteString("\nThis may take a while, if the ticket is long.") closingMsg = closingMsgBuilder.String() } From 333d8794badbdd58e80a9a72c3873dee0903ac29 Mon Sep 17 00:00:00 2001 From: Wolveric Date: Mon, 30 Dec 2024 15:28:05 +0000 Subject: [PATCH 5/6] tickets: Drop ticket closing response from buttons Due to the design of the ticket button handling functions, closing tickets resulted in the ticket closing prompt being doubled up on with an ephemeral response. For this reason, these prompts served little purpose, as a prompt was already created as a normal message, as part of the `tickets.closeTicket` function. Consquently, this effectively just introduced a dependency on the `tickets.closingTicketMsg` constant, that this series of commits, served to remove. --- tickets/tickets_bot.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index 01a3c2163..3e8580c6b 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -316,13 +316,6 @@ func handleButton(evt *eventsystem.EventData, ic *discordgo.InteractionCreate, m } } - common.BotSession.CreateInteractionResponse(ic.ID, ic.Token, &discordgo.InteractionResponse{ - Type: discordgo.InteractionResponseChannelMessageWithSource, - Data: &discordgo.InteractionResponseData{ - Content: closingTicketMsg, - Flags: discordgo.MessageFlagsEphemeral, - }, - }) response.Data.Content, err = closeTicket(evt.GS, currentTicket, currentChannel, conf, member.User, "", evt.Context()) case "close-reason": response = &discordgo.InteractionResponse{ @@ -378,13 +371,6 @@ func handleModal(evt *eventsystem.EventData, ic *discordgo.InteractionCreate, me } } - common.BotSession.CreateInteractionResponse(ic.ID, ic.Token, &discordgo.InteractionResponse{ - Type: discordgo.InteractionResponseChannelMessageWithSource, - Data: &discordgo.InteractionResponseData{ - Content: closingTicketMsg, - Flags: discordgo.MessageFlagsEphemeral, - }, - }) response.Data.Content, err = closeTicket(evt.GS, currentTicket, currentChannel, conf, member.User, value, evt.Context()) } From f81416f7aa1376126eace81e1efdc782e3f31da7 Mon Sep 17 00:00:00 2001 From: "Willow \"Wolveric\" Catkin" <72138328+Wolveric@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:26:01 +0000 Subject: [PATCH 6/6] tickets: Remove unnecessary comma from closing prompt Co-authored-by: Joseph Liu --- tickets/tickets_bot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index 3e8580c6b..7597886b5 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -224,7 +224,7 @@ func closeTicket(gs *dstate.GuildSet, currentTicket *Ticket, ticketCS *dstate.Ch closingMsgBuilder.WriteString("\nDownloading attachments.") } - closingMsgBuilder.WriteString("\nThis may take a while, if the ticket is long.") + closingMsgBuilder.WriteString("\nThis may take a while if the ticket is long.") closingMsg = closingMsgBuilder.String() }