Skip to content

Commit

Permalink
feat: displayName
Browse files Browse the repository at this point in the history
  • Loading branch information
liy77 committed Feb 4, 2024
1 parent 9d7472e commit 04998bb
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/darkcord/src/resources/User.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { DataWithClient, DisplayUserAvatarOptions, ImageSize } from "@typings/index";
import {
DataWithClient,
DisplayUserAvatarOptions,
ImageSize,
} from "@typings/index";
import { userMention } from "@utils/Constants";
import {
APIDMChannel,
Expand Down Expand Up @@ -117,12 +121,19 @@ export class User extends Base {
return this;
}

/**
* The user's avatar decoration url
* @param options options for avatar decoration url
* @returns
*/
avatarDecorationURL(options?: ImageSize) {
if (!this.avatarDecoration) {
return null;
}

let url = RouteBases.cdn + CDNRoutes.userAvatarDecoration(this.id, this.avatarDecoration)
let url =
RouteBases.cdn +
CDNRoutes.userAvatarDecoration(this.id, this.avatarDecoration);

if (options?.size) {
url += "?size=" + options.size.toString();
Expand Down Expand Up @@ -180,6 +191,14 @@ export class User extends Base {
return this.avatarURL(options) ?? this.defaultAvatarURL;
}

/**
* The user's display name
* @returns
*/
displayName() {
return this.globalName ?? this.username;
}

/**
* The user's username and discriminator
*/
Expand Down

0 comments on commit 04998bb

Please sign in to comment.