Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bot/button/handlers/close.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion bot/command/impl/admin/adminlistguildentitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func (AdminListGuildEntitlementsCommand) Execute(ctx registry.CommandContext, gu
ctx,
customisation.Orange,
i18n.Admin,
ctx.PremiumTier(),
values,
),
}))
Expand Down
1 change: 0 additions & 1 deletion bot/command/impl/admin/adminlistuserentitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (AdminListUserEntitlementsCommand) Execute(ctx registry.CommandContext, use
ctx,
customisation.Orange,
i18n.Admin,
ctx.PremiumTier(),
values,
),
}))
Expand Down
1 change: 0 additions & 1 deletion bot/command/impl/admin/adminrecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion bot/command/impl/general/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bot/command/impl/general/jumptotop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bot/command/impl/general/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion bot/command/impl/settings/addadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}),
Expand Down
2 changes: 1 addition & 1 deletion bot/command/impl/settings/addsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}),
Expand Down
1 change: 0 additions & 1 deletion bot/command/impl/settings/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func (c *LanguageCommand) Execute(ctx registry.CommandContext) {
ctx,
customisation.Green,
i18n.TitleLanguage,
ctx.PremiumTier(),
innerComponents,
))))
}
Expand Down
1 change: 0 additions & 1 deletion bot/command/impl/settings/premium.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...),
Expand Down
7 changes: 0 additions & 7 deletions bot/command/impl/tags/tagalias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions bot/command/impl/tickets/closerequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 0 additions & 2 deletions bot/command/impl/tickets/switchpanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 14 additions & 17 deletions bot/customisation/emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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("<a:%s:%d>", 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 {
Expand All @@ -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
}
2 changes: 0 additions & 2 deletions bot/logic/close.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
1 change: 0 additions & 1 deletion bot/logic/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion bot/logic/viewstaff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions bot/logic/welcomemessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ func SendWelcomeMessage(
AccentColor: &embedColor,
Components: components,
}))

// embeds = append(embeds, formAnswersEmbed)
}

buttons := []component.Component{
Expand Down
41 changes: 10 additions & 31 deletions bot/utils/messageutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...),
})})
Expand All @@ -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...),
}),
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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),
}),
)

Expand Down
17 changes: 8 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down