feat: add and remove members from a team
This commit is contained in:
parent
a32c7292df
commit
baf038539b
@ -215,6 +215,8 @@ const Messages = {
|
|||||||
LOGIN_FAILED_UNKNOWN: 'Login failed',
|
LOGIN_FAILED_UNKNOWN: 'Login failed',
|
||||||
LOGIN_FAILED_2FA: 'Login failed, 2FA code is required',
|
LOGIN_FAILED_2FA: 'Login failed, 2FA code is required',
|
||||||
GUILD_IS_LARGE: 'This guild is too large to fetch all members with this method',
|
GUILD_IS_LARGE: 'This guild is too large to fetch all members with this method',
|
||||||
|
|
||||||
|
TEAM_MEMBER_FORMAT: 'The member provided is either not real or not of the User class',
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const [name, message] of Object.entries(Messages)) register(name, message);
|
for (const [name, message] of Object.entries(Messages)) register(name, message);
|
||||||
|
@ -46,6 +46,22 @@ class DeveloperPortalManager extends BaseManager {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Team.
|
||||||
|
* @param {string} name Name of the team
|
||||||
|
* @returns {Promise<Team>}
|
||||||
|
*/
|
||||||
|
async createTeam(name) {
|
||||||
|
const team = await this.client.api.teams.post({
|
||||||
|
data: {
|
||||||
|
name: name,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.teams.set(team.id, new Team(this.client, team));
|
||||||
|
return this.teams.get(team.id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new application.
|
* Creates a new application.
|
||||||
* @param {string} name Name of the application
|
* @param {string} name Name of the application
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const TeamMember = require('./TeamMember');
|
const TeamMember = require('./TeamMember');
|
||||||
|
const User = require('./User');
|
||||||
|
const { Error } = require('../errors');
|
||||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,6 +100,36 @@ class Team extends Base {
|
|||||||
return this.client.rest.cdn.TeamIcon(this.id, this.icon, { format, size });
|
return this.client.rest.cdn.TeamIcon(this.id, this.icon, { format, size });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invite a team member to the team
|
||||||
|
* @param {User} user The user to invite to the team
|
||||||
|
* @param {string} MFACode The mfa code
|
||||||
|
* @returns {Promise<TeamMember>}
|
||||||
|
*/
|
||||||
|
async inviteMember(user, MFACode) {
|
||||||
|
if (!(user instanceof User)) return new Error('TEAM_MEMBER_FORMAT');
|
||||||
|
const payload = {
|
||||||
|
username: user.username,
|
||||||
|
discriminator: user.discriminator,
|
||||||
|
};
|
||||||
|
if (MFACode) payload.code = MFACode;
|
||||||
|
|
||||||
|
const member = await this.client.api.teams(this.id).members.post({
|
||||||
|
data: payload,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.members.set(member.user.id, new TeamMember(this, member));
|
||||||
|
return this.members.get(member.user.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a member from the team
|
||||||
|
* @param {Snowflake} userID The ID of the user you want to remove
|
||||||
|
*/
|
||||||
|
async removeMember(userID) {
|
||||||
|
await this.client.api.teams[this.id].members[userID].delete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When concatenated with a string, this automatically returns the Team's name instead of the
|
* When concatenated with a string, this automatically returns the Team's name instead of the
|
||||||
* Team object.
|
* Team object.
|
||||||
|
Loading…
Reference in New Issue
Block a user