v0.2.1
This commit is contained in:
@@ -70,6 +70,49 @@ func (m *Manager) DeleteClaimMessage(ctx context.Context, s *discordgo.Session,
|
||||
m.claims.Delete(ctx, ticketID) //nolint
|
||||
}
|
||||
|
||||
// MarkClaimed edits the claim channel message to show the claimed state (green embed, no button,
|
||||
// no ping) and removes it from tracking so the close flow leaves it untouched.
|
||||
func (m *Manager) MarkClaimed(ctx context.Context, s *discordgo.Session, ticket *db.Ticket, staffID string) {
|
||||
cm, err := m.claims.Get(ctx, ticket.ID)
|
||||
if err != nil || cm == nil {
|
||||
m.claims.Delete(ctx, ticket.ID) //nolint
|
||||
return
|
||||
}
|
||||
cfg := m.cfg.Get()
|
||||
claimChannelID := cfg.Bot.ClaimChannel
|
||||
if claimChannelID == "" {
|
||||
m.claims.Delete(ctx, ticket.ID) //nolint
|
||||
return
|
||||
}
|
||||
|
||||
claimedEmbed := &discordgo.MessageEmbed{
|
||||
Title: "Ticket pris en charge",
|
||||
Color: 0x57f287,
|
||||
Fields: []*discordgo.MessageEmbedField{
|
||||
{Name: "Numéro", Value: fmt.Sprintf("#%04d", ticket.TicketNumber), Inline: true},
|
||||
{Name: "Type", Value: ticket.Type, Inline: true},
|
||||
{Name: "Auteur", Value: fmt.Sprintf("<@%s>", ticket.UserID), Inline: true},
|
||||
{Name: "Pris par", Value: fmt.Sprintf("<@%s>", staffID), Inline: true},
|
||||
{Name: "Salon", Value: fmt.Sprintf("<#%s>", ticket.ChannelID), Inline: true},
|
||||
},
|
||||
Timestamp: time.Now().UTC().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
content := ""
|
||||
emptyComponents := []discordgo.MessageComponent{}
|
||||
if _, editErr := s.ChannelMessageEditComplex(&discordgo.MessageEdit{
|
||||
Channel: claimChannelID,
|
||||
ID: cm.MessageID,
|
||||
Content: &content,
|
||||
Embeds: &[]*discordgo.MessageEmbed{claimedEmbed},
|
||||
Components: &emptyComponents,
|
||||
}); editErr != nil {
|
||||
slog.Warn("claim: edit message to claimed", "ticket_id", ticket.ID, "err", editErr)
|
||||
}
|
||||
|
||||
m.claims.Delete(ctx, ticket.ID) //nolint
|
||||
}
|
||||
|
||||
func (m *Manager) startReupLoop(s *discordgo.Session, ticket *db.Ticket, lastReupAt time.Time) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
m.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user