finalized context menus
This commit is contained in:
89
cmd_tag.go
89
cmd_tag.go
@@ -51,43 +51,7 @@ var cmd_tag Command = Command{
|
|||||||
case "get":
|
case "get":
|
||||||
GetTagCommand(i, i.ApplicationCommandData().Options[0].Options[0])
|
GetTagCommand(i, i.ApplicationCommandData().Options[0].Options[0])
|
||||||
case "add":
|
case "add":
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
AddTagCommand(i, "")
|
||||||
Type: discordgo.InteractionResponseModal,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
CustomID: "tag_add_modal" + i.Interaction.Member.User.ID,
|
|
||||||
Title: "Add a custom tag command",
|
|
||||||
Components: []discordgo.MessageComponent{
|
|
||||||
discordgo.ActionsRow{
|
|
||||||
Components: []discordgo.MessageComponent{
|
|
||||||
discordgo.TextInput{
|
|
||||||
CustomID: "tag_add_modal_name",
|
|
||||||
Label: "Name",
|
|
||||||
Style: discordgo.TextInputShort,
|
|
||||||
Required: true,
|
|
||||||
MaxLength: 20,
|
|
||||||
Value: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
discordgo.ActionsRow{
|
|
||||||
Components: []discordgo.MessageComponent{
|
|
||||||
discordgo.TextInput{
|
|
||||||
CustomID: "tag_add_modal_content",
|
|
||||||
Label: "Content",
|
|
||||||
Placeholder: "Content that gets returned when the tag will be run",
|
|
||||||
Style: discordgo.TextInputParagraph,
|
|
||||||
Required: true,
|
|
||||||
MaxLength: 2000,
|
|
||||||
Value: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
logrus.Error(err)
|
|
||||||
}
|
|
||||||
case "remove":
|
case "remove":
|
||||||
removeTag(i.GuildID, i.ApplicationCommandData().Options[0].Options[0].StringValue())
|
removeTag(i.GuildID, i.ApplicationCommandData().Options[0].Options[0].StringValue())
|
||||||
err := respond(i.Interaction, "Tag removed!", true)
|
err := respond(i.Interaction, "Tag removed!", true)
|
||||||
@@ -133,6 +97,17 @@ var cmd_tag_short Command = Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var context_tag Command = Command{
|
||||||
|
Definition: discordgo.ApplicationCommand{
|
||||||
|
Type: discordgo.MessageApplicationCommand,
|
||||||
|
Name: "Save as tag",
|
||||||
|
DefaultMemberPermissions: int64Ptr(discordgo.PermissionManageServer),
|
||||||
|
},
|
||||||
|
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
|
AddTagCommand(i, i.ApplicationCommandData().Resolved.Messages[i.ApplicationCommandData().TargetID].Content)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func GetTagCommand(i *discordgo.InteractionCreate, option *discordgo.ApplicationCommandInteractionDataOption) {
|
func GetTagCommand(i *discordgo.InteractionCreate, option *discordgo.ApplicationCommandInteractionDataOption) {
|
||||||
err := respond(i.Interaction, getTagContent(i.GuildID, option.Value.(string)), false)
|
err := respond(i.Interaction, getTagContent(i.GuildID, option.Value.(string)), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -140,6 +115,46 @@ func GetTagCommand(i *discordgo.InteractionCreate, option *discordgo.Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AddTagCommand(i *discordgo.InteractionCreate, prevalue string) {
|
||||||
|
err := bot.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
|
Type: discordgo.InteractionResponseModal,
|
||||||
|
Data: &discordgo.InteractionResponseData{
|
||||||
|
CustomID: "tag_add_modal" + i.Interaction.Member.User.ID,
|
||||||
|
Title: "Add a custom tag command",
|
||||||
|
Components: []discordgo.MessageComponent{
|
||||||
|
discordgo.ActionsRow{
|
||||||
|
Components: []discordgo.MessageComponent{
|
||||||
|
discordgo.TextInput{
|
||||||
|
CustomID: "tag_add_modal_name",
|
||||||
|
Label: "Name",
|
||||||
|
Style: discordgo.TextInputShort,
|
||||||
|
Required: true,
|
||||||
|
MaxLength: 20,
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
discordgo.ActionsRow{
|
||||||
|
Components: []discordgo.MessageComponent{
|
||||||
|
discordgo.TextInput{
|
||||||
|
CustomID: "tag_add_modal_content",
|
||||||
|
Label: "Content",
|
||||||
|
Placeholder: "Content that gets returned when the tag will be run",
|
||||||
|
Style: discordgo.TextInputParagraph,
|
||||||
|
Required: true,
|
||||||
|
MaxLength: 2000,
|
||||||
|
Value: prevalue,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func AutocompleteTag(i *discordgo.InteractionCreate) {
|
func AutocompleteTag(i *discordgo.InteractionCreate) {
|
||||||
err := bot.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := bot.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionApplicationCommandAutocompleteResult,
|
Type: discordgo.InteractionApplicationCommandAutocompleteResult,
|
||||||
|
@@ -21,7 +21,7 @@ type Command struct {
|
|||||||
DynamicModalIDs func() []string
|
DynamicModalIDs func() []string
|
||||||
}
|
}
|
||||||
|
|
||||||
var commands []Command = []Command{cmd_form, cmd_tag, cmd_tag_short, cmd_dadjoke, cmd_ping, cmd_ask, cmd_sticky, cmd_cat, cmd_autojoinroles, cmd_autopublish, context_sticky}
|
var commands []Command = []Command{cmd_form, cmd_tag, cmd_tag_short, cmd_dadjoke, cmd_ping, cmd_ask, cmd_sticky, cmd_cat, cmd_autojoinroles, cmd_autopublish, context_sticky, context_tag}
|
||||||
|
|
||||||
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||||
logrus.Info("Starting up...")
|
logrus.Info("Starting up...")
|
||||||
|
Reference in New Issue
Block a user