Browse Source

add user public flags field and public flag consts (#801)

* add user public flags field and public flag consts

* fix user flag constant initialization and vaalue documentation

* fix user flag constants values
zekro 4 years ago
parent
commit
b806975e3b
1 changed files with 26 additions and 0 deletions
  1. 26 0
      user.go

+ 26 - 0
user.go

@@ -2,6 +2,27 @@ package discordgo
 
 import "strings"
 
+// UserFlags is the flags of "user" (see UserFlags* consts)
+// https://discord.com/developers/docs/resources/user#user-object-user-flags
+type UserFlags int
+
+// Valid UserFlags values
+const (
+	UserFlagDiscordEmployee      UserFlags = 1 << 0
+	UserFlagDiscordPartner                 = 1 << 1
+	UserFlagHypeSquadEvents                = 1 << 2
+	UserFlagBugHunterLevel1                = 1 << 3
+	UserFlagHouseBravery                   = 1 << 6
+	UserFlagHouseBrilliance                = 1 << 7
+	UserFlagHouseBalance                   = 1 << 8
+	UserFlagEarlySupporter                 = 1 << 9
+	UserFlagTeamUser                       = 1 << 10
+	UserFlagSystem                         = 1 << 12
+	UserFlagBugHunterLevel2                = 1 << 14
+	UserFlagVerifiedBot                    = 1 << 16
+	UserFlagVerifiedBotDeveloper           = 1 << 17
+)
+
 // A User stores all data for an individual Discord user.
 type User struct {
 	// The ID of the user.
@@ -36,6 +57,11 @@ type User struct {
 
 	// Whether the user is a bot.
 	Bot bool `json:"bot"`
+
+	// The public flags on a user's account.
+	// This is a combination of bit masks; the presence of a certain flag can
+	// be checked by performing a bitwise AND between this int and the flag.
+	PublicFlags UserFlags `json:"public_flags"`
 }
 
 // String returns a unique identifier of the form username#discriminator