-
Notifications
You must be signed in to change notification settings - Fork 21
feat(RM-118): Components v2 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BenHall-1
wants to merge
17
commits into
master
Choose a base branch
from
cv2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e151696
cv2
BenHall-1 8118e21
cv2
BenHall-1 a2f256c
cv2
BenHall-1 b934cb4
Merge branch 'master' of github.com:ticketsbot-cloud/worker into cv2
BenHall-1 6885bd0
Merge branch 'master' of github.com:ticketsbot-cloud/worker into cv2
BenHall-1 4a891f8
Merge branch 'master' into cv2
BenHall-1 3bad395
update more components
BenHall-1 1d9ed3c
feat: slight rewrite of /viewstaff with added pagination (#14)
biast12 f79f2f6
update more components
BenHall-1 0ce9f2a
Cleanup for cv2 (#20)
biast12 00268c5
update stats commands
BenHall-1 9a0d72b
Merge branch 'cv2' of github.com:ticketsbot-cloud/worker into cv2
BenHall-1 2c1f144
update stats commands
BenHall-1 1359666
add recache button
BenHall-1 bec9946
update stats commands
BenHall-1 7d66d3a
CV2: refactor component variable names and improve blacklist logic (#21)
biast12 4b515f6
feat(RM-51): Show panel name in close container if available (CV2) (#22)
biast12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package handlers | ||
|
|
||
| import ( | ||
| "math" | ||
| "strings" | ||
|
|
||
| "github.com/TicketsBot-cloud/gdl/objects/interaction/component" | ||
| "github.com/TicketsBot-cloud/worker/bot/button/registry" | ||
| "github.com/TicketsBot-cloud/worker/bot/button/registry/matcher" | ||
| "github.com/TicketsBot-cloud/worker/bot/command" | ||
| "github.com/TicketsBot-cloud/worker/bot/command/context" | ||
| "github.com/TicketsBot-cloud/worker/bot/command/manager" | ||
| "github.com/TicketsBot-cloud/worker/bot/logic" | ||
| ) | ||
|
|
||
| type HelpCategoryHandler struct{} | ||
|
|
||
| func (h *HelpCategoryHandler) Matcher() matcher.Matcher { | ||
| return &matcher.FuncMatcher{ | ||
| Func: func(customId string) bool { | ||
| return strings.HasPrefix(customId, "help_") | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func (h *HelpCategoryHandler) Properties() registry.Properties { | ||
| return registry.Properties{ | ||
| Flags: registry.SumFlags(registry.GuildAllowed), | ||
| } | ||
| } | ||
|
|
||
| func (h *HelpCategoryHandler) Execute(ctx *context.SelectMenuContext) { | ||
| if len(ctx.InteractionData.Values) == 0 { | ||
| return | ||
| } | ||
|
|
||
| commandManager := new(manager.CommandManager) | ||
| commandManager.RegisterCommands() | ||
|
|
||
| helpCategoryCustomId := ctx.InteractionData.Values[0] | ||
|
|
||
| helpCategory := command.General | ||
|
|
||
| switch helpCategoryCustomId { | ||
| case "help_general": | ||
| helpCategory = command.General | ||
| case "help_tickets": | ||
| helpCategory = command.Tickets | ||
| case "help_settings": | ||
| helpCategory = command.Settings | ||
| case "help_tags": | ||
| helpCategory = command.Tags | ||
| case "help_statistics": | ||
| helpCategory = command.Statistics | ||
| default: | ||
| return | ||
| } | ||
|
|
||
| container, err := logic.BuildHelpMessage(helpCategory, 1, ctx, commandManager.GetCommands()) | ||
| if err != nil { | ||
| ctx.HandleError(err) | ||
| return | ||
| } | ||
|
|
||
| // get commands in selected category | ||
| commands := commandManager.GetCommandByCategory(helpCategory) | ||
| pageCount := float64(len(commands)) / float64(5) | ||
|
|
||
| if pageCount == 0 { | ||
| pageCount = 1 | ||
| } | ||
|
|
||
| ctx.Edit(command.NewEphemeralMessageResponseWithComponents([]component.Component{ | ||
| *container, | ||
| *logic.BuildHelpMessagePaginationButtons(helpCategory.ToRawString(), 1, int(math.Ceil(pageCount))), | ||
| *logic.BuildHelpMessageCategorySelector(commandManager.GetCommands(), ctx, helpCategory), | ||
| })) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package handlers | ||
|
|
||
| import ( | ||
| "math" | ||
| "strconv" | ||
| "strings" | ||
|
|
||
| "github.com/TicketsBot-cloud/gdl/objects/interaction/component" | ||
| "github.com/TicketsBot-cloud/worker/bot/button/registry" | ||
| "github.com/TicketsBot-cloud/worker/bot/button/registry/matcher" | ||
| "github.com/TicketsBot-cloud/worker/bot/command" | ||
| "github.com/TicketsBot-cloud/worker/bot/command/context" | ||
| "github.com/TicketsBot-cloud/worker/bot/command/manager" | ||
| "github.com/TicketsBot-cloud/worker/bot/logic" | ||
| ) | ||
|
|
||
| type HelpPageHandler struct{} | ||
|
|
||
| func (h *HelpPageHandler) Matcher() matcher.Matcher { | ||
| return &matcher.FuncMatcher{ | ||
| Func: func(customId string) bool { | ||
| return strings.HasPrefix(customId, "helppage_") | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func (h *HelpPageHandler) Properties() registry.Properties { | ||
| return registry.Properties{ | ||
| Flags: registry.SumFlags(registry.GuildAllowed), | ||
| } | ||
| } | ||
|
|
||
| func (h *HelpPageHandler) Execute(ctx *context.ButtonContext) { | ||
| if ctx.InteractionData.CustomId == "" { | ||
| return | ||
| } | ||
|
|
||
| var ( | ||
| customIdParts = strings.Split(ctx.InteractionData.CustomId, "_") | ||
| category = customIdParts[1] | ||
| page, _ = strconv.ParseInt(customIdParts[2], 10, 64) | ||
| ) | ||
|
|
||
| commandManager := new(manager.CommandManager) | ||
| commandManager.RegisterCommands() | ||
|
|
||
| helpCategory := command.General | ||
|
|
||
| switch category { | ||
| case "general": | ||
| helpCategory = command.General | ||
| case "tickets": | ||
| helpCategory = command.Tickets | ||
| case "settings": | ||
| helpCategory = command.Settings | ||
| case "tags": | ||
| helpCategory = command.Tags | ||
| case "statistics": | ||
| helpCategory = command.Statistics | ||
| default: | ||
| return | ||
| } | ||
|
|
||
| container, err := logic.BuildHelpMessage(helpCategory, int(page), ctx, commandManager.GetCommands()) | ||
| if err != nil { | ||
| ctx.HandleError(err) | ||
| return | ||
| } | ||
|
|
||
| // get commands in selected category | ||
| commands := commandManager.GetCommandByCategory(helpCategory) | ||
| pageCount := float64(len(commands)) / float64(5) | ||
|
|
||
| if pageCount == 0 { | ||
| pageCount = 1 | ||
| } | ||
|
|
||
| ctx.Edit(command.NewEphemeralMessageResponseWithComponents([]component.Component{ | ||
| *container, | ||
| *logic.BuildHelpMessagePaginationButtons(helpCategory.ToRawString(), int(page), int(math.Ceil(pageCount))), | ||
| *logic.BuildHelpMessageCategorySelector(commandManager.GetCommands(), ctx, helpCategory), | ||
| })) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.