discord: Add User.DisplayOr{Username,Tag}

This commit is contained in:
diamondburned 2023-06-08 22:45:40 -07:00
parent 2b0395ab12
commit 4224b93c4e
No known key found for this signature in database
GPG Key ID: D78C4471CE776659
1 changed files with 18 additions and 2 deletions

View File

@ -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 {