fixed message context interaction
This commit is contained in:
10
cmd_tag.go
10
cmd_tag.go
@@ -48,7 +48,7 @@ var cmd_tag Command = Command{
|
|||||||
case "get":
|
case "get":
|
||||||
GetTagCommand(e)
|
GetTagCommand(e)
|
||||||
case "add":
|
case "add":
|
||||||
AddTagCommand(e, "")
|
AddTagCommand(e)
|
||||||
case "remove":
|
case "remove":
|
||||||
removeTag(e.GuildID().String(), e.SlashCommandInteractionData().String("tag"))
|
removeTag(e.GuildID().String(), e.SlashCommandInteractionData().String("tag"))
|
||||||
err := e.CreateMessage(discord.NewMessageCreateBuilder().
|
err := e.CreateMessage(discord.NewMessageCreateBuilder().
|
||||||
@@ -103,7 +103,7 @@ var context_tag Command = Command{
|
|||||||
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild),
|
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild),
|
||||||
},
|
},
|
||||||
Interact: func(e *events.ApplicationCommandInteractionCreate) {
|
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{
|
err := e.Modal(discord.ModalCreate{
|
||||||
CustomID: "tag_add_modal" + e.User().ID.String(),
|
CustomID: "tag_add_modal" + e.User().ID.String(),
|
||||||
Title: "Add a custom tag command",
|
Title: "Add a custom tag command",
|
||||||
|
@@ -62,11 +62,14 @@ func ready(e *events.Ready) {
|
|||||||
|
|
||||||
func applicationCommandInteractionCreate(e *events.ApplicationCommandInteractionCreate) {
|
func applicationCommandInteractionCreate(e *events.ApplicationCommandInteractionCreate) {
|
||||||
for _, command := range commands {
|
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() == "" {
|
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).
|
SetContent("This command is not available in DMs.").SetEphemeral(true).
|
||||||
Build())
|
Build())
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
command.Interact(e)
|
command.Interact(e)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user