Skip to content

Commit

Permalink
discord: Add User.DisplayOr{Username,Tag}
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Jun 9, 2023
1 parent 2b0395a commit 4224b93
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions discord/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,29 @@ func (u User) Mention() string {

// Tag returns a tag of the user.
func (u User) Tag() string {
if u.Discriminator == "0" {
if u.Discriminator == "0" || u.Discriminator == "0000" {
return u.Username
}

return u.Username + "#" + u.Discriminator
}

// DisplayOrUsername returns the DisplayName if it is set, otherwise the
// Username.
func (u User) DisplayOrUsername() string {
if u.DisplayName != "" {
return u.DisplayName
}
return u.Username
}

// DisplayOrTag returns the DisplayName if it is set, otherwise the Tag.
func (u User) DisplayOrTag() string {
if u.DisplayName != "" {
return u.DisplayName
}
return u.Tag()
}

// AvatarURL returns the URL of the Avatar Image. It automatically detects a
// suitable type.
func (u User) AvatarURL() string {
Expand Down

0 comments on commit 4224b93

Please sign in to comment.