v4/interactions/cmd_roleypoly.go
2025-03-26 16:36:00 -07:00

52 lines
1.3 KiB
Go

package interactions
import (
"fmt"
"net/url"
"git.sapphic.engineer/roleypoly/v4/utils"
)
func (i *Interactions) CmdRoleypoly(ix Interaction) (InteractionResponse, error) {
mentions := i.CommandsMap()
hostname := "roleypoly.com"
publicURL, _ := url.Parse(i.PublicBaseURL)
if publicURL != nil {
hostname = publicURL.Host
}
return InteractionResponse{
Type: ResponseChannelMessage,
Data: InteractionResponseData{
Flags: FlagEphemeral,
Embeds: []Embed{{
Color: utils.EmbedColor,
Title: fmt.Sprintf(":beginner: Hey there, %s", ix.GetName()),
Description: "Try these slash commands, or pick roles from a browser!",
Fields: []EmbedField{
{
Name: "See all the roles",
Value: utils.Or(mentions["pickable-roles"], "/pickable-roles"),
},
{
Name: "Pick a role",
Value: utils.Or(mentions["pick-role"], "/pick-role"),
},
{
Name: "Remove a role",
Value: utils.Or(mentions["remove-role"], "/remove-role"),
},
},
}},
Components: []ButtonComponent{
{
Type: 2, // Button
Style: 5, // Link
Label: fmt.Sprintf("Pick roles on %s", hostname),
Emoji: utils.GetRandomEmoji(),
URL: fmt.Sprintf("%s/s/%s", i.PublicBaseURL, ix.GuildID),
},
},
},
}, nil
}