mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
add (incomplete) docs for guildmember
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -6,8 +6,20 @@ const TextBasedChannel = require('./interface/TextBasedChannel');
|
|||||||
*/
|
*/
|
||||||
class GuildMember {
|
class GuildMember {
|
||||||
constructor(guild, data) {
|
constructor(guild, data) {
|
||||||
|
/**
|
||||||
|
* The client that instantiated this GuildMember
|
||||||
|
* @type {Client}
|
||||||
|
*/
|
||||||
this.client = guild.client;
|
this.client = guild.client;
|
||||||
|
/**
|
||||||
|
* The guild that this member is part of
|
||||||
|
* @type {Guild}
|
||||||
|
*/
|
||||||
this.guild = guild;
|
this.guild = guild;
|
||||||
|
/**
|
||||||
|
* The user that this guild member instance Represents
|
||||||
|
* @type {User}
|
||||||
|
*/
|
||||||
this.user = {};
|
this.user = {};
|
||||||
this._roles = [];
|
this._roles = [];
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -17,16 +29,49 @@ class GuildMember {
|
|||||||
|
|
||||||
setup(data) {
|
setup(data) {
|
||||||
this.user = data.user;
|
this.user = data.user;
|
||||||
|
/**
|
||||||
|
* Whether this member is deafened server-wide
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
this.serverDeaf = data.deaf;
|
this.serverDeaf = data.deaf;
|
||||||
|
/**
|
||||||
|
* Whether this member is muted server-wide
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
this.serverMute = data.mute;
|
this.serverMute = data.mute;
|
||||||
|
/**
|
||||||
|
* Whether this member is self-muted
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
this.selfMute = data.self_mute;
|
this.selfMute = data.self_mute;
|
||||||
|
/**
|
||||||
|
* Whether this member is self-deafened
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
this.selfDeaf = data.self_deaf;
|
this.selfDeaf = data.self_deaf;
|
||||||
|
/**
|
||||||
|
* The voice session ID of this member, if any
|
||||||
|
* @type {?String}
|
||||||
|
*/
|
||||||
this.voiceSessionID = data.session_id;
|
this.voiceSessionID = data.session_id;
|
||||||
|
/**
|
||||||
|
* The voice channel ID of this member, if any
|
||||||
|
* @type {?String}
|
||||||
|
*/
|
||||||
this.voiceChannelID = data.channel_id;
|
this.voiceChannelID = data.channel_id;
|
||||||
|
/**
|
||||||
|
* The date this member joined the guild
|
||||||
|
* @type {Date}
|
||||||
|
*/
|
||||||
this.joinDate = new Date(data.joined_at);
|
this.joinDate = new Date(data.joined_at);
|
||||||
this._roles = data.roles;
|
this._roles = data.roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of roles that are applied to this GuildMember
|
||||||
|
* @type {Array<Role>}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
get roles() {
|
get roles() {
|
||||||
const list = [];
|
const list = [];
|
||||||
const everyoneRole = this.guild.store.get('roles', this.guild.id);
|
const everyoneRole = this.guild.store.get('roles', this.guild.id);
|
||||||
@@ -45,26 +90,54 @@ class GuildMember {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this member is muted in any way
|
||||||
|
* @type {Boolean}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
get mute() {
|
get mute() {
|
||||||
return this.selfMute || this.serverMute;
|
return this.selfMute || this.serverMute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this member is deafened in any way
|
||||||
|
* @type {Boolean}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
get deaf() {
|
get deaf() {
|
||||||
return this.selfDeaf || this.serverDeaf;
|
return this.selfDeaf || this.serverDeaf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The voice channel this member is in, if any
|
||||||
|
* @type {?VoiceChannel}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
get voiceChannel() {
|
get voiceChannel() {
|
||||||
return this.guild.store.get('channels', this.voiceChannelID);
|
return this.guild.store.get('channels', this.voiceChannelID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of this User
|
||||||
|
* @type {String}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
get id() {
|
get id() {
|
||||||
return this.user.id;
|
return this.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes any DM's with this Guild Member
|
||||||
|
* @returns {Promise<DMChannel>}
|
||||||
|
*/
|
||||||
deleteDM() {
|
deleteDM() {
|
||||||
return this.client.rest.methods.deleteChannel(this);
|
return this.client.rest.methods.deleteChannel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kick this member from the Guild
|
||||||
|
* @returns {Promise<GuildMember>}
|
||||||
|
*/
|
||||||
kick() {
|
kick() {
|
||||||
return this.client.rest.methods.kickGuildMember(this.guild, this);
|
return this.client.rest.methods.kickGuildMember(this.guild, this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user