diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index 58b9c2733..dba8ca804 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -50,9 +50,10 @@ func (t TicketUserError) Error() string { } const ( - ErrNoTicketCateogry TicketUserError = "No category for ticket channels set" - ErrTitleTooLong TicketUserError = "Title is too long (max 90 characters.) Please shorten it down, you can add more details in the ticket after it has been created" - ErrMaxOpenTickets TicketUserError = "You're currently in over 10 open tickets on this server, please close some of the ones you're in." + ErrNoTicketCategory TicketUserError = "No category for ticket channels set" + ErrTitleTooLong TicketUserError = "Title is too long (max 90 characters.) Please shorten it down, you can add more details in the ticket after it has been created" + ErrMaxOpenTickets TicketUserError = "You're currently in over 10 open tickets on this server, please close some of the ones you're in." + ErrMaxCategoryChannels TicketUserError = "Max channels in category reached (50)" ) const ( @@ -62,7 +63,18 @@ const ( func CreateTicket(ctx context.Context, gs *dstate.GuildSet, ms *dstate.MemberState, conf *models.TicketConfig, topic string, checkMaxTickets, executedByCommandTemplate bool) (*dstate.GuildSet, *models.Ticket, error) { if gs.GetChannel(conf.TicketsChannelCategory) == nil { - return gs, nil, ErrNoTicketCateogry + return gs, nil, ErrNoTicketCategory + } + + categoryChannels := 0 + for _, v := range gs.Channels { + if v.ParentID == conf.TicketsChannelCategory { + categoryChannels++ + } + + if categoryChannels == 50 { + return gs, nil, ErrMaxCategoryChannels + } } if hasPerms, _ := bot.BotHasPermissionGS(gs, conf.TicketsChannelCategory, InTicketPerms); !hasPerms {