Ver Fonte

Channel type restriction (#1015)

Fedor Lapshin há 3 anos atrás
pai
commit
4249df2359
2 ficheiros alterados com 10 adições e 4 exclusões
  1. 6 1
      examples/slash_commands/main.go
  2. 4 3
      interactions.go

+ 6 - 1
examples/slash_commands/main.go

@@ -76,7 +76,12 @@ var (
 					Type:        discordgo.ApplicationCommandOptionChannel,
 					Name:        "channel-option",
 					Description: "Channel option",
-					Required:    false,
+					// Channel type mask
+					ChannelTypes: []discordgo.ChannelType{
+						discordgo.ChannelTypeGuildText,
+						discordgo.ChannelTypeGuildVoice,
+					},
+					Required: false,
 				},
 				{
 					Type:        discordgo.ApplicationCommandOptionUser,

+ 4 - 3
interactions.go

@@ -89,9 +89,10 @@ type ApplicationCommandOption struct {
 	// NOTE: This feature was on the API, but at some point developers decided to remove it.
 	// So I commented it, until it will be officially on the docs.
 	// Default     bool                              `json:"default"`
-	Required bool                              `json:"required"`
-	Choices  []*ApplicationCommandOptionChoice `json:"choices"`
-	Options  []*ApplicationCommandOption       `json:"options"`
+	Required     bool                              `json:"required"`
+	Choices      []*ApplicationCommandOptionChoice `json:"choices"`
+	Options      []*ApplicationCommandOption       `json:"options"`
+	ChannelTypes []ChannelType                     `json:"channel_types"`
 }
 
 // ApplicationCommandOptionChoice represents a slash command option choice.