commit
This commit is contained in:
parent
a15c733e45
commit
2a5130cbda
2838 changed files with 288613 additions and 0 deletions
102
node_modules/discord.js/src/structures/ThreadMember.js
generated
vendored
Normal file
102
node_modules/discord.js/src/structures/ThreadMember.js
generated
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const ThreadMemberFlagsBitField = require('../util/ThreadMemberFlagsBitField');
|
||||
|
||||
/**
|
||||
* Represents a Member for a Thread.
|
||||
* @extends {Base}
|
||||
*/
|
||||
class ThreadMember extends Base {
|
||||
constructor(thread, data) {
|
||||
super(thread.client);
|
||||
|
||||
/**
|
||||
* The thread that this member is a part of
|
||||
* @type {ThreadChannel}
|
||||
*/
|
||||
this.thread = thread;
|
||||
|
||||
/**
|
||||
* The timestamp the member last joined the thread at
|
||||
* @type {?number}
|
||||
*/
|
||||
this.joinedTimestamp = null;
|
||||
|
||||
/**
|
||||
* The flags for this thread member. This will be `null` if partial.
|
||||
* @type {?ThreadMemberFlagsBitField}
|
||||
*/
|
||||
this.flags = null;
|
||||
|
||||
/**
|
||||
* The id of the thread member
|
||||
* @type {Snowflake}
|
||||
*/
|
||||
this.id = data.user_id;
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
if ('join_timestamp' in data) this.joinedTimestamp = Date.parse(data.join_timestamp);
|
||||
if ('flags' in data) this.flags = new ThreadMemberFlagsBitField(data.flags).freeze();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this thread member is a partial
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get partial() {
|
||||
return this.flags === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild member associated with this thread member
|
||||
* @type {?GuildMember}
|
||||
* @readonly
|
||||
*/
|
||||
get guildMember() {
|
||||
return this.thread.guild.members.resolve(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* The last time this member joined the thread
|
||||
* @type {?Date}
|
||||
* @readonly
|
||||
*/
|
||||
get joinedAt() {
|
||||
return this.joinedTimestamp && new Date(this.joinedTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* The user associated with this thread member
|
||||
* @type {?User}
|
||||
* @readonly
|
||||
*/
|
||||
get user() {
|
||||
return this.client.users.resolve(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the client user can manage this thread member
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get manageable() {
|
||||
return !this.thread.archived && this.thread.editable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this member from the thread.
|
||||
* @param {string} [reason] Reason for removing the member
|
||||
* @returns {ThreadMember}
|
||||
*/
|
||||
async remove(reason) {
|
||||
await this.thread.members.remove(this.id, reason);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ThreadMember;
|
Loading…
Add table
Add a link
Reference in a new issue