From e62833b5e1d0ee9314c58792b639b3dbb2ea705b Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Tue, 19 Mar 2019 19:59:45 +0100 Subject: [PATCH] docs: mark getters as @ readonly --- src/client/voice/VoiceBroadcast.js | 1 + src/client/voice/VoiceConnection.js | 1 + src/client/voice/dispatcher/StreamDispatcher.js | 5 +++++ src/client/voice/networking/VoiceWebSocket.js | 1 + src/client/voice/util/VolumeInterface.js | 7 ++++--- src/stores/GuildEmojiRoleStore.js | 1 + src/stores/GuildMemberRoleStore.js | 1 + src/structures/ClientUser.js | 2 +- src/structures/DMChannel.js | 1 + src/structures/GuildMember.js | 1 + src/structures/Message.js | 1 + src/structures/Presence.js | 2 ++ src/structures/User.js | 1 + src/structures/VoiceChannel.js | 1 + src/structures/VoiceState.js | 5 +++++ 15 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/client/voice/VoiceBroadcast.js b/src/client/voice/VoiceBroadcast.js index 602f59205..27c8f7e28 100644 --- a/src/client/voice/VoiceBroadcast.js +++ b/src/client/voice/VoiceBroadcast.js @@ -34,6 +34,7 @@ class VoiceBroadcast extends EventEmitter { /** * The current master dispatcher, if any. This dispatcher controls all that is played by subscribed dispatchers. * @type {?BroadcastDispatcher} + * @readonly */ get dispatcher() { return this.player.dispatcher; diff --git a/src/client/voice/VoiceConnection.js b/src/client/voice/VoiceConnection.js index d0922ae81..727f21968 100644 --- a/src/client/voice/VoiceConnection.js +++ b/src/client/voice/VoiceConnection.js @@ -130,6 +130,7 @@ class VoiceConnection extends EventEmitter { /** * The client that instantiated this connection * @type {Client} + * @readonly */ get client() { return this.voiceManager.client; diff --git a/src/client/voice/dispatcher/StreamDispatcher.js b/src/client/voice/dispatcher/StreamDispatcher.js index e05cd49ec..71e6e1611 100644 --- a/src/client/voice/dispatcher/StreamDispatcher.js +++ b/src/client/voice/dispatcher/StreamDispatcher.js @@ -146,12 +146,14 @@ class StreamDispatcher extends Writable { /** * Whether or not playback is paused * @type {boolean} + * @readonly */ get paused() { return Boolean(this.pausedSince); } /** * Total time that this dispatcher has been paused * @type {number} + * @readonly */ get pausedTime() { return this._silentPausedTime + this._pausedTime + (this.paused ? Date.now() - this.pausedSince : 0); @@ -177,6 +179,7 @@ class StreamDispatcher extends Writable { /** * The time (in milliseconds) that the dispatcher has actually been playing audio for * @type {number} + * @readonly */ get streamTime() { return this.count * FRAME_LENGTH; @@ -185,6 +188,7 @@ class StreamDispatcher extends Writable { /** * The time (in milliseconds) that the dispatcher has been playing audio for, taking into account skips and pauses * @type {number} + * @readonly */ get totalStreamTime() { return Date.now() - this.startTime; @@ -322,6 +326,7 @@ class StreamDispatcher extends Writable { /** * Whether or not the Opus bitrate of this stream is editable * @type {boolean} + * @readonly */ get bitrateEditable() { return this.streams.opus && this.streams.opus.setBitrate; } diff --git a/src/client/voice/networking/VoiceWebSocket.js b/src/client/voice/networking/VoiceWebSocket.js index 3720afa74..8f1e8340d 100644 --- a/src/client/voice/networking/VoiceWebSocket.js +++ b/src/client/voice/networking/VoiceWebSocket.js @@ -32,6 +32,7 @@ class VoiceWebSocket extends EventEmitter { /** * The client of this voice WebSocket * @type {Client} + * @readonly */ get client() { return this.connection.voiceManager.client; diff --git a/src/client/voice/util/VolumeInterface.js b/src/client/voice/util/VolumeInterface.js index a631e6caf..ba162a947 100644 --- a/src/client/voice/util/VolumeInterface.js +++ b/src/client/voice/util/VolumeInterface.js @@ -15,6 +15,7 @@ class VolumeInterface extends EventEmitter { /** * Whether or not the volume of this stream is editable * @type {boolean} + * @readonly */ get volumeEditable() { return true; @@ -22,8 +23,8 @@ class VolumeInterface extends EventEmitter { /** * The current volume of the stream - * @readonly * @type {number} + * @readonly */ get volume() { return this._volume; @@ -31,8 +32,8 @@ class VolumeInterface extends EventEmitter { /** * The current volume of the stream in decibels - * @readonly * @type {number} + * @readonly */ get volumeDecibels() { return Math.log10(this.volume) * 20; @@ -40,8 +41,8 @@ class VolumeInterface extends EventEmitter { /** * The current volume of the stream from a logarithmic scale - * @readonly * @type {number} + * @readonly */ get volumeLogarithmic() { return Math.pow(this.volume, 1 / 1.660964); diff --git a/src/stores/GuildEmojiRoleStore.js b/src/stores/GuildEmojiRoleStore.js index 8c097f564..2051161d9 100644 --- a/src/stores/GuildEmojiRoleStore.js +++ b/src/stores/GuildEmojiRoleStore.js @@ -20,6 +20,7 @@ class GuildEmojiRoleStore extends Collection { * The filtered collection of roles of the guild emoji * @type {Collection} * @private + * @readonly */ get _filtered() { return this.guild.roles.filter(role => this.emoji._roles.includes(role.id)); diff --git a/src/stores/GuildMemberRoleStore.js b/src/stores/GuildMemberRoleStore.js index 9ab340d68..7b44a3536 100644 --- a/src/stores/GuildMemberRoleStore.js +++ b/src/stores/GuildMemberRoleStore.js @@ -20,6 +20,7 @@ class GuildMemberRoleStore extends Collection { * The filtered collection of roles of the member * @type {Collection} * @private + * @readonly */ get _filtered() { const everyone = this.guild.defaultRole; diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index a86a6cb56..20bc42b9f 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -30,8 +30,8 @@ class ClientUser extends Structures.get('User') { /** * ClientUser's presence - * @readonly * @type {Presence} + * @readonly */ get presence() { return this.client.presence; diff --git a/src/structures/DMChannel.js b/src/structures/DMChannel.js index f1280e802..e58942c3e 100644 --- a/src/structures/DMChannel.js +++ b/src/structures/DMChannel.js @@ -49,6 +49,7 @@ class DMChannel extends Channel { /** * Whether this DMChannel is a partial * @type {boolean} + * @readonly */ get partial() { return !this.recipient; diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index 91f54c8c9..d479dd772 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -83,6 +83,7 @@ class GuildMember extends Base { /** * Whether this GuildMember is a partial * @type {boolean} + * @readonly */ get partial() { return !this.joinedTimestamp; diff --git a/src/structures/Message.js b/src/structures/Message.js index e302de265..afdb5e2c4 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -172,6 +172,7 @@ class Message extends Base { /** * Whether or not this message is a partial * @type {boolean} + * @readonly */ get partial() { return typeof this.content !== 'string' || !this.author; diff --git a/src/structures/Presence.js b/src/structures/Presence.js index baacab138..5d82ac07e 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -45,6 +45,7 @@ class Presence { /** * The user of this presence * @type {?User} + * @readonly */ get user() { return this.client.users.get(this.userID) || null; @@ -53,6 +54,7 @@ class Presence { /** * The member of this presence * @type {?GuildMember} + * @readonly */ get member() { return this.guild.members.get(this.userID) || null; diff --git a/src/structures/User.js b/src/structures/User.js index f510ee137..a0436f7e8 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -78,6 +78,7 @@ class User extends Base { /** * Whether this User is a partial * @type {boolean} + * @readonly */ get partial() { return typeof this.username !== 'string'; diff --git a/src/structures/VoiceChannel.js b/src/structures/VoiceChannel.js index 2d1fa956e..8b49715fd 100644 --- a/src/structures/VoiceChannel.js +++ b/src/structures/VoiceChannel.js @@ -30,6 +30,7 @@ class VoiceChannel extends GuildChannel { * The members in this voice channel * @type {Collection} * @name VoiceChannel#members + * @readonly */ get members() { const coll = new Collection(); diff --git a/src/structures/VoiceState.js b/src/structures/VoiceState.js index 82f9eec71..9ff71e87a 100644 --- a/src/structures/VoiceState.js +++ b/src/structures/VoiceState.js @@ -58,6 +58,7 @@ class VoiceState extends Base { /** * The member that this voice state belongs to * @type {?GuildMember} + * @readonly */ get member() { return this.guild.members.get(this.id) || null; @@ -66,6 +67,7 @@ class VoiceState extends Base { /** * The channel that the member is connected to * @type {?VoiceChannel} + * @readonly */ get channel() { return this.guild.channels.get(this.channelID) || null; @@ -74,6 +76,7 @@ class VoiceState extends Base { /** * Whether this member is either self-deafened or server-deafened * @type {?boolean} + * @readonly */ get deaf() { return this.serverDeaf || this.selfDeaf; @@ -82,6 +85,7 @@ class VoiceState extends Base { /** * Whether this member is either self-muted or server-muted * @type {?boolean} + * @readonly */ get mute() { return this.serverMute || this.selfMute; @@ -91,6 +95,7 @@ class VoiceState extends Base { * Whether this member is currently speaking. A boolean if the information is available (aka * the bot is connected to any voice channel in the guild), otherwise this is null * @type {?boolean} + * @readonly */ get speaking() { return this.channel && this.channel.connection ?