66 lines
1.4 KiB
JavaScript
66 lines
1.4 KiB
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
const Base = require('./Base');
|
||
|
const { MembershipStates } = require('../util/Constants');
|
||
|
|
||
|
/**
|
||
|
* Represents a Client OAuth2 Application Team Member.
|
||
|
* @extends {Base}
|
||
|
*/
|
||
|
class TeamMember extends Base {
|
||
|
constructor(team, data) {
|
||
|
super(team.client);
|
||
|
|
||
|
/**
|
||
|
* The Team this member is part of
|
||
|
* @type {Team}
|
||
|
*/
|
||
|
this.team = team;
|
||
|
|
||
|
this._patch(data);
|
||
|
}
|
||
|
|
||
|
_patch(data) {
|
||
|
/**
|
||
|
* The permissions this Team Member has with regard to the team
|
||
|
* @type {string[]}
|
||
|
*/
|
||
|
this.permissions = data.permissions;
|
||
|
|
||
|
/**
|
||
|
* The permissions this Team Member has with regard to the team
|
||
|
* @type {MembershipStates}
|
||
|
*/
|
||
|
this.membershipState = MembershipStates[data.membership_state];
|
||
|
|
||
|
/**
|
||
|
* The user for this Team Member
|
||
|
* @type {User}
|
||
|
*/
|
||
|
this.user = this.client.users.add(data.user);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* The ID of the Team Member
|
||
|
* @type {Snowflake}
|
||
|
* @readonly
|
||
|
*/
|
||
|
get id() {
|
||
|
return this.user.id;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* When concatenated with a string, this automatically returns the team members's mention instead of the
|
||
|
* TeamMember object.
|
||
|
* @returns {string}
|
||
|
* @example
|
||
|
* // Logs: Team Member's mention: <@123456789012345678>
|
||
|
* console.log(`Team Member's mention: ${teamMember}`);
|
||
|
*/
|
||
|
toString() {
|
||
|
return this.user.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = TeamMember;
|