From d05a74016eb8917f1a8295640c95fecb8a59b5dd Mon Sep 17 00:00:00 2001 From: biast12 Date: Sat, 21 Jun 2025 23:52:13 +0200 Subject: [PATCH] Cleanup --- bot/button/handlers/close.go | 2 +- .../impl/admin/adminlistguildentitlements.go | 1 - .../impl/admin/adminlistuserentitlements.go | 1 - bot/command/impl/admin/adminrecache.go | 1 - bot/command/impl/general/invite.go | 2 +- bot/command/impl/general/jumptotop.go | 2 +- bot/command/impl/general/vote.go | 2 +- bot/command/impl/settings/addadmin.go | 2 +- bot/command/impl/settings/addsupport.go | 2 +- bot/command/impl/settings/language.go | 1 - bot/command/impl/settings/premium.go | 1 - bot/command/impl/tags/tagalias.go | 7 ---- bot/command/impl/tickets/closerequest.go | 7 ---- bot/command/impl/tickets/switchpanel.go | 2 - bot/customisation/emoji.go | 31 +++++++------- bot/logic/close.go | 2 - bot/logic/help.go | 1 - bot/logic/viewstaff.go | 2 +- bot/logic/welcomemessage.go | 2 - bot/utils/messageutils.go | 41 +++++-------------- config/config.go | 17 ++++---- 21 files changed, 39 insertions(+), 90 deletions(-) diff --git a/bot/button/handlers/close.go b/bot/button/handlers/close.go index 5b8ecbc..170bb8d 100644 --- a/bot/button/handlers/close.go +++ b/bot/button/handlers/close.go @@ -57,7 +57,7 @@ func (h *CloseHandler) Execute(ctx *cmdcontext.ButtonContext) { } if closeConfirmation { - container := utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleCloseConfirmation, ctx.PremiumTier(), []component.Component{ + container := utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleCloseConfirmation, []component.Component{ component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("<@%d>: %s", ctx.InteractionUser().Id, ctx.GetMessage(i18n.MessageCloseConfirmation))}), component.BuildActionRow(component.BuildButton(component.Button{ Label: ctx.GetMessage(i18n.TitleClose), diff --git a/bot/command/impl/admin/adminlistguildentitlements.go b/bot/command/impl/admin/adminlistguildentitlements.go index 2473a8d..767b282 100644 --- a/bot/command/impl/admin/adminlistguildentitlements.go +++ b/bot/command/impl/admin/adminlistguildentitlements.go @@ -118,7 +118,6 @@ func (AdminListGuildEntitlementsCommand) Execute(ctx registry.CommandContext, gu ctx, customisation.Orange, i18n.Admin, - ctx.PremiumTier(), values, ), })) diff --git a/bot/command/impl/admin/adminlistuserentitlements.go b/bot/command/impl/admin/adminlistuserentitlements.go index 0a83f21..12885d4 100644 --- a/bot/command/impl/admin/adminlistuserentitlements.go +++ b/bot/command/impl/admin/adminlistuserentitlements.go @@ -72,7 +72,6 @@ func (AdminListUserEntitlementsCommand) Execute(ctx registry.CommandContext, use ctx, customisation.Orange, i18n.Admin, - ctx.PremiumTier(), values, ), })) diff --git a/bot/command/impl/admin/adminrecache.go b/bot/command/impl/admin/adminrecache.go index 46f794a..16e6e65 100644 --- a/bot/command/impl/admin/adminrecache.go +++ b/bot/command/impl/admin/adminrecache.go @@ -109,7 +109,6 @@ func (AdminRecacheCommand) Execute(ctx registry.CommandContext, providedGuildId ctx, customisation.Orange, "Admin - Recache", - ctx.PremiumTier(), []component.Component{ component.BuildTextDisplay(component.TextDisplay{ Content: fmt.Sprintf("**%s** has been recached successfully.\n\n**Guild ID:** %d\n**Time Taken:** %s", guild.Name, guildId, time.Since(currentTime).Round(time.Millisecond)), diff --git a/bot/command/impl/general/invite.go b/bot/command/impl/general/invite.go index d712d17..2ec3899 100644 --- a/bot/command/impl/general/invite.go +++ b/bot/command/impl/general/invite.go @@ -36,7 +36,7 @@ func (c InviteCommand) GetExecutor() interface{} { func (InviteCommand) Execute(ctx registry.CommandContext) { ctx.ReplyWith(command.NewEphemeralMessageResponseWithComponents([]component.Component{ - utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleInvite, ctx.PremiumTier(), []component.Component{ + utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleInvite, []component.Component{ component.BuildActionRow(component.BuildButton(component.Button{ Label: ctx.GetMessage(i18n.ClickHere), Style: component.ButtonStyleLink, diff --git a/bot/command/impl/general/jumptotop.go b/bot/command/impl/general/jumptotop.go index c0bd526..8c5a5b8 100644 --- a/bot/command/impl/general/jumptotop.go +++ b/bot/command/impl/general/jumptotop.go @@ -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, ctx.PremiumTier(), components), + utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleJumpToTop, components), })); err != nil { ctx.HandleError(err) return diff --git a/bot/command/impl/general/vote.go b/bot/command/impl/general/vote.go index db3b8d0..caa1362 100644 --- a/bot/command/impl/general/vote.go +++ b/bot/command/impl/general/vote.go @@ -95,7 +95,7 @@ func (c VoteCommand) Execute(ctx registry.CommandContext) { } if _, err := ctx.ReplyWith(command.NewEphemeralMessageResponseWithComponents([]component.Component{ - utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleVote, ctx.PremiumTier(), []component.Component{ + utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleVote, []component.Component{ componentBody, component.BuildSeparator(component.Separator{Divider: utils.Ptr(false)}), buildVoteComponent(ctx, true), diff --git a/bot/command/impl/settings/addadmin.go b/bot/command/impl/settings/addadmin.go index 1ff4f1d..92237b8 100644 --- a/bot/command/impl/settings/addadmin.go +++ b/bot/command/impl/settings/addadmin.go @@ -62,7 +62,7 @@ func (c AddAdminCommand) Execute(ctx registry.CommandContext, id uint64) { // Send confirmation message if _, err := ctx.ReplyWith(command.NewEphemeralMessageResponseWithComponents([]component.Component{ - utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleAddAdmin, ctx.PremiumTier(), []component.Component{ + utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleAddAdmin, []component.Component{ component.BuildTextDisplay(component.TextDisplay{ Content: ctx.GetMessage(i18n.MessageAddAdminConfirm, mention), }), diff --git a/bot/command/impl/settings/addsupport.go b/bot/command/impl/settings/addsupport.go index e49358e..8244930 100644 --- a/bot/command/impl/settings/addsupport.go +++ b/bot/command/impl/settings/addsupport.go @@ -66,7 +66,7 @@ func (c AddSupportCommand) Execute(ctx registry.CommandContext, id uint64) { // Send confirmation message if _, err := ctx.ReplyWith(command.NewEphemeralMessageResponseWithComponents([]component.Component{ - utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleAddSupport, ctx.PremiumTier(), []component.Component{ + utils.BuildContainerWithComponents(ctx, customisation.Green, i18n.TitleAddSupport, []component.Component{ component.BuildTextDisplay(component.TextDisplay{ Content: ctx.GetMessage(i18n.MessageAddSupportConfirm, mention), }), diff --git a/bot/command/impl/settings/language.go b/bot/command/impl/settings/language.go index b4719c4..b780331 100644 --- a/bot/command/impl/settings/language.go +++ b/bot/command/impl/settings/language.go @@ -79,7 +79,6 @@ func (c *LanguageCommand) Execute(ctx registry.CommandContext) { ctx, customisation.Green, i18n.TitleLanguage, - ctx.PremiumTier(), innerComponents, )))) } diff --git a/bot/command/impl/settings/premium.go b/bot/command/impl/settings/premium.go index f8f0c48..c764d96 100644 --- a/bot/command/impl/settings/premium.go +++ b/bot/command/impl/settings/premium.go @@ -90,7 +90,6 @@ func (PremiumCommand) Execute(ctx registry.CommandContext) { ctx, customisation.Green, i18n.TitlePremium, - ctx.PremiumTier(), []component.Component{ component.BuildTextDisplay(component.TextDisplay{Content: ctx.GetMessage(content)}), component.BuildActionRow(buttons...), diff --git a/bot/command/impl/tags/tagalias.go b/bot/command/impl/tags/tagalias.go index 0967ae8..a601427 100644 --- a/bot/command/impl/tags/tagalias.go +++ b/bot/command/impl/tags/tagalias.go @@ -83,13 +83,6 @@ func (c TagAliasCommand) Execute(ctx registry.CommandContext) { components = append(components, *logic.BuildCustomContainer(ctx, ctx.Worker(), ticket, *c.tag.Embed.CustomEmbed, c.tag.Embed.Fields, false, nil)) } - // var allowedMentions message.AllowedMention - // if ticket.Id != 0 { - // allowedMentions = message.AllowedMention{ - // Users: []uint64{ticket.UserId}, - // } - // } - if _, err := ctx.ReplyWith(command.NewMessageResponseWithComponents(components)); err != nil { ctx.HandleError(err) return diff --git a/bot/command/impl/tickets/closerequest.go b/bot/command/impl/tickets/closerequest.go index 53ee822..f68fbf4 100644 --- a/bot/command/impl/tickets/closerequest.go +++ b/bot/command/impl/tickets/closerequest.go @@ -105,13 +105,6 @@ func (CloseRequestCommand) Execute(ctx registry.CommandContext, closeDelay *int, }), ) - // data := command.MessageResponse{ - // AllowedMentions: message.AllowedMention{ - // Users: []uint64{ticket.UserId}, - // }, - - // } - if _, err := ctx.ReplyWith(command.NewMessageResponseWithComponents([]component.Component{ component.BuildTextDisplay(component.TextDisplay{ Content: fmt.Sprintf("<@%d>", ticket.UserId), diff --git a/bot/command/impl/tickets/switchpanel.go b/bot/command/impl/tickets/switchpanel.go index 7077f8f..7eae731 100644 --- a/bot/command/impl/tickets/switchpanel.go +++ b/bot/command/impl/tickets/switchpanel.go @@ -113,8 +113,6 @@ func (SwitchPanelCommand) Execute(ctx *cmdcontext.SlashCommandContext, panelId i c := msg.Components // get the first c where its a Container - - // embeds := utils.PtrElems(msg.Embeds) // TODO: Fix types if len(c) == 0 { c = make([]component.Component, 1) subject = "No subject given" diff --git a/bot/customisation/emoji.go b/bot/customisation/emoji.go index 180590a..b50a8a8 100644 --- a/bot/customisation/emoji.go +++ b/bot/customisation/emoji.go @@ -3,9 +3,9 @@ package customisation import ( "fmt" - "github.com/TicketsBot-cloud/worker/config" "github.com/TicketsBot-cloud/gdl/objects" "github.com/TicketsBot-cloud/gdl/objects/guild/emoji" + "github.com/TicketsBot-cloud/worker/config" ) type CustomEmoji struct { @@ -16,17 +16,17 @@ type CustomEmoji struct { func NewCustomEmoji(name string, id uint64, animated bool) CustomEmoji { return CustomEmoji{ - Name: name, - Id: id, + Name: name, + Id: id, + Animated: animated, } } func (e CustomEmoji) String() string { if e.Animated { return fmt.Sprintf("", e.Name, e.Id) - } else { - return fmt.Sprintf("<:%s:%d>", e.Name, e.Id) } + return fmt.Sprintf("<:%s:%d>", e.Name, e.Id) } func (e CustomEmoji) BuildEmoji() *emoji.Emoji { @@ -38,30 +38,27 @@ func (e CustomEmoji) BuildEmoji() *emoji.Emoji { } var ( + EmojiBulletLine = NewCustomEmoji("bulletline", config.Conf.Emojis.BulletLine, false) + EmojiClaim = NewCustomEmoji("claim", config.Conf.Emojis.Claim, false) + EmojiClose = NewCustomEmoji("close", config.Conf.Emojis.Close, false) + EmojiDiscord = NewCustomEmoji("discord", config.Conf.Emojis.Discord, false) EmojiId = NewCustomEmoji("id", config.Conf.Emojis.Id, false) + EmojiLogo = NewCustomEmoji("logo", config.Conf.Emojis.Logo, false) EmojiOpen = NewCustomEmoji("open", config.Conf.Emojis.Open, false) EmojiOpenTime = NewCustomEmoji("opentime", config.Conf.Emojis.OpenTime, false) - EmojiClose = NewCustomEmoji("close", config.Conf.Emojis.Close, false) - EmojiCloseTime = NewCustomEmoji("closetime", config.Conf.Emojis.CloseTime, false) - EmojiReason = NewCustomEmoji("reason", config.Conf.Emojis.Reason, false) - EmojiSubject = NewCustomEmoji("subject", config.Conf.Emojis.Subject, false) - EmojiTranscript = NewCustomEmoji("transcript", config.Conf.Emojis.Transcript, false) - EmojiClaim = NewCustomEmoji("claim", config.Conf.Emojis.Claim, false) EmojiPanel = NewCustomEmoji("panel", config.Conf.Emojis.Panel, false) + EmojiPatreon = NewCustomEmoji("patreon", config.Conf.Emojis.Patreon, false) EmojiRating = NewCustomEmoji("rating", config.Conf.Emojis.Rating, false) + EmojiReason = NewCustomEmoji("reason", config.Conf.Emojis.Reason, false) EmojiStaff = NewCustomEmoji("staff", config.Conf.Emojis.Staff, false) EmojiThread = NewCustomEmoji("thread", config.Conf.Emojis.Thread, false) - EmojiBulletLine = NewCustomEmoji("bulletline", config.Conf.Emojis.BulletLine, false) - EmojiPatreon = NewCustomEmoji("patreon", config.Conf.Emojis.Patreon, false) - EmojiDiscord = NewCustomEmoji("discord", config.Conf.Emojis.Discord, false) - //EmojiTime = NewCustomEmoji("time", 974006684622159952, false) + EmojiTranscript = NewCustomEmoji("transcript", config.Conf.Emojis.Transcript, false) ) // PrefixWithEmoji Useful for whitelabel bots func PrefixWithEmoji(s string, emoji CustomEmoji, includeEmoji bool) string { if includeEmoji { return fmt.Sprintf("%s %s", emoji, s) - } else { - return s } + return s } diff --git a/bot/logic/close.go b/bot/logic/close.go index 71b482f..8393258 100644 --- a/bot/logic/close.go +++ b/bot/logic/close.go @@ -256,11 +256,9 @@ func sendCloseEmbed(ctx context.Context, cmd registry.CommandContext, errorConte }, } - // closeEmbed, closeComponents := BuildCloseEmbed(ctx, cmd.Worker(), ticket, member.User.Id, reason, nil, componentBuilders) closeContainer := BuildCloseContainer(ctx, cmd, cmd.Worker(), ticket, member.User.Id, reason, nil, componentBuilders) data := rest.CreateMessageData{ - // Embeds: utils.Slice(closeEmbed), Flags: uint(message.FlagComponentsV2), Components: utils.Slice(*closeContainer), } diff --git a/bot/logic/help.go b/bot/logic/help.go index b93954c..8724668 100644 --- a/bot/logic/help.go +++ b/bot/logic/help.go @@ -21,7 +21,6 @@ func BuildHelpMessage(category command.Category, page int, ctx registry.CommandC componentList := []component.Component{} permLevel, _ := ctx.UserPermissionLevel(ctx) - // permLevel := permission.Admin commandIds, err := command.LoadCommandIds(ctx.Worker(), ctx.Worker().BotId) if err != nil { diff --git a/bot/logic/viewstaff.go b/bot/logic/viewstaff.go index bb0edf5..c2bc712 100644 --- a/bot/logic/viewstaff.go +++ b/bot/logic/viewstaff.go @@ -127,7 +127,7 @@ func BuildViewStaffMessage(ctx context.Context, cmd registry.CommandContext, pag comps = append(comps, component.BuildTextDisplay(component.TextDisplay{Content: fmt.Sprintf("**%s**\n%s", label, value)})) } - container := utils.BuildContainerWithComponents(cmd, customisation.Green, i18n.MessageViewStaffTitle, cmd.PremiumTier(), comps) + container := utils.BuildContainerWithComponents(cmd, customisation.Green, i18n.MessageViewStaffTitle, comps) return container, totalPages } diff --git a/bot/logic/welcomemessage.go b/bot/logic/welcomemessage.go index 810095c..9762d05 100644 --- a/bot/logic/welcomemessage.go +++ b/bot/logic/welcomemessage.go @@ -75,8 +75,6 @@ func SendWelcomeMessage( AccentColor: &embedColor, Components: components, })) - - // embeds = append(embeds, formAnswersEmbed) } buttons := []component.Component{ diff --git a/bot/utils/messageutils.go b/bot/utils/messageutils.go index f4bc01d..a11882f 100644 --- a/bot/utils/messageutils.go +++ b/bot/utils/messageutils.go @@ -18,7 +18,7 @@ import ( ) func BuildContainer(ctx registry.CommandContext, colour customisation.Colour, titleId, contentId i18n.MessageId, format ...interface{}) component.Component { - return BuildContainerWithComponents(ctx, colour, titleId, ctx.PremiumTier(), []component.Component{ + return BuildContainerWithComponents(ctx, colour, titleId, []component.Component{ component.BuildTextDisplay(component.TextDisplay{ Content: i18n.GetMessageFromGuild(ctx.GuildId(), contentId, format...), })}) @@ -34,7 +34,7 @@ func BuildContainerWithFields(ctx registry.CommandContext, colour customisation. })) } - return BuildContainerWithComponents(ctx, colour, titleId, ctx.PremiumTier(), append([]component.Component{ + return BuildContainerWithComponents(ctx, colour, titleId, append([]component.Component{ component.BuildTextDisplay(component.TextDisplay{ Content: i18n.GetMessageFromGuild(ctx.GuildId(), content, format...), }), @@ -43,7 +43,7 @@ func BuildContainerWithFields(ctx registry.CommandContext, colour customisation. } func BuildContainerWithComponents( - ctx registry.CommandContext, colour customisation.Colour, title i18n.MessageId, tier premium.PremiumTier, innerComponents []component.Component, + ctx registry.CommandContext, colour customisation.Colour, title i18n.MessageId, innerComponents []component.Component, ) component.Component { components := append(Slice( component.BuildTextDisplay(component.TextDisplay{ @@ -52,16 +52,8 @@ func BuildContainerWithComponents( component.BuildSeparator(component.Separator{}), ), innerComponents...) - if tier == premium.None { - // check if last component is a separator, if not add one - if len(components) == 0 || components[len(components)-1].Type != component.ComponentSeparator { - components = append(components, component.BuildSeparator(component.Separator{})) - } - components = append(components, - component.BuildTextDisplay(component.TextDisplay{ - Content: fmt.Sprintf("-# <:tkts_circle:1373407290912276642> Powered by %s", config.Conf.Bot.PoweredBy), - }), - ) + if ctx.PremiumTier() == premium.None { + components = AddPremiumFooter(components) } return component.BuildContainer(component.Container{ @@ -71,7 +63,7 @@ func BuildContainerWithComponents( } func BuildContainerNoLocale( - ctx registry.CommandContext, colour customisation.Colour, title string, tier premium.PremiumTier, innerComponents []component.Component, + ctx registry.CommandContext, colour customisation.Colour, title string, innerComponents []component.Component, ) component.Component { components := append(Slice( component.BuildTextDisplay(component.TextDisplay{ @@ -80,16 +72,8 @@ func BuildContainerNoLocale( component.BuildSeparator(component.Separator{}), ), innerComponents...) - if tier == premium.None { - // check if last component is a separator, if not add one - if len(components) == 0 || components[len(components)-1].Type != component.ComponentSeparator { - components = append(components, component.BuildSeparator(component.Separator{})) - } - components = append(components, - component.BuildTextDisplay(component.TextDisplay{ - Content: fmt.Sprintf("-# <:tkts_circle:1373407290912276642> Powered by %s", config.Conf.Bot.PoweredBy), - }), - ) + if ctx.PremiumTier() == premium.None { + components = AddPremiumFooter(components) } return component.BuildContainer(component.Container{ @@ -112,12 +96,7 @@ func BuildContainerRaw( ) if tier == premium.None { - components = append(components, - component.BuildSeparator(component.Separator{}), - component.BuildTextDisplay(component.TextDisplay{ - Content: fmt.Sprintf("-# <:tkts_circle:1373407290912276642> Powered by %s", config.Conf.Bot.PoweredBy), - }), - ) + components = AddPremiumFooter(components) } return component.BuildContainer(component.Container{ @@ -133,7 +112,7 @@ func AddPremiumFooter(components []component.Component) []component.Component { components = append(components, component.BuildTextDisplay(component.TextDisplay{ - Content: fmt.Sprintf("-# <:tkts_circle:1373407290912276642> Powered by %s", config.Conf.Bot.PoweredBy), + Content: fmt.Sprintf("-# %s Powered by %s", customisation.EmojiLogo, config.Conf.Bot.PoweredBy), }), ) diff --git a/config/config.go b/config/config.go index fa5e10e..8fdaf6f 100644 --- a/config/config.go +++ b/config/config.go @@ -122,22 +122,21 @@ type ( } `envPrefix:"WORKER_CLOUD_PROFILER_"` Emojis struct { + BulletLine uint64 `env:"BULLETLINE" envDefault:"1327350311110574201"` + Claim uint64 `env:"CLAIM" envDefault:"1327350259965235233"` + Close uint64 `env:"CLOSE" envDefault:"1327350171121614870"` + Discord uint64 `env:"DISCORD" envDefault:"1327350329381228544"` Id uint64 `env:"ID" envDefault:"1327350136170479638"` + Logo uint64 `env:"LOGO" envDefault:"1373407290912276642"` Open uint64 `env:"OPEN" envDefault:"1327350149684400268"` OpenTime uint64 `env:"OPENTIME" envDefault:"1327350161206153227"` - Close uint64 `env:"CLOSE" envDefault:"1327350171121614870"` - CloseTime uint64 `env:"CLOSETIME" envDefault:"1327350182806949948"` - Reason uint64 `env:"REASON" envDefault:"1327350192801972224"` - Subject uint64 `env:"SUBJECT" envDefault:"1327350205896458251"` - Transcript uint64 `env:"TRANSCRIPT" envDefault:"1327350249450111068"` - Claim uint64 `env:"CLAIM" envDefault:"1327350259965235233"` Panel uint64 `env:"PANEL" envDefault:"1327350268974600263"` + Patreon uint64 `env:"PATREON" envDefault:"1327350319612690563"` Rating uint64 `env:"RATING" envDefault:"1327350278973952045"` + Reason uint64 `env:"REASON" envDefault:"1327350192801972224"` Staff uint64 `env:"STAFF" envDefault:"1327350290558746674"` Thread uint64 `env:"THREAD" envDefault:"1327350300717355079"` - BulletLine uint64 `env:"BULLETLINE" envDefault:"1327350311110574201"` - Patreon uint64 `env:"PATREON" envDefault:"1327350319612690563"` - Discord uint64 `env:"DISCORD" envDefault:"1327350329381228544"` + Transcript uint64 `env:"TRANSCRIPT" envDefault:"1327350249450111068"` } `envPrefix:"EMOJI_"` VoteSkuId uuid.UUID `env:"VOTE_SKU_ID"`