Some comments
This commit is contained in:
parent
a1c6f5d5fd
commit
21ff9d200c
|
@ -104,7 +104,7 @@ export default class DiscordApi {
|
|||
}
|
||||
|
||||
/**
|
||||
* An array of guild ID in the order they appear in the server list.
|
||||
* An array of guild IDs in the order they appear in the server list.
|
||||
*/
|
||||
static get guildPositions() {
|
||||
return Modules.SortedGuildStore.guildPositions;
|
||||
|
|
|
@ -108,6 +108,13 @@ export class Channel {
|
|||
Modules.NavigationUtils.transitionToGuild(this.guild_id ? this.guild_id : Modules.DiscordConstants.ME, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this channel is currently selected.
|
||||
*/
|
||||
get selected() {
|
||||
return DiscordApi.currentChannel === this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens this channel's settings window.
|
||||
* @param {String} section The section to open (see DiscordConstants.ChannelSettingsSections)
|
||||
|
@ -186,6 +193,9 @@ export class GuildChannel extends Channel {
|
|||
return Channel.fromId(this.parent_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* The current user's permissions on this channel.
|
||||
*/
|
||||
get permissions() {
|
||||
return Modules.GuildPermissions.getChannelPermissions(this.id);
|
||||
}
|
||||
|
@ -199,6 +209,9 @@ export class GuildChannel extends Channel {
|
|||
if (guild) return Guild.from(guild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this channel is the guild's default channel.
|
||||
*/
|
||||
get default_channel() {
|
||||
return Modules.GuildChannelsStore.getDefaultChannel(this.guild_id).id === this.id;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,9 @@ export class Guild {
|
|||
return List.from(members, m => new GuildMember(m, this.id));
|
||||
}
|
||||
|
||||
/**
|
||||
* The current user as a GuildMember of this guild.
|
||||
*/
|
||||
get currentUser() {
|
||||
return this.members.find(m => m.user === DiscordApi.currentUser);
|
||||
}
|
||||
|
@ -179,6 +182,9 @@ export class Guild {
|
|||
return List.from(Modules.EmojiUtils.getGuildEmoji(this.id), e => new Emoji(e, this.id));
|
||||
}
|
||||
|
||||
/**
|
||||
* The current user's permissions on this guild.
|
||||
*/
|
||||
get permissions() {
|
||||
return Modules.GuildPermissions.getGuildPermissions(this.id);
|
||||
}
|
||||
|
@ -213,6 +219,13 @@ export class Guild {
|
|||
Modules.GuildActions.selectGuild(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this channel is currently selected.
|
||||
*/
|
||||
get selected() {
|
||||
return DiscordApi.currentGuild === this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens this guild's settings window.
|
||||
* @param {String} section The section to open (see DiscordConstants.GuildSettingsSections)
|
||||
|
|
|
@ -217,10 +217,10 @@ export class DefaultMessage extends Message {
|
|||
/**
|
||||
* Start the edit mode of the UI.
|
||||
*/
|
||||
startEdit() {
|
||||
startEdit(content) {
|
||||
if (this.author !== DiscordApi.currentUser)
|
||||
throw new Error('Cannot edit messages sent by other users.');
|
||||
Modules.MessageActions.startEditMessage(this.channel_id, this.id, this.content);
|
||||
Modules.MessageActions.startEditMessage(this.channel_id, this.id, content || this.content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,7 +74,7 @@ export class User {
|
|||
}
|
||||
|
||||
async ensurePrivateChannel() {
|
||||
if (DiscordApi.currentUser.id === this.id)
|
||||
if (DiscordApi.currentUser === this)
|
||||
throw new Error('Cannot create a direct message channel to the current user.');
|
||||
return Channel.from(await Modules.PrivateChannelActions.ensurePrivateChannel(DiscordApi.currentUser.id, this.id));
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ export class GuildMember {
|
|||
* Opens the modal to change this user's nickname.
|
||||
*/
|
||||
openChangeNicknameModal() {
|
||||
if (DiscordApi.currentUser.id !== this.id) this.assertPermissions('MANAGE_NICKNAMES', Modules.DiscordPermissions.MANAGE_NICKNAMES);
|
||||
if (DiscordApi.currentUser !== this) this.assertPermissions('MANAGE_NICKNAMES', Modules.DiscordPermissions.MANAGE_NICKNAMES);
|
||||
Modules.ChangeNicknameModal.open(this.guild_id, this.id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue