sendingnetwork-bot-sdk
Version:
TypeScript/JavaScript SDK for SDN bots
45 lines • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDNProfile = void 0;
const __1 = require("..");
/**
* Represents a user's profile, possibly in a room.
* @category Models
*/
class SDNProfile {
/**
* Creates a new profile representation for a user.
* @param {string} userId The user ID the profile is for.
* @param {SDNProfile} profile The profile itself.
*/
constructor(userId, profile) {
this.userId = userId;
this.profile = profile;
}
/**
* The display name for the user. This will always return a value, though it
* may be based upon their user ID if no explicit display name is set.
*/
get displayName() {
var _a;
if (!((_a = this.profile) === null || _a === void 0 ? void 0 : _a.displayname))
return new __1.UserID(this.userId).localpart;
return this.profile.displayname;
}
/**
* The avatar URL for the user. If the user does not have an avatar, this will
* be null.
*/
get avatarUrl() {
var _a;
return ((_a = this.profile) === null || _a === void 0 ? void 0 : _a.avatar_url) || null; // enforce null over boolean semantics
}
/**
* A mention pill for this user.
*/
get mention() {
return __1.MentionPill.withDisplayName(this.userId, this.displayName);
}
}
exports.SDNProfile = SDNProfile;
//# sourceMappingURL=SDNProfile.js.map