Update dependencies and build to go1.22 (#2113)
* Update dependencies and build to go1.22 * Fix api changes wrt to dependencies * Update golangci config
This commit is contained in:
63
vendor/github.com/bwmarrin/discordgo/user.go
generated
vendored
63
vendor/github.com/bwmarrin/discordgo/user.go
generated
vendored
@@ -1,5 +1,9 @@
|
||||
package discordgo
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// UserFlags is the flags of "user" (see UserFlags* consts)
|
||||
// https://discord.com/developers/docs/resources/user#user-object-user-flags
|
||||
type UserFlags int
|
||||
@@ -20,6 +24,20 @@ const (
|
||||
UserFlagVerifiedBot UserFlags = 1 << 16
|
||||
UserFlagVerifiedBotDeveloper UserFlags = 1 << 17
|
||||
UserFlagDiscordCertifiedModerator UserFlags = 1 << 18
|
||||
UserFlagBotHTTPInteractions UserFlags = 1 << 19
|
||||
UserFlagActiveBotDeveloper UserFlags = 1 << 22
|
||||
)
|
||||
|
||||
// UserPremiumType is the type of premium (nitro) subscription a user has (see UserPremiumType* consts).
|
||||
// https://discord.com/developers/docs/resources/user#user-object-premium-types
|
||||
type UserPremiumType int
|
||||
|
||||
// Valid UserPremiumType values.
|
||||
const (
|
||||
UserPremiumTypeNone UserPremiumType = 0
|
||||
UserPremiumTypeNitroClassic UserPremiumType = 1
|
||||
UserPremiumTypeNitro UserPremiumType = 2
|
||||
UserPremiumTypeNitroBasic UserPremiumType = 3
|
||||
)
|
||||
|
||||
// A User stores all data for an individual Discord user.
|
||||
@@ -44,6 +62,10 @@ type User struct {
|
||||
// The discriminator of the user (4 numbers after name).
|
||||
Discriminator string `json:"discriminator"`
|
||||
|
||||
// The user's display name, if it is set.
|
||||
// For bots, this is the application name.
|
||||
GlobalName string `json:"global_name"`
|
||||
|
||||
// The token of the user. This is only present for
|
||||
// the user represented by the current session.
|
||||
Token string `json:"token"`
|
||||
@@ -70,7 +92,7 @@ type User struct {
|
||||
|
||||
// The type of Nitro subscription on a user's account.
|
||||
// Only available when the request is authorized via a Bearer token.
|
||||
PremiumType int `json:"premium_type"`
|
||||
PremiumType UserPremiumType `json:"premium_type"`
|
||||
|
||||
// Whether the user is an Official Discord System user (part of the urgent message system).
|
||||
System bool `json:"system"`
|
||||
@@ -81,7 +103,14 @@ type User struct {
|
||||
}
|
||||
|
||||
// String returns a unique identifier of the form username#discriminator
|
||||
// or just username, if the discriminator is set to "0".
|
||||
func (u *User) String() string {
|
||||
// If the user has been migrated from the legacy username system, their discriminator is "0".
|
||||
// See https://support-dev.discord.com/hc/en-us/articles/13667755828631
|
||||
if u.Discriminator == "0" {
|
||||
return u.Username
|
||||
}
|
||||
|
||||
return u.Username + "#" + u.Discriminator
|
||||
}
|
||||
|
||||
@@ -91,17 +120,35 @@ func (u *User) Mention() string {
|
||||
}
|
||||
|
||||
// AvatarURL returns a URL to the user's avatar.
|
||||
// size: The size of the user's avatar as a power of two
|
||||
// if size is an empty string, no size parameter will
|
||||
// be added to the URL.
|
||||
//
|
||||
// size: The size of the user's avatar as a power of two
|
||||
// if size is an empty string, no size parameter will
|
||||
// be added to the URL.
|
||||
func (u *User) AvatarURL(size string) string {
|
||||
return avatarURL(u.Avatar, EndpointDefaultUserAvatar(u.Discriminator),
|
||||
EndpointUserAvatar(u.ID, u.Avatar), EndpointUserAvatarAnimated(u.ID, u.Avatar), size)
|
||||
return avatarURL(
|
||||
u.Avatar,
|
||||
EndpointDefaultUserAvatar(u.DefaultAvatarIndex()),
|
||||
EndpointUserAvatar(u.ID, u.Avatar),
|
||||
EndpointUserAvatarAnimated(u.ID, u.Avatar),
|
||||
size,
|
||||
)
|
||||
}
|
||||
|
||||
// BannerURL returns the URL of the users's banner image.
|
||||
// size: The size of the desired banner image as a power of two
|
||||
// Image size can be any power of two between 16 and 4096.
|
||||
//
|
||||
// size: The size of the desired banner image as a power of two
|
||||
// Image size can be any power of two between 16 and 4096.
|
||||
func (u *User) BannerURL(size string) string {
|
||||
return bannerURL(u.Banner, EndpointUserBanner(u.ID, u.Banner), EndpointUserBannerAnimated(u.ID, u.Banner), size)
|
||||
}
|
||||
|
||||
// DefaultAvatarIndex returns the index of the user's default avatar.
|
||||
func (u *User) DefaultAvatarIndex() int {
|
||||
if u.Discriminator == "0" {
|
||||
id, _ := strconv.ParseUint(u.ID, 10, 64)
|
||||
return int((id >> 22) % 6)
|
||||
}
|
||||
|
||||
id, _ := strconv.Atoi(u.Discriminator)
|
||||
return id % 5
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user