Some comments and fix updateSystemChannel

This commit is contained in:
Samuel Elliott 2018-04-30 21:12:50 +01:00
parent 3aedcfdd06
commit 640ec66abc
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 49 additions and 3 deletions

View File

@ -245,19 +245,39 @@ export class GuildChannel extends Channel {
Modules.ChannelSettingsWindow.open(this.id); Modules.ChannelSettingsWindow.open(this.id);
} }
/**
* Updates this channel's name.
* @param {String} name The channel's new name
* @return {Promise}
*/
updateName(name) { updateName(name) {
return this.updateChannel({ name }); return this.updateChannel({ name });
} }
/**
* Changes the channel's position.
* @param {Number} position The channel's new position
* @return {Promise}
*/
changeSortLocation(position = 0) { changeSortLocation(position = 0) {
if (position instanceof GuildChannel) position = position.position; if (position instanceof GuildChannel) position = position.position;
return this.updateChannel({ position }); return this.updateChannel({ position });
} }
/**
* Updates this channel's permission overwrites.
* @param {Array} permissionOverwrites An array of permission overwrites
* @return {Promise}
*/
updatePermissionOverwrites(permission_overwrites) { updatePermissionOverwrites(permission_overwrites) {
return this.updateChannel({ permission_overwrites }); return this.updateChannel({ permission_overwrites });
} }
/**
* Updates this channel's category.
* @param {ChannelCategory} category The new channel category
* @return {Promise}
*/
updateCategory(category) { updateCategory(category) {
return this.updateChannel({ parent_id: category.id || category }); return this.updateChannel({ parent_id: category.id || category });
} }
@ -269,10 +289,20 @@ export class GuildTextChannel extends GuildChannel {
get topic() { return this.discordObject.topic } get topic() { return this.discordObject.topic }
get nsfw() { return this.discordObject.nsfw } get nsfw() { return this.discordObject.nsfw }
/**
* Updates this channel's topic.
* @param {String} topc The new channel topic
* @return {Promise}
*/
updateTopic(topic) { updateTopic(topic) {
return this.updateChannel({ topic }); return this.updateChannel({ topic });
} }
/**
* Updates this channel's NSFW flag.
* @param {Boolean} nsfw Whether the channel should be marked as NSFW
* @return {Promise}
*/
setNswf(nsfw = true) { setNswf(nsfw = true) {
return this.updateChannel({ nsfw }); return this.updateChannel({ nsfw });
} }
@ -289,16 +319,26 @@ export class GuildVoiceChannel extends GuildChannel {
get bitrate() { return this.discordObject.bitrate } get bitrate() { return this.discordObject.bitrate }
sendMessage() { throw new Error('Cannot send messages in a voice channel.'); } sendMessage() { throw new Error('Cannot send messages in a voice channel.'); }
get messages() { return []; } get messages() { return new List(); }
jumpToPresent() { throw new Error('Cannot select a voice channel.'); } jumpToPresent() { throw new Error('Cannot select a voice channel.'); }
get hasMoreAfter() { return false; } get hasMoreAfter() { return false; }
sendInvite() { throw new Error('Cannot invite someone to a voice channel.'); } sendInvite() { throw new Error('Cannot invite someone to a voice channel.'); }
select() { throw new Error('Cannot select a voice channel.'); } select() { throw new Error('Cannot select a voice channel.'); }
/**
* Updates this channel's bitrate.
* @param {Number} bitrate The new bitrate
* @return {Promise}
*/
updateBitrate(bitrate) { updateBitrate(bitrate) {
return this.updateChannel({ bitrate }); return this.updateChannel({ bitrate });
} }
/**
* Updates this channel's user limit.
* @param {Number} userLimit The new user limit
* @return {Promise}
*/
updateUserLimit(user_limit) { updateUserLimit(user_limit) {
return this.updateChannel({ user_limit }); return this.updateChannel({ user_limit });
} }
@ -311,11 +351,12 @@ export class ChannelCategory extends GuildChannel {
get category() { return undefined } get category() { return undefined }
sendMessage() { throw new Error('Cannot send messages in a channel category.'); } sendMessage() { throw new Error('Cannot send messages in a channel category.'); }
get messages() { return []; } get messages() { return new List(); }
jumpToPresent() { throw new Error('Cannot select a channel category.'); } jumpToPresent() { throw new Error('Cannot select a channel category.'); }
get hasMoreAfter() { return false; } get hasMoreAfter() { return false; }
sendInvite() { throw new Error('Cannot invite someone to a channel category.'); } sendInvite() { throw new Error('Cannot invite someone to a channel category.'); }
select() { throw new Error('Cannot select a channel category.'); } select() { throw new Error('Cannot select a channel category.'); }
updateCategory() { throw new Error('Cannot set a channel category on another channel category.'); }
/** /**
* A list of channels in this category. * A list of channels in this category.
@ -384,6 +425,11 @@ export class GroupChannel extends PrivateChannel {
return User.fromId(this.ownerId); return User.fromId(this.ownerId);
} }
/**
* Updates this channel's name.
* @param {String} name The channel's new name
* @return {Promise}
*/
updateName(name) { updateName(name) {
return this.updateChannel({ name }); return this.updateChannel({ name });
} }

View File

@ -466,7 +466,7 @@ export class Guild {
* @param {GuildTextChannel} systemChannel The new system channel * @param {GuildTextChannel} systemChannel The new system channel
* @return {Promise} * @return {Promise}
*/ */
updateAfkChannel(system_channel) { updateSystemChannel(system_channel) {
return this.updateGuild({ system_channel_id: system_channel.id || system_channel }); return this.updateGuild({ system_channel_id: system_channel.id || system_channel });
} }