diff --git a/cmd_tag.go b/cmd_tag.go index e0bc64a..634926f 100644 --- a/cmd_tag.go +++ b/cmd_tag.go @@ -48,7 +48,7 @@ var cmd_tag Command = Command{ case "get": GetTagCommand(e) case "add": - AddTagCommand(e, "") + AddTagCommand(e) case "remove": removeTag(e.GuildID().String(), e.SlashCommandInteractionData().String("tag")) err := e.CreateMessage(discord.NewMessageCreateBuilder(). @@ -103,7 +103,7 @@ var context_tag Command = Command{ DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild), }, Interact: func(e *events.ApplicationCommandInteractionCreate) { - AddTagCommand(e, e.SlashCommandInteractionData().String("")) + AddTagCommand(e) }, } @@ -116,7 +116,11 @@ func GetTagCommand(e *events.ApplicationCommandInteractionCreate) { } } -func AddTagCommand(e *events.ApplicationCommandInteractionCreate, prevalue string) { +func AddTagCommand(e *events.ApplicationCommandInteractionCreate) { + var prevalue string + if e.ApplicationCommandInteraction.Data.Type() == discord.ApplicationCommandTypeMessage { + prevalue = e.MessageCommandInteractionData().TargetMessage().Content + } err := e.Modal(discord.ModalCreate{ CustomID: "tag_add_modal" + e.User().ID.String(), Title: "Add a custom tag command", diff --git a/handlers.go b/handlers.go index 70aca38..b481a0a 100644 --- a/handlers.go +++ b/handlers.go @@ -62,11 +62,14 @@ func ready(e *events.Ready) { func applicationCommandInteractionCreate(e *events.ApplicationCommandInteractionCreate) { for _, command := range commands { - if command.Interact != nil && e.SlashCommandInteractionData().CommandName() == command.Definition.CommandName() { + if command.Interact != nil && e.Data.CommandName() == command.Definition.CommandName() { if !command.AllowDM && e.ApplicationCommandInteraction.GuildID().String() == "" { - e.CreateMessage(discord.NewMessageCreateBuilder(). + err := e.CreateMessage(discord.NewMessageCreateBuilder(). SetContent("This command is not available in DMs.").SetEphemeral(true). Build()) + if err != nil { + logrus.Error(err) + } } else { command.Interact(e) }