fixed some error with the tag command
This commit is contained in:
@@ -4,10 +4,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"github.com/iancoleman/strcase"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tagAddName string
|
|
||||||
var tag_command Command = Command{
|
var tag_command Command = Command{
|
||||||
Definition: discordgo.ApplicationCommand{
|
Definition: discordgo.ApplicationCommand{
|
||||||
Name: "tag",
|
Name: "tag",
|
||||||
@@ -31,14 +29,6 @@ var tag_command Command = Command{
|
|||||||
Name: "add",
|
Name: "add",
|
||||||
Description: "A command to add messages saved to the bot.",
|
Description: "A command to add messages saved to the bot.",
|
||||||
Type: discordgo.ApplicationCommandOptionSubCommand,
|
Type: discordgo.ApplicationCommandOptionSubCommand,
|
||||||
Options: []*discordgo.ApplicationCommandOption{
|
|
||||||
{
|
|
||||||
Type: discordgo.ApplicationCommandOptionString,
|
|
||||||
Name: "tag",
|
|
||||||
Description: "Your tag for the saved message",
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "remove",
|
Name: "remove",
|
||||||
@@ -61,13 +51,24 @@ var tag_command Command = Command{
|
|||||||
case "get":
|
case "get":
|
||||||
GetTagCommand(s, i, i.ApplicationCommandData().Options[0].Options[0])
|
GetTagCommand(s, i, i.ApplicationCommandData().Options[0].Options[0])
|
||||||
case "add":
|
case "add":
|
||||||
tagAddName = strcase.ToSnake(i.ApplicationCommandData().Options[0].Options[0].StringValue())
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseModal,
|
Type: discordgo.InteractionResponseModal,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
CustomID: "tag_add_modal" + i.Interaction.Member.User.ID,
|
CustomID: "tag_add_modal" + i.Interaction.Member.User.ID,
|
||||||
Title: "Add a custom tag command",
|
Title: "Add a custom tag command",
|
||||||
Components: []discordgo.MessageComponent{
|
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{
|
discordgo.ActionsRow{
|
||||||
Components: []discordgo.MessageComponent{
|
Components: []discordgo.MessageComponent{
|
||||||
discordgo.TextInput{
|
discordgo.TextInput{
|
||||||
@@ -97,25 +98,16 @@ var tag_command Command = Command{
|
|||||||
},
|
},
|
||||||
ModalID: "tag_add_modal",
|
ModalID: "tag_add_modal",
|
||||||
ModalSubmit: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
ModalSubmit: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
if tagAddName == "" {
|
tagName := i.ModalSubmitData().Components[0].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value
|
||||||
|
tagContent := i.ModalSubmitData().Components[1].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value
|
||||||
|
addTag(i.GuildID, tagName, tagContent)
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: "Tag name got missing! Please try again...",
|
Content: "Tag \"" + tagName + "\" added!",
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
Flags: discordgo.MessageFlagsEphemeral,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
tagContent := i.ModalSubmitData().Components[0].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value
|
|
||||||
addTag(i.GuildID, tagAddName, tagContent)
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Tag \"" + tagAddName + "\" added!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Autocomplete: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
Autocomplete: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
AutocompleteTag(s, i)
|
AutocompleteTag(s, i)
|
||||||
|
Reference in New Issue
Block a user