mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Add more @readonly and clean up some stuff
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -157,8 +157,8 @@ class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* The status for the logged in Client.
|
||||
* @readonly
|
||||
* @type {?number}
|
||||
* @readonly
|
||||
*/
|
||||
get status() {
|
||||
return this.ws.status;
|
||||
@@ -166,8 +166,8 @@ class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* The uptime for the logged in Client.
|
||||
* @readonly
|
||||
* @type {?number}
|
||||
* @readonly
|
||||
*/
|
||||
get uptime() {
|
||||
return this.readyTime ? Date.now() - this.readyTime : null;
|
||||
@@ -175,8 +175,8 @@ class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Returns a Collection, mapping Guild ID to Voice Connections.
|
||||
* @readonly
|
||||
* @type {Collection<string, VoiceConnection>}
|
||||
* @readonly
|
||||
*/
|
||||
get voiceConnections() {
|
||||
return this.voice.connections;
|
||||
|
||||
@@ -16,6 +16,7 @@ class ShardClientUtil {
|
||||
/**
|
||||
* ID of this shard
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
get id() {
|
||||
return this.client.options.shardId;
|
||||
@@ -24,6 +25,7 @@ class ShardClientUtil {
|
||||
/**
|
||||
* Total number of shards
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
get count() {
|
||||
return this.client.options.shardCount;
|
||||
|
||||
@@ -148,19 +148,13 @@ class ClientUser extends User {
|
||||
|
||||
if (data.game) {
|
||||
game = data.game;
|
||||
if (game.url) {
|
||||
game.type = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof data.afk !== 'undefined') {
|
||||
afk = data.afk;
|
||||
if (game.url) game.type = 1;
|
||||
}
|
||||
|
||||
if (typeof data.afk !== 'undefined') afk = data.afk;
|
||||
afk = Boolean(afk);
|
||||
|
||||
this.localPresence = { status, game, afk };
|
||||
|
||||
this.localPresence.since = 0;
|
||||
|
||||
this.client.ws.send({
|
||||
|
||||
@@ -80,6 +80,7 @@ class GroupDMChannel extends Channel {
|
||||
/**
|
||||
* The owner of this Group DM.
|
||||
* @type {User}
|
||||
* @readonly
|
||||
*/
|
||||
get owner() {
|
||||
return this.client.users.get(this.ownerID);
|
||||
|
||||
@@ -59,14 +59,6 @@ class Guild {
|
||||
}
|
||||
}
|
||||
|
||||
_setPresence(id, presence) {
|
||||
if (this.presences.get(id)) {
|
||||
this.presences.get(id).update(presence);
|
||||
return;
|
||||
}
|
||||
this.presences.set(id, new Presence(presence));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the Guild
|
||||
* @param {*} data The raw data of the guild
|
||||
@@ -754,6 +746,14 @@ class Guild {
|
||||
}
|
||||
}
|
||||
|
||||
_setPresence(id, presence) {
|
||||
if (this.presences.get(id)) {
|
||||
this.presences.get(id).update(presence);
|
||||
return;
|
||||
}
|
||||
this.presences.set(id, new Presence(presence));
|
||||
}
|
||||
|
||||
_checkChunks() {
|
||||
if (this._fetchWaiter) {
|
||||
if (this.members.size === this.memberCount) {
|
||||
|
||||
@@ -132,6 +132,7 @@ class GuildMember {
|
||||
/**
|
||||
* The role of the member with the highest position.
|
||||
* @type {Role}
|
||||
* @readonly
|
||||
*/
|
||||
get highestRole() {
|
||||
return this.roles.reduce((prev, role) =>
|
||||
@@ -178,6 +179,7 @@ class GuildMember {
|
||||
/**
|
||||
* The overall set of permissions for the guild member, taking only roles into account
|
||||
* @type {EvaluatedPermissions}
|
||||
* @readonly
|
||||
*/
|
||||
get permissions() {
|
||||
if (this.user.id === this.guild.ownerID) return new EvaluatedPermissions(this, Constants.ALL_PERMISSIONS);
|
||||
@@ -195,6 +197,7 @@ class GuildMember {
|
||||
/**
|
||||
* Whether the member is kickable by the client user.
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get kickable() {
|
||||
if (this.user.id === this.guild.ownerID) return false;
|
||||
@@ -207,6 +210,7 @@ class GuildMember {
|
||||
/**
|
||||
* Whether the member is bannable by the client user.
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get bannable() {
|
||||
if (this.user.id === this.guild.ownerID) return false;
|
||||
|
||||
@@ -215,6 +215,7 @@ class Message {
|
||||
/**
|
||||
* The guild the message was sent in (if in a guild channel)
|
||||
* @type {?Guild}
|
||||
* @readonly
|
||||
*/
|
||||
get guild() {
|
||||
return this.channel.guild || null;
|
||||
@@ -224,6 +225,7 @@ class Message {
|
||||
* The message contents with all mentions replaced by the equivalent text. If mentions cannot be resolved to a name,
|
||||
* the relevant mention in the message content will not be converted.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
get cleanContent() {
|
||||
return this.content
|
||||
@@ -262,6 +264,7 @@ class Message {
|
||||
* An array of cached versions of the message, including the current version.
|
||||
* Sorted from latest (first) to oldest (last).
|
||||
* @type {Message[]}
|
||||
* @readonly
|
||||
*/
|
||||
get edits() {
|
||||
return this._edits.slice().unshift(this);
|
||||
@@ -270,6 +273,7 @@ class Message {
|
||||
/**
|
||||
* Whether the message is editable by the client user.
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get editable() {
|
||||
return this.author.id === this.client.user.id;
|
||||
@@ -278,6 +282,7 @@ class Message {
|
||||
/**
|
||||
* Whether the message is deletable by the client user.
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get deletable() {
|
||||
return this.author.id === this.client.user.id || (this.guild &&
|
||||
@@ -288,6 +293,7 @@ class Message {
|
||||
/**
|
||||
* Whether the message is pinnable by the client user.
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get pinnable() {
|
||||
return !this.guild ||
|
||||
|
||||
@@ -103,6 +103,7 @@ class Role {
|
||||
/**
|
||||
* The cached guild members that have this role.
|
||||
* @type {Collection<string, GuildMember>}
|
||||
* @readonly
|
||||
*/
|
||||
get members() {
|
||||
return this.guild.members.filter(m => m.roles.has(this.id));
|
||||
|
||||
@@ -76,8 +76,8 @@ class User {
|
||||
|
||||
/**
|
||||
* The presence of this user
|
||||
* @readonly
|
||||
* @type {Presence}
|
||||
* @readonly
|
||||
*/
|
||||
get presence() {
|
||||
if (this.client.presences.has(this.id)) return this.client.presences.get(this.id);
|
||||
|
||||
@@ -241,6 +241,7 @@ class TextBasedChannel {
|
||||
/**
|
||||
* Whether or not the typing indicator is being shown in the channel.
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get typing() {
|
||||
return this.client.user._typing.has(this.id);
|
||||
@@ -249,6 +250,7 @@ class TextBasedChannel {
|
||||
/**
|
||||
* Number of times `startTyping` has been called.
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
get typingCount() {
|
||||
if (this.client.user._typing.has(this.id)) return this.client.user._typing.get(this.id).count;
|
||||
|
||||
Reference in New Issue
Block a user