From 86b6d3ae20407f9dd7680de509e11d0f8dd0be78 Mon Sep 17 00:00:00 2001 From: biast12 Date: Sun, 29 Jun 2025 14:53:28 +0200 Subject: [PATCH] Refactor component variable names and improve blacklist logic Renames local variables for component slices to 'innerComponents' across multiple files for clarity and consistency. Refactors the blacklist command to separate user and role blacklist logic into dedicated handler functions, unifies response formatting, and fixes role blacklist count checks. Updates help and welcome message logic to use new container utilities. Adds a new i18n message for tickets started from messages with no content and improves the premium footer link formatting. --- bot/button/handlers/viewsurvey.go | 6 +- .../impl/admin/adminlistguildentitlements.go | 6 +- .../impl/admin/adminlistuserentitlements.go | 6 +- bot/command/impl/admin/adminwhitelabeldata.go | 4 +- bot/command/impl/general/jumptotop.go | 4 +- bot/command/impl/settings/blacklist.go | 212 +++++++++--------- bot/command/impl/settings/premium.go | 6 +- bot/command/impl/tickets/startticket.go | 18 +- bot/logic/closeembed.go | 6 +- bot/logic/help.go | 39 ++-- bot/logic/viewstaff.go | 16 +- bot/logic/welcomemessage.go | 6 +- bot/utils/messageutils.go | 2 +- i18n/messages.go | 37 ++- 14 files changed, 186 insertions(+), 182 deletions(-) diff --git a/bot/button/handlers/viewsurvey.go b/bot/button/handlers/viewsurvey.go index b30397ff..e90a2066 100644 --- a/bot/button/handlers/viewsurvey.go +++ b/bot/button/handlers/viewsurvey.go @@ -120,7 +120,7 @@ func (h *ViewSurveyHandler) Execute(ctx *context.ButtonContext) { buttons = append(buttons, logic.TranscriptLinkElement(ticket.HasTranscript)(ctx.Worker(), ticket)...) buttons = append(buttons, logic.ThreadLinkElement(ticket.ChannelId != nil && ticket.IsThread)(ctx.Worker(), ticket)...) - comps := []component.Component{ + innerComponents := []component.Component{ component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("## Exit Survey for %s", opener.GlobalName)}), component.BuildSeparator(component.Separator{}), component.BuildTextDisplay(component.TextDisplay{ @@ -129,11 +129,11 @@ func (h *ViewSurveyHandler) Execute(ctx *context.ButtonContext) { } if len(buttons) > 0 { - comps = append(comps, component.BuildActionRow(buttons...)) + innerComponents = append(innerComponents, component.BuildActionRow(buttons...)) } ctx.ReplyWith(command.NewMessageResponseWithComponents(utils.Slice(component.BuildContainer(component.Container{ AccentColor: utils.Ptr(ctx.GetColour(customisation.Green)), - Components: comps, + Components: innerComponents, })))) } diff --git a/bot/command/impl/admin/adminlistguildentitlements.go b/bot/command/impl/admin/adminlistguildentitlements.go index 767b282d..0bb4dc72 100644 --- a/bot/command/impl/admin/adminlistguildentitlements.go +++ b/bot/command/impl/admin/adminlistguildentitlements.go @@ -97,7 +97,7 @@ func (AdminListGuildEntitlementsCommand) Execute(ctx registry.CommandContext, gu return } - values := []component.Component{} + innerComponents := []component.Component{} for _, entitlement := range entitlements { value := fmt.Sprintf( @@ -110,7 +110,7 @@ func (AdminListGuildEntitlementsCommand) Execute(ctx registry.CommandContext, gu entitlement.SkuPriority, ) - values = append(values, component.BuildTextDisplay(component.TextDisplay{Content: value})) + innerComponents = append(innerComponents, component.BuildTextDisplay(component.TextDisplay{Content: value})) } ctx.ReplyWith(command.NewMessageResponseWithComponents([]component.Component{ @@ -118,7 +118,7 @@ func (AdminListGuildEntitlementsCommand) Execute(ctx registry.CommandContext, gu ctx, customisation.Orange, i18n.Admin, - values, + innerComponents, ), })) } diff --git a/bot/command/impl/admin/adminlistuserentitlements.go b/bot/command/impl/admin/adminlistuserentitlements.go index 12885d45..13b5e241 100644 --- a/bot/command/impl/admin/adminlistuserentitlements.go +++ b/bot/command/impl/admin/adminlistuserentitlements.go @@ -50,7 +50,7 @@ func (AdminListUserEntitlementsCommand) Execute(ctx registry.CommandContext, use return } - values := []component.Component{} + innerComponents := []component.Component{} for _, entitlement := range entitlements { @@ -64,7 +64,7 @@ func (AdminListUserEntitlementsCommand) Execute(ctx registry.CommandContext, use entitlement.SkuPriority, ) - values = append(values, component.BuildTextDisplay(component.TextDisplay{Content: value})) + innerComponents = append(innerComponents, component.BuildTextDisplay(component.TextDisplay{Content: value})) } ctx.ReplyWith(command.NewMessageResponseWithComponents([]component.Component{ @@ -72,7 +72,7 @@ func (AdminListUserEntitlementsCommand) Execute(ctx registry.CommandContext, use ctx, customisation.Orange, i18n.Admin, - values, + innerComponents, ), })) } diff --git a/bot/command/impl/admin/adminwhitelabeldata.go b/bot/command/impl/admin/adminwhitelabeldata.go index f47b9497..7d16832c 100644 --- a/bot/command/impl/admin/adminwhitelabeldata.go +++ b/bot/command/impl/admin/adminwhitelabeldata.go @@ -127,7 +127,7 @@ func (AdminWhitelabelDataCommand) Execute(ctx registry.CommandContext, userId ui tds += fmt.Sprintf("**%s:** %s\n", fields[i].Name, fields[i].Value) } - comps := []component.Component{ + innerComponents := []component.Component{ component.BuildTextDisplay(component.TextDisplay{Content: "## Whitelabel"}), component.BuildSeparator(component.Separator{}), component.BuildTextDisplay(component.TextDisplay{ @@ -137,6 +137,6 @@ func (AdminWhitelabelDataCommand) Execute(ctx registry.CommandContext, userId ui ctx.ReplyWith(command.NewMessageResponseWithComponents(utils.Slice(component.BuildContainer(component.Container{ AccentColor: utils.Ptr(ctx.GetColour(customisation.Green)), - Components: comps, + Components: innerComponents, })))) } diff --git a/bot/command/impl/general/jumptotop.go b/bot/command/impl/general/jumptotop.go index 8c5a5b8c..336c9617 100644 --- a/bot/command/impl/general/jumptotop.go +++ b/bot/command/impl/general/jumptotop.go @@ -52,7 +52,7 @@ func (JumpToTopCommand) Execute(ctx registry.CommandContext) { } messageLink := fmt.Sprintf("https://discord.com/channels/%d/%d/%d", ctx.GuildId(), ctx.ChannelId(), *ticket.WelcomeMessageId) - components := []component.Component{ + innerComponents := []component.Component{ component.BuildTextDisplay(component.TextDisplay{Content: ctx.GetMessage(i18n.MessageJumpToTopContent)}), component.BuildSeparator(component.Separator{Divider: utils.Ptr(false)}), component.BuildActionRow(component.BuildButton(component.Button{ @@ -64,7 +64,7 @@ func (JumpToTopCommand) Execute(ctx registry.CommandContext) { } if _, err := ctx.ReplyWith(command.NewEphemeralMessageResponseWithComponents([]component.Component{ - utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleJumpToTop, components), + utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleJumpToTop, innerComponents), })); err != nil { ctx.HandleError(err) return diff --git a/bot/command/impl/settings/blacklist.go b/bot/command/impl/settings/blacklist.go index f30d0526..81f29ffa 100644 --- a/bot/command/impl/settings/blacklist.go +++ b/bot/command/impl/settings/blacklist.go @@ -52,138 +52,148 @@ func (BlacklistCommand) Execute(ctx registry.CommandContext, id uint64) { return } - if mentionableType == context.MentionableTypeUser { - member, err := ctx.Worker().GetGuildMember(ctx.GuildId(), id) - if err != nil { - ctx.HandleError(err) - return - } + switch mentionableType { + case context.MentionableTypeUser: + BlacklistCommand{}.handleUserBlacklist(ctx, id, usageEmbed) + case context.MentionableTypeRole: + BlacklistCommand{}.handleRoleBlacklist(ctx, id, usageEmbed) + default: + ctx.HandleError(fmt.Errorf("invalid mentionable type")) + } +} + +func (BlacklistCommand) handleUserBlacklist(ctx registry.CommandContext, id uint64, usageEmbed model.Field) { + member, err := ctx.Worker().GetGuildMember(ctx.GuildId(), id) + if err != nil { + ctx.HandleError(err) + return + } + + if ctx.UserId() == id { + ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistSelf, utils.ToSlice(usageEmbed)) + return + } - if ctx.UserId() == id { - ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistSelf, utils.ToSlice(usageEmbed)) + permLevel, err := permission.GetPermissionLevel(ctx, utils.ToRetriever(ctx.Worker()), member, ctx.GuildId()) + if err != nil { + ctx.HandleError(err) + return + } + + if permLevel > permission.Everyone { + ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistStaff, utils.ToSlice(usageEmbed)) + return + } + + isBlacklisted, err := dbclient.Client.Blacklist.IsBlacklisted(ctx, ctx.GuildId(), id) + if err != nil { + sentry.ErrorWithContext(err, ctx.ToErrorContext()) + return + } + + if isBlacklisted { + if err := dbclient.Client.Blacklist.Remove(ctx, ctx.GuildId(), id); err != nil { + ctx.HandleError(err) return } - - permLevel, err := permission.GetPermissionLevel(ctx, utils.ToRetriever(ctx.Worker()), member, ctx.GuildId()) + } else { + // Check user blacklist limit + count, err := dbclient.Client.Blacklist.GetBlacklistedCount(ctx, ctx.GuildId()) if err != nil { ctx.HandleError(err) return } - if permLevel > permission.Everyone { - ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistStaff, utils.ToSlice(usageEmbed)) + if count >= 250 { + ctx.Reply(customisation.Red, i18n.Error, i18n.MessageBlacklistLimit, 250) return } - isBlacklisted, err := dbclient.Client.Blacklist.IsBlacklisted(ctx, ctx.GuildId(), id) - if err != nil { - sentry.ErrorWithContext(err, ctx.ToErrorContext()) + if err := dbclient.Client.Blacklist.Add(ctx, ctx.GuildId(), member.User.Id); err != nil { + ctx.HandleError(err) return } + } - blacklistMsg := i18n.MessageBlacklistRemove - - if isBlacklisted { - if err := dbclient.Client.Blacklist.Remove(ctx, ctx.GuildId(), id); err != nil { - ctx.HandleError(err) - return - } - } else { - // Limit of 250 *users* - count, err := dbclient.Client.Blacklist.GetBlacklistedCount(ctx, ctx.GuildId()) - if err != nil { - ctx.HandleError(err) - return - } - - if count >= 250 { - ctx.Reply(customisation.Red, i18n.Error, i18n.MessageBlacklistLimit, 250) - return - } - - if err := dbclient.Client.Blacklist.Add(ctx, ctx.GuildId(), member.User.Id); err != nil { - ctx.HandleError(err) - return - } - blacklistMsg = i18n.MessageBlacklistAdd - } + BlacklistCommand{}.sendBlacklistResponse(ctx, id, isBlacklisted, true) +} - ctx.ReplyWith( - command.NewEphemeralMessageResponseWithComponents( - utils.Slice( - utils.BuildContainerRaw(ctx.GetColour(customisation.Green), ctx.GetMessage(i18n.TitleBlacklist), ctx.GetMessage(blacklistMsg, id), ctx.PremiumTier()), - ), - ), - ) - } else if mentionableType == context.MentionableTypeRole { - // Check if role is staff - isSupport, err := dbclient.Client.RolePermissions.IsSupport(ctx, id) - if err != nil { - ctx.HandleError(err) - return - } +func (BlacklistCommand) handleRoleBlacklist(ctx registry.CommandContext, id uint64, usageEmbed model.Field) { + // Check if role is support role + isSupport, err := dbclient.Client.RolePermissions.IsSupport(ctx, id) + if err != nil { + ctx.HandleError(err) + return + } + + if isSupport { + ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistStaff, utils.ToSlice(usageEmbed)) + return + } - if isSupport { - ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistStaff, utils.ToSlice(usageEmbed)) // TODO: Does this need a new message? + // Check if role is part of any support team + isSupport, err = dbclient.Client.SupportTeamRoles.IsSupport(ctx, ctx.GuildId(), id) + if err != nil { + ctx.HandleError(err) + return + } + + if isSupport { + ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistStaff, utils.ToSlice(usageEmbed)) + return + } + + isBlacklisted, err := dbclient.Client.RoleBlacklist.IsBlacklisted(ctx, ctx.GuildId(), id) + if err != nil { + ctx.HandleError(err) + return + } + + if isBlacklisted { + if err := dbclient.Client.RoleBlacklist.Remove(ctx, ctx.GuildId(), id); err != nil { + ctx.HandleError(err) return } - - // Check if staff is part of any team - isSupport, err = dbclient.Client.SupportTeamRoles.IsSupport(ctx, ctx.GuildId(), id) + } else { + // Check role blacklist limit - use RoleBlacklist instead of Blacklist + count, err := dbclient.Client.RoleBlacklist.GetBlacklistedCount(ctx, ctx.GuildId()) if err != nil { ctx.HandleError(err) return } - if isSupport { - ctx.ReplyWithFields(customisation.Red, i18n.Error, i18n.MessageBlacklistStaff, utils.ToSlice(usageEmbed)) // TODO: Does this need a new message? + if count >= 50 { + ctx.Reply(customisation.Red, i18n.Error, i18n.MessageBlacklistRoleLimit, 50) return } - isBlacklisted, err := dbclient.Client.RoleBlacklist.IsBlacklisted(ctx, ctx.GuildId(), id) - if err != nil { + if err := dbclient.Client.RoleBlacklist.Add(ctx, ctx.GuildId(), id); err != nil { ctx.HandleError(err) return } + } - blacklistMsg := i18n.MessageBlacklistRemoveRole - - if isBlacklisted { - if err := dbclient.Client.RoleBlacklist.Remove(ctx, ctx.GuildId(), id); err != nil { - ctx.HandleError(err) - return - } - } else { - // Limit of 50 *roles* - count, err := dbclient.Client.Blacklist.GetBlacklistedCount(ctx, ctx.GuildId()) - if err != nil { - ctx.HandleError(err) - return - } - - if count >= 50 { - ctx.Reply(customisation.Red, i18n.Error, i18n.MessageBlacklistRoleLimit, 50) - return - } - - if err := dbclient.Client.RoleBlacklist.Add(ctx, ctx.GuildId(), id); err != nil { - ctx.HandleError(err) - return - } - blacklistMsg = i18n.MessageBlacklistAddRole - - ctx.Reply(customisation.Green, i18n.TitleBlacklist, i18n.MessageBlacklistAddRole, id) - } + BlacklistCommand{}.sendBlacklistResponse(ctx, id, isBlacklisted, false) +} - ctx.ReplyWith( - command.NewEphemeralMessageResponseWithComponents( - utils.Slice( - utils.BuildContainerRaw(ctx.GetColour(customisation.Green), ctx.GetMessage(i18n.TitleBlacklist), ctx.GetMessage(blacklistMsg, id), ctx.PremiumTier()), - ), - ), - ) +func (BlacklistCommand) sendBlacklistResponse(ctx registry.CommandContext, id uint64, wasBlacklisted, isUser bool) { + blacklistMsg := i18n.MessageBlacklistAdd + if wasBlacklisted { + blacklistMsg = i18n.MessageBlacklistRemove + } + + var message string + if isUser { + message = fmt.Sprintf("<@%d> %s", id, ctx.GetMessage(blacklistMsg)) } else { - ctx.HandleError(fmt.Errorf("infallible")) - return + message = fmt.Sprintf("<@&%d> %s", id, ctx.GetMessage(blacklistMsg)) } + + ctx.ReplyWith( + command.NewEphemeralMessageResponseWithComponents( + utils.Slice( + utils.BuildContainerRaw(ctx.GetColour(customisation.Green), ctx.GetMessage(i18n.TitleBlacklist), message, ctx.PremiumTier()), + ), + ), + ) } diff --git a/bot/command/impl/settings/premium.go b/bot/command/impl/settings/premium.go index c764d96d..a4634abb 100644 --- a/bot/command/impl/settings/premium.go +++ b/bot/command/impl/settings/premium.go @@ -107,7 +107,7 @@ func (PremiumCommand) Execute(ctx registry.CommandContext) { keyEmoji = utils.BuildEmoji("🔑") } - components := []component.Component{ + innerComponents := []component.Component{ component.BuildSection(component.Section{ Components: utils.Slice( component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("## %s", ctx.GetMessage(i18n.TitlePremium))}), @@ -152,13 +152,13 @@ func (PremiumCommand) Execute(ctx registry.CommandContext) { } if ctx.PremiumTier() == premium.None { - components = utils.AddPremiumFooter(components) + innerComponents = utils.AddPremiumFooter(innerComponents) } ctx.ReplyWith( command.NewEphemeralMessageResponseWithComponents( utils.Slice(component.BuildContainer(component.Container{ - Components: components, + Components: innerComponents, AccentColor: utils.Ptr(ctx.GetColour(customisation.Green)), })), ), diff --git a/bot/command/impl/tickets/startticket.go b/bot/command/impl/tickets/startticket.go index f4db1e89..e77e4e3b 100644 --- a/bot/command/impl/tickets/startticket.go +++ b/bot/command/impl/tickets/startticket.go @@ -9,6 +9,7 @@ import ( "github.com/TicketsBot-cloud/database" "github.com/TicketsBot-cloud/gdl/objects/channel/message" "github.com/TicketsBot-cloud/gdl/objects/interaction" + "github.com/TicketsBot-cloud/gdl/objects/interaction/component" "github.com/TicketsBot-cloud/gdl/rest" "github.com/TicketsBot-cloud/gdl/rest/request" "github.com/TicketsBot-cloud/worker/bot/command" @@ -110,12 +111,19 @@ func (StartTicketCommand) Execute(ctx registry.CommandContext) { func sendTicketStartedFromMessage(ctx registry.CommandContext, ticket database.Ticket, msg message.Message) { // format messageLink := fmt.Sprintf("https://discord.com/channels/%d/%d/%d", ctx.GuildId(), ctx.ChannelId(), msg.Id) - contentFormatted := strings.ReplaceAll(utils.StringMax(msg.Content, 2048, "..."), "`", "\\`") - msgEmbed := utils.BuildContainer( - ctx, customisation.Green, i18n.Ticket, i18n.MessageTicketStartedFrom, - messageLink, msg.Author.Id, ctx.ChannelId(), contentFormatted, - ) + var msgEmbed component.Component + if msg.Content == "" { + msgEmbed = utils.BuildContainer( + ctx, customisation.Green, i18n.Ticket, i18n.MessageTicketStartedFromNoContent, + messageLink, + ) + } else { + msgEmbed = utils.BuildContainer( + ctx, customisation.Green, i18n.Ticket, i18n.MessageTicketStartedFrom, + messageLink, msg.Author.Id, ctx.ChannelId(), strings.ReplaceAll(utils.StringMax(msg.Content, 2048, "..."), "`", "\\`"), + ) + } if _, err := ctx.Worker().CreateMessageComplex(*ticket.ChannelId, rest.CreateMessageData{ Components: utils.Slice(msgEmbed), diff --git a/bot/logic/closeembed.go b/bot/logic/closeembed.go index de4f1f65..1dd7e028 100644 --- a/bot/logic/closeembed.go +++ b/bot/logic/closeembed.go @@ -265,7 +265,7 @@ func BuildCloseContainer( } transcriptLink := fmt.Sprintf("%s/manage/%d/transcripts/view/%d", config.Conf.Bot.DashboardUrl, ticket.GuildId, ticket.Id) - cc := []component.Component{ + innerComponents := []component.Component{ component.BuildSection(component.Section{ Accessory: component.BuildButton(component.Button{ Label: "View Transcript", @@ -283,12 +283,12 @@ func BuildCloseContainer( } if cmd.PremiumTier() == premium.None { - cc = utils.AddPremiumFooter(cc) + innerComponents = utils.AddPremiumFooter(innerComponents) } container := component.BuildContainer(component.Container{ AccentColor: utils.Ptr(cmd.GetColour(customisation.Green)), - Components: cc, + Components: innerComponents, }) return &container diff --git a/bot/logic/help.go b/bot/logic/help.go index 8724668b..eaac32a4 100644 --- a/bot/logic/help.go +++ b/bot/logic/help.go @@ -5,20 +5,18 @@ import ( "fmt" "sort" - "github.com/TicketsBot-cloud/common/premium" "github.com/TicketsBot-cloud/gdl/objects/interaction" "github.com/TicketsBot-cloud/gdl/objects/interaction/component" "github.com/TicketsBot-cloud/worker/bot/command" "github.com/TicketsBot-cloud/worker/bot/command/registry" "github.com/TicketsBot-cloud/worker/bot/customisation" "github.com/TicketsBot-cloud/worker/bot/utils" - "github.com/TicketsBot-cloud/worker/config" "github.com/TicketsBot-cloud/worker/i18n" "github.com/elliotchance/orderedmap" ) func BuildHelpMessage(category command.Category, page int, ctx registry.CommandContext, cmds map[string]registry.Command) (*component.Component, error) { - componentList := []component.Component{} + innerComponents := []component.Component{} permLevel, _ := ctx.UserPermissionLevel(ctx) @@ -69,7 +67,7 @@ func BuildHelpMessage(category command.Category, page int, ctx registry.CommandC continue } - componentList = append(componentList, + innerComponents = append(innerComponents, component.BuildTextDisplay(component.TextDisplay{ Content: registry.FormatHelp2(cmd, ctx.GuildId(), &commandId), }), @@ -80,38 +78,27 @@ func BuildHelpMessage(category command.Category, page int, ctx registry.CommandC // get certain commands for pagination componentsPerPage := 10 - if len(componentList) > componentsPerPage { + if len(innerComponents) > componentsPerPage { startIndex := (page - 1) * componentsPerPage endIndex := startIndex + componentsPerPage - if startIndex > len(componentList) { + if startIndex > len(innerComponents) { return nil, fmt.Errorf("page %d is out of range", page) } - if endIndex > len(componentList) { - endIndex = len(componentList) + if endIndex > len(innerComponents) { + endIndex = len(innerComponents) } - componentList = componentList[startIndex:endIndex] + innerComponents = innerComponents[startIndex:endIndex] } - if ctx.PremiumTier() == premium.None { - componentList = append(componentList, - component.BuildTextDisplay(component.TextDisplay{ - Content: fmt.Sprintf("Powered by %s", config.Conf.Bot.PoweredBy), - }), - ) - } - - container := component.BuildContainer(component.Container{ - Components: append([]component.Component{ - component.BuildTextDisplay(component.TextDisplay{ - Content: fmt.Sprintf("## %s\n-# %s", ctx.GetMessage(i18n.TitleHelp), category), - }), - component.BuildSeparator(component.Separator{}), - }, componentList...), - AccentColor: utils.Ptr(ctx.GetColour(customisation.Green)), - }) + container := utils.BuildContainerNoLocale( + ctx, + customisation.Green, + fmt.Sprintf("%s\n-# %s", ctx.GetMessage(i18n.TitleHelp), category), + innerComponents, + ) return &container, nil } diff --git a/bot/logic/viewstaff.go b/bot/logic/viewstaff.go index c2bc7121..26c1776a 100644 --- a/bot/logic/viewstaff.go +++ b/bot/logic/viewstaff.go @@ -62,7 +62,7 @@ func buildPaginatedField(cmd registry.CommandContext, entries []uint64, page int } func BuildViewStaffMessage(ctx context.Context, cmd registry.CommandContext, page int) (component.Component, int) { - comps := []component.Component{} + innerComponents := []component.Component{} adminUsers, _ := dbclient.Client.Permissions.GetAdmins(ctx, cmd.GuildId()) adminRoles, _ := dbclient.Client.RolePermissions.GetAdminRoles(ctx, cmd.GuildId()) @@ -90,8 +90,8 @@ func BuildViewStaffMessage(ctx context.Context, cmd registry.CommandContext, pag viewStaffRoleFormat, "", ) - comps = append(comps, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) - comps = append(comps, component.BuildSeparator(component.Separator{Divider: utils.Ptr(true), Spacing: utils.Ptr(1)})) + innerComponents = append(innerComponents, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) + innerComponents = append(innerComponents, component.BuildSeparator(component.Separator{Divider: utils.Ptr(true), Spacing: utils.Ptr(1)})) // Admin users label, value = buildPaginatedField( @@ -101,9 +101,9 @@ func BuildViewStaffMessage(ctx context.Context, cmd registry.CommandContext, pag viewStaffUserFormat, "", ) - comps = append(comps, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) + innerComponents = append(innerComponents, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) - comps = append(comps, component.BuildSeparator(component.Separator{Divider: utils.Ptr(true), Spacing: utils.Ptr(1)})) + innerComponents = append(innerComponents, component.BuildSeparator(component.Separator{Divider: utils.Ptr(true), Spacing: utils.Ptr(1)})) // Support roles label, value = buildPaginatedField( @@ -113,7 +113,7 @@ func BuildViewStaffMessage(ctx context.Context, cmd registry.CommandContext, pag viewStaffRoleFormat, "", ) - comps = append(comps, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) + innerComponents = append(innerComponents, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) // Support users if len(supportUsers) > 0 { @@ -124,10 +124,10 @@ func BuildViewStaffMessage(ctx context.Context, cmd registry.CommandContext, pag viewStaffUserFormat, cmd.GetMessage(i18n.MessageViewStaffSupportUsersWarn), ) - comps = append(comps, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) + innerComponents = append(innerComponents, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) } - container := utils.BuildContainerWithComponents(cmd, customisation.Green, i18n.MessageViewStaffTitle, comps) + container := utils.BuildContainerWithComponents(cmd, customisation.Green, i18n.MessageViewStaffTitle, innerComponents) return container, totalPages } diff --git a/bot/logic/welcomemessage.go b/bot/logic/welcomemessage.go index 9762d058..1b5432a2 100644 --- a/bot/logic/welcomemessage.go +++ b/bot/logic/welcomemessage.go @@ -61,19 +61,19 @@ func SendWelcomeMessage( fieldStr += fmt.Sprintf("**%s**\n%s\n", field.Name, utils.EscapeMarkdown(field.Value)) } - components := []component.Component{ + innerComponents := []component.Component{ component.BuildTextDisplay(component.TextDisplay{ Content: fieldStr, }), } if cmd.PremiumTier() == premium.None { - components = utils.AddPremiumFooter(components) + innerComponents = utils.AddPremiumFooter(innerComponents) } embeds = append(embeds, component.BuildContainer(component.Container{ AccentColor: &embedColor, - Components: components, + Components: innerComponents, })) } diff --git a/bot/utils/messageutils.go b/bot/utils/messageutils.go index 8c682116..56233745 100644 --- a/bot/utils/messageutils.go +++ b/bot/utils/messageutils.go @@ -112,7 +112,7 @@ func AddPremiumFooter(components []component.Component) []component.Component { components = append(components, component.BuildTextDisplay(component.TextDisplay{ - Content: fmt.Sprintf("-# %s Powered by %s", customisation.EmojiLogo, config.Conf.Bot.PoweredBy), + Content: fmt.Sprintf("-# %s Powered by [%s](https://%s)", customisation.EmojiLogo, config.Conf.Bot.PoweredBy, config.Conf.Bot.PoweredBy), }), ) diff --git a/i18n/messages.go b/i18n/messages.go index 025158eb..b14e31e8 100644 --- a/i18n/messages.go +++ b/i18n/messages.go @@ -112,16 +112,14 @@ var ( MessageAddNoPermission MessageId = "commands.add.no_permission" MessageAddSuccess MessageId = "commands.add.success" - MessageBlacklisted MessageId = "generic.error.blacklisted" - MessageBlacklistNoMembers MessageId = "commands.blacklist.no_members" - MessageBlacklistSelf MessageId = "commands.blacklist.self" - MessageBlacklistStaff MessageId = "commands.blacklist.staff" - MessageBlacklistLimit MessageId = "commands.blacklist.add.limit" - MessageBlacklistAdd MessageId = "commands.blacklist.add.success" - MessageBlacklistRoleLimit MessageId = "commands.blacklist.add_role.limit" - MessageBlacklistAddRole MessageId = "commands.blacklist.add_role.success" - MessageBlacklistRemove MessageId = "commands.blacklist.remove.success" - MessageBlacklistRemoveRole MessageId = "commands.blacklist.remove_role.success" + MessageBlacklisted MessageId = "generic.error.blacklisted" + MessageBlacklistNoMembers MessageId = "commands.blacklist.no_members" + MessageBlacklistSelf MessageId = "commands.blacklist.self" + MessageBlacklistStaff MessageId = "commands.blacklist.staff" + MessageBlacklistAdd MessageId = "commands.blacklist.add.success" + MessageBlacklistRemove MessageId = "commands.blacklist.remove.success" + MessageBlacklistLimit MessageId = "commands.blacklist.add.limit" + MessageBlacklistRoleLimit MessageId = "commands.blacklist.add_role.limit" MessageClaimed MessageId = "commands.claim.success" MessageClaimNoPermission MessageId = "commands.claim.no_permission" @@ -183,15 +181,16 @@ var ( MessageNotATicketChannel MessageId = "generic.not_ticket" MessageInvalidUser MessageId = "generic.invalid_user" - MessageTicketLimitReached MessageId = "commands.open.ticket_limit" - MessageTooManyTickets MessageId = "commands.open.too_many_tickets" - MessageGuildChannelLimitReached MessageId = "commands.open.guild_channel_limit" - MessageTicketStartedFrom MessageId = "commands.open.from" - MessageMovedToTicket MessageId = "commands.open.from.moved" - MessageFormMissingInput MessageId = "commands.open.missing_form_answer" - MessageOpenCommandDisabled MessageId = "commands.open.disabled" - MessageOpenCantSeeParentChannel MessageId = "commands.open.threads.cant_see_parent_channel" - MessageOpenCantMessageInThreads MessageId = "commands.open.threads.cant_message_in_threads" + MessageTicketLimitReached MessageId = "commands.open.ticket_limit" + MessageTooManyTickets MessageId = "commands.open.too_many_tickets" + MessageGuildChannelLimitReached MessageId = "commands.open.guild_channel_limit" + MessageTicketStartedFrom MessageId = "commands.open.from" + MessageTicketStartedFromNoContent MessageId = "commands.open.from.no_content" + MessageMovedToTicket MessageId = "commands.open.from.moved" + MessageFormMissingInput MessageId = "commands.open.missing_form_answer" + MessageOpenCommandDisabled MessageId = "commands.open.disabled" + MessageOpenCantSeeParentChannel MessageId = "commands.open.threads.cant_see_parent_channel" + MessageOpenCantMessageInThreads MessageId = "commands.open.threads.cant_message_in_threads" MessageCloseRequestNoReason MessageId = "commands.close_request.no_reason" MessageCloseRequestWithReason MessageId = "commands.close_request.with_reason"