Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cc: add functions and triggers for components and modals (#1619)
* cc: add functions and triggers for components and modals Co-Authored-By: Shadow <[email protected]> Co-Authored-By: Borbot33 <[email protected]> Co-Authored-By: Luca Zeuch <[email protected]> * cc: restructure and rename functions creating buttons and select menus does not need context to run, and therefore should be in `general`. also renamed the functions to match convention * cc: restructure custom id validation Move all custom id validation, including setting link button cids to empty strings, to one function executed at the end of a complexMessage or complexMessageEdit run. also moves the setting of default custom ids to this function. Signed-off-by: SoggySaussages <[email protected]> * cc: add buttons and menus to complexMessage<Edit> add fields to complexMessage allowing users to pass slices of buttons and menus to complexMessage builders, in any order, as many times as they'd like. they can be slices of buttons/modals or sdicts. Signed-off-by: SoggySaussages <[email protected]> * cc: allow duplicate keys in complexMessage<Edit> allow multiple of the same key to be passed to complexMessage so that embeds and components may be declared multiple times, each case appending the input to the message. illustrated here: https://github.com/botlabs-gg/yagpdb/assets/110698921/c2e1e9fa-8f36-4ddd-8fd0-d45f4ad945d6 this is mainly implemented for buttons and menus since embed already uses a slice of embeds and this can be done even better using that method. this is not as simple with buttons and menus because we need to be able to customize the layout of the component rows. only keeping it the same for embed field for consistency. Signed-off-by: SoggySaussages <[email protected]> * cc: hotfix Fix an issue re: "cc: restructure custom id validation" where components were no longer prepending templates- to custom ids Reverted an upstream pull in lib/discordgo.components.go, upstream discordgo uses strings whilst yagpdb uses int64 * cc: upstream message unmarshal function Implement the proper unmarshalling function from upstream discordgo to fix improper unmarshalling of message components * cc: sendMessageType delegated to own type Signed-off-by: SoggySaussages <[email protected]> * cc/web: gramatical consistency Signed-off-by: SoggySaussages <[email protected]> * cc: idiomatify templates prefix check Signed-off-by: SoggySaussages <[email protected]> * cc: add limits to functions and triggers Signed-off-by: SoggySaussages <[email protected]> * cc: allow sendModal to accept an sdict Signed-off-by: SoggySaussages <[email protected]> * cc/buttons: add more style compatibility adds aliases for the styles to be their numerical value or a discordgo.ButtonStyle, useful if using structToSdict so you don't need to manually parse the styles Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: allow file in response + followup add the ability for a file specified in complexMessage to be sent in an interaction response or followup. Technically a fix because I thought it would already work but never tested it. Feauring a slightly altered upstream pull of discordgo for (s *Session) CreateInteractionResponse. It still diverges from upstream slightly, however only enough to avoid rebasing the entirety of restapi.go. Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: improve cid parsing use cutPrefix in modal handler. do not prepend templates- if it is already prefixxed, either from a structToSdict or a user thinking they have to. also validate cid length. * cc/interactions: restructure dot context CustomID has custom ID with prefix templates- trimmed off. Cmd now has Cmd as matched by the regex pattern instead of the full custom ID. CmdArgs has the proper CmdArgs as would usually be parsed, Values has any values submitted in a menu or modal instead. Signed off by SoggySaussages <[email protected]> * cc/interactions: add getResponse getResponse allows the user to get an interaction response or followup. It functions similarly to getMessage, and takes an interaction token (nil to use token in context) and a message id (nil to get original response). This is necessary for getting ephemeral messages. Syntax: getResponse interactionToken mID Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: fix empty message content edits fixes a bug where editing a message to have no content would error. Also allows for messages without content or embeds if they have components. Signed-off-by: SoggySaussages <[email protected]> * dgo: use WebhookMessage Change from using GetOriginalInteractionResponse to WebhookMessage. This is similar to upstream which uses WebhookMessage with a message ID "@original" as opposed to a separate function. WebhookMessage message ID is a string which may be a message ID or "@original." Signed-off by SoggySaussages <[email protected]> * Revert "dgo: use WebhookMessage" This reverts commit 376513d. * dgo: support string in EndpointWebhookMessage Add support for EndpointWebhookMessage to use a string value for the message ID. This is necessary because the endpoint supports use of either an int64 message ID or @original. Signed-off-by: SoggySaussages <[email protected]> * cc/interaction: fix modal cid parse Signed-off-by: SoggySaussages <[email protected]> * cc:clarify ccid triggers on dashboard Clarify trigger type and add info that these triggers are in beta. Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: move functions to separate file Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: update js in accordance with 1646 Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: frontend fix Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: adjust js naming Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: pass interaction context w execCC Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: fix non-text menus' context data Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: fix text menus' context data Signed-off-by: SoggySaussages <[email protected]> * cc/interactions: allow components in DM Allowing components in DMs allows for link buttons and disabled buttons (for cosmetic purposes) to be included. This does not add support for triggering custom commands via DM interactions, DM component usage is still ignored by CC. Note: This commit puts the Show Server Info button before other components. Signed-off-by: SoggySaussages <[email protected]> --------- Signed-off-by: SoggySaussages <[email protected]> Signed-off-by: SoggySaussages <[email protected]> Co-authored-by: Shadow <[email protected]> Co-authored-by: Borbot33 <[email protected]> Co-authored-by: Luca Zeuch <[email protected]>
- Loading branch information