refactor: add to index.d.ts & change MFACode type
This commit is contained in:
		@@ -11,6 +11,8 @@ const Messages = {
 | 
				
			|||||||
  TOKEN_INVALID: 'An invalid token was provided.',
 | 
					  TOKEN_INVALID: 'An invalid token was provided.',
 | 
				
			||||||
  TOKEN_MISSING: 'Request to use token, but token was unavailable to the client.',
 | 
					  TOKEN_MISSING: 'Request to use token, but token was unavailable to the client.',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MFA_INVALID: 'An invalid mfa code was provided',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  WS_CLOSE_REQUESTED: 'WebSocket closed due to user request.',
 | 
					  WS_CLOSE_REQUESTED: 'WebSocket closed due to user request.',
 | 
				
			||||||
  WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
 | 
					  WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
 | 
				
			||||||
  WS_NOT_OPEN: (data = 'data') => `WebSocket not open to send ${data}`,
 | 
					  WS_NOT_OPEN: (data = 'data') => `WebSocket not open to send ${data}`,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103,15 +103,18 @@ class Team extends Base {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Invite a team member to the team
 | 
					   * Invite a team member to the team
 | 
				
			||||||
   * @param {User} user The user to invite to the team
 | 
					   * @param {User} user The user to invite to the team
 | 
				
			||||||
   * @param {string} MFACode The mfa code
 | 
					   * @param {number} MFACode The mfa code
 | 
				
			||||||
   * @returns {Promise<TeamMember>}
 | 
					   * @returns {Promise<TeamMember>}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  async inviteMember(user, MFACode) {
 | 
					  async inviteMember(user, MFACode) {
 | 
				
			||||||
    if (!(user instanceof User)) return new Error('TEAM_MEMBER_FORMAT');
 | 
					    if (!(user instanceof User)) return new Error('TEAM_MEMBER_FORMAT');
 | 
				
			||||||
 | 
					    const regex = /([0-9]{6})/g;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const payload = {
 | 
					    const payload = {
 | 
				
			||||||
      username: user.username,
 | 
					      username: user.username,
 | 
				
			||||||
      discriminator: user.discriminator,
 | 
					      discriminator: user.discriminator,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					    if (MFACode && !regex.test(MFACode)) return new Error('MFA_INVALID');
 | 
				
			||||||
    if (MFACode) payload.code = MFACode;
 | 
					    if (MFACode) payload.code = MFACode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const member = await this.client.api.teams(this.id).members.post({
 | 
					    const member = await this.client.api.teams(this.id).members.post({
 | 
				
			||||||
@@ -125,18 +128,22 @@ class Team extends Base {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Remove a member from the team
 | 
					   * Remove a member from the team
 | 
				
			||||||
   * @param {Snowflake} userID The ID of the user you want to remove
 | 
					   * @param {Snowflake} userID The ID of the user you want to remove
 | 
				
			||||||
 | 
					   * @returns {boolean}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  async removeMember(userID) {
 | 
					  async removeMember(userID) {
 | 
				
			||||||
    await this.client.api.teams[this.id].members[userID].delete();
 | 
					    await this.client.api.teams[this.id].members[userID].delete();
 | 
				
			||||||
 | 
					    return this.members.delete(userID);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Delete this team
 | 
					   * Delete this team
 | 
				
			||||||
   * @param {string} code The 2fa code
 | 
					   * @param {number} MFACode The 2fa code
 | 
				
			||||||
   * @returns {Promise<boolean>}
 | 
					   * @returns {Promise<boolean>}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  async delete(code) {
 | 
					  async delete(MFACode) {
 | 
				
			||||||
    await this.client.api.teams[this.id].delete({ data: { code: code } });
 | 
					    const regex = /([0-9]{6})/g;
 | 
				
			||||||
 | 
					    if (!regex.test(MFACode)) return new Error('MFA_INVALID');
 | 
				
			||||||
 | 
					    await this.client.api.teams[this.id].delete({ data: { code: MFACode } });
 | 
				
			||||||
    return this.client.developerPortal.teams.delete(this.id);
 | 
					    return this.client.developerPortal.teams.delete(this.id);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								typings/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								typings/index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -457,6 +457,7 @@ export class DeveloperPortalManager extends BaseManager {
 | 
				
			|||||||
  public applications: Collection<Snowflake, DeveloperPortalApplication>;
 | 
					  public applications: Collection<Snowflake, DeveloperPortalApplication>;
 | 
				
			||||||
  public teams: Collection<Snowflake, Team>;
 | 
					  public teams: Collection<Snowflake, Team>;
 | 
				
			||||||
  public fetch(): Promise<DeveloperPortalManager>;
 | 
					  public fetch(): Promise<DeveloperPortalManager>;
 | 
				
			||||||
 | 
					  public createTeam(name: string): Promise<Team>;
 | 
				
			||||||
  public createApplication(name: string, teamId?: Team | Snowflake): Promise<DeveloperPortalApplication>;
 | 
					  public createApplication(name: string, teamId?: Team | Snowflake): Promise<DeveloperPortalApplication>;
 | 
				
			||||||
  public deleteApplication(id: Snowflake, MFACode?: number): Promise<undefined>;
 | 
					  public deleteApplication(id: Snowflake, MFACode?: number): Promise<undefined>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -2889,6 +2890,9 @@ export class Team extends Base {
 | 
				
			|||||||
  public readonly createdTimestamp: number;
 | 
					  public readonly createdTimestamp: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public iconURL(options?: StaticImageURLOptions): string | null;
 | 
					  public iconURL(options?: StaticImageURLOptions): string | null;
 | 
				
			||||||
 | 
					  public inviteMemeber(user: User, MFACode: number): Promise<TeamMember>;
 | 
				
			||||||
 | 
					  public removeMemeber(userID: Snowflake): boolean;
 | 
				
			||||||
 | 
					  public delete(MFACode: string): Promise<boolean>;
 | 
				
			||||||
  public toJSON(): unknown;
 | 
					  public toJSON(): unknown;
 | 
				
			||||||
  public toString(): string;
 | 
					  public toString(): string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user