mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
feat: api v9 and threads (#5570)
Co-authored-by: Noel <icrawltogo@gmail.com> Co-authored-by: Amish Shah <dev@shah.gg> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: SynthGhost <60333233+synthghost@users.noreply.github.com> Co-authored-by: SpaceEEC <24881032+SpaceEEC@users.noreply.github.com> Co-authored-by: Elliot <elliot@maisl.fr> Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
95
src/structures/ThreadMember.js
Normal file
95
src/structures/ThreadMember.js
Normal file
@@ -0,0 +1,95 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const ThreadMemberFlags = require('../util/ThreadMemberFlags');
|
||||
|
||||
/**
|
||||
* Represents a Member for a Thread.
|
||||
* @extends {Base}
|
||||
*/
|
||||
class ThreadMember extends Base {
|
||||
/**
|
||||
* @param {ThreadChannel} thread The thread that this member is associated with
|
||||
* @param {Object} data The data for the thread member
|
||||
*/
|
||||
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 id of the thread member
|
||||
* @type {Snowflake}
|
||||
*/
|
||||
this.id = data.user_id;
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
this.joinedTimestamp = new Date(data.join_timestamp).getTime();
|
||||
|
||||
/**
|
||||
* The flags for this thread member
|
||||
* @type {ThreadMemberFlags}
|
||||
*/
|
||||
this.flags = new ThreadMemberFlags(data.flags).freeze();
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild member that this thread member instance represents
|
||||
* @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) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The user that this thread member instance represents
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this member from the thread.
|
||||
* @param {string} [reason] Reason for removing the member
|
||||
* @returns {ThreadMember}
|
||||
*/
|
||||
remove(reason) {
|
||||
return this.thread.members.remove(this.id, reason).then(() => this);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ThreadMember;
|
||||
Reference in New Issue
Block a user