feature: teams support (#3350)

* basic teams support

* export Team & TeamMember

* use typedef

* typings and some fixes

* Update src/structures/TeamMember.js

Co-Authored-By: Vlad Frangu <kingdgrizzle@gmail.com>

* fix Team#iconURL()

* fix typings and a bug

* fix states start at 1

* team icon hash can be null

* fix owner typings
This commit is contained in:
bdistin
2019-06-25 13:31:48 -05:00
committed by SpaceEEC
parent 6100aceef2
commit a22aabf6a8
6 changed files with 223 additions and 3 deletions

View File

@@ -0,0 +1,62 @@
'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(client, team, data) {
super(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 reguard to the team
* @type {string[]}
*/
this.permissions = data.permissions;
/**
* The permissions this Team Member has with reguard 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}
*/
this.id = this.user.id;
}
/**
* When concatenated with a string, this automatically returns the team members's tag instead of the
* TeamMember object.
* @returns {string}
* @example
* // Logs: Team Member's tag: @Hydrabolt
* console.log(`Team Member's tag: ${teamMember}`);
*/
toString() {
return this.user.toString();
}
}
module.exports = TeamMember;