Update dependencies and fix whatsmeow API changes (#1887)

* Update dependencies

* Fix whatsmau API changes
This commit is contained in:
Wim
2022-09-05 21:00:54 +02:00
committed by GitHub
parent 7abf1a5884
commit fda05f2262
44 changed files with 2008 additions and 1703 deletions

View File

@@ -9,6 +9,7 @@ import (
"io"
"io/ioutil"
"net/http"
"strconv"
"time"
)
@@ -32,11 +33,15 @@ 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"`
NameLocalizations *map[Locale]string `json:"name_localizations,omitempty"`
DefaultPermission *bool `json:"default_permission,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.
@@ -113,6 +118,10 @@ 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.
@@ -129,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"`
@@ -147,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.
@@ -190,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.
@@ -517,9 +542,11 @@ type InteractionResponseData struct {
Components []MessageComponent `json:"components"`
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"`