aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/bwmarrin/discordgo/interactions.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo/interactions.go')
-rw-r--r--vendor/github.com/bwmarrin/discordgo/interactions.go57
1 files changed, 45 insertions, 12 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/interactions.go b/vendor/github.com/bwmarrin/discordgo/interactions.go
index 0e5ae3c..61a4e99 100644
--- a/vendor/github.com/bwmarrin/discordgo/interactions.go
+++ b/vendor/github.com/bwmarrin/discordgo/interactions.go
@@ -9,6 +9,7 @@ import (
"io"
"io/ioutil"
"net/http"
+ "strconv"
"time"
)
@@ -32,15 +33,21 @@ const (
type ApplicationCommand struct {
ID string `json:"id,omitempty"`
ApplicationID string `json:"application_id,omitempty"`
+ GuildID string `json:"guild_id,omitempty"`
Version string `json:"version,omitempty"`
Type ApplicationCommandType `json:"type,omitempty"`
Name string `json:"name"`
- DefaultPermission *bool `json:"default_permission,omitempty"`
+ NameLocalizations *map[Locale]string `json:"name_localizations,omitempty"`
+ // NOTE: DefaultPermission will be soon deprecated. Use DefaultMemberPermissions and DMPermission instead.
+ DefaultPermission *bool `json:"default_permission,omitempty"`
+ DefaultMemberPermissions *int64 `json:"default_member_permissions,string,omitempty"`
+ DMPermission *bool `json:"dm_permission,omitempty"`
// NOTE: Chat commands only. Otherwise it mustn't be set.
- Description string `json:"description,omitempty"`
- Options []*ApplicationCommandOption `json:"options"`
+ Description string `json:"description,omitempty"`
+ DescriptionLocalizations *map[Locale]string `json:"description_localizations,omitempty"`
+ Options []*ApplicationCommandOption `json:"options"`
}
// ApplicationCommandOptionType indicates the type of a slash command's option.
@@ -91,9 +98,11 @@ func (t ApplicationCommandOptionType) String() string {
// ApplicationCommandOption represents an option/subcommand/subcommands group.
type ApplicationCommandOption struct {
- Type ApplicationCommandOptionType `json:"type"`
- Name string `json:"name"`
- Description string `json:"description,omitempty"`
+ Type ApplicationCommandOptionType `json:"type"`
+ Name string `json:"name"`
+ NameLocalizations map[Locale]string `json:"name_localizations,omitempty"`
+ Description string `json:"description,omitempty"`
+ DescriptionLocalizations map[Locale]string `json:"description_localizations,omitempty"`
// 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"`
@@ -109,12 +118,17 @@ type ApplicationCommandOption struct {
MinValue *float64 `json:"min_value,omitempty"`
// Maximum value of number/integer option.
MaxValue float64 `json:"max_value,omitempty"`
+ // Minimum length of string option.
+ MinLength *int `json:"min_length,omitempty"`
+ // Maximum length of string option.
+ MaxLength int `json:"max_length,omitempty"`
}
// ApplicationCommandOptionChoice represents a slash command option choice.
type ApplicationCommandOptionChoice struct {
- Name string `json:"name"`
- Value interface{} `json:"value"`
+ Name string `json:"name"`
+ NameLocalizations map[Locale]string `json:"name_localizations,omitempty"`
+ Value interface{} `json:"value"`
}
// ApplicationCommandPermissions represents a single user or role permission for a command.
@@ -124,6 +138,18 @@ type ApplicationCommandPermissions struct {
Permission bool `json:"permission"`
}
+// GuildAllChannelsID is a helper function which returns guild_id-1.
+// It is used in ApplicationCommandPermissions to target all the channels within a guild.
+func GuildAllChannelsID(guild string) (id string, err error) {
+ var v uint64
+ v, err = strconv.ParseUint(guild, 10, 64)
+ if err != nil {
+ return
+ }
+
+ return strconv.FormatUint(v-1, 10), nil
+}
+
// ApplicationCommandPermissionsList represents a list of ApplicationCommandPermissions, needed for serializing to JSON.
type ApplicationCommandPermissionsList struct {
Permissions []*ApplicationCommandPermissions `json:"permissions"`
@@ -142,8 +168,9 @@ type ApplicationCommandPermissionType uint8
// Application command permission types.
const (
- ApplicationCommandPermissionTypeRole ApplicationCommandPermissionType = 1
- ApplicationCommandPermissionTypeUser ApplicationCommandPermissionType = 2
+ ApplicationCommandPermissionTypeRole ApplicationCommandPermissionType = 1
+ ApplicationCommandPermissionTypeUser ApplicationCommandPermissionType = 2
+ ApplicationCommandPermissionTypeChannel ApplicationCommandPermissionType = 3
)
// InteractionType indicates the type of an interaction event.
@@ -175,6 +202,7 @@ func (t InteractionType) String() string {
// Interaction represents data of an interaction.
type Interaction struct {
ID string `json:"id"`
+ AppID string `json:"application_id"`
Type InteractionType `json:"type"`
Data InteractionData `json:"data"`
GuildID string `json:"guild_id"`
@@ -184,6 +212,9 @@ type Interaction struct {
// NOTE: this field is only filled when a button click triggered the interaction. Otherwise it will be nil.
Message *Message `json:"message"`
+ // Bitwise set of permissions the app or bot has within the channel the interaction was sent from
+ AppPermissions int64 `json:"app_permissions,string"`
+
// The member who invoked this interaction.
// NOTE: this field is only filled when the slash command was invoked in a guild;
// if it was invoked in a DM, the `User` field will be filled instead.
@@ -509,11 +540,13 @@ type InteractionResponseData struct {
TTS bool `json:"tts"`
Content string `json:"content"`
Components []MessageComponent `json:"components"`
- Embeds []*MessageEmbed `json:"embeds,omitempty"`
+ Embeds []*MessageEmbed `json:"embeds"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
- Flags uint64 `json:"flags,omitempty"`
Files []*File `json:"-"`
+ // NOTE: only MessageFlagsSuppressEmbeds and MessageFlagsEphemeral can be set.
+ Flags MessageFlags `json:"flags,omitempty"`
+
// NOTE: autocomplete interaction only.
Choices []*ApplicationCommandOptionChoice `json:"choices,omitempty"`