mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
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:
62
src/structures/TeamMember.js
Normal file
62
src/structures/TeamMember.js
Normal 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;
|
||||
Reference in New Issue
Block a user