refactor(GuildChannel): change overwritePermisions to accept an… (#3853)

* refactor(GuildChannel): change overwritePermisions to no longer accept an object

* fix: check for instanceof Collection too
This commit is contained in:
Sugden
2020-02-29 13:19:21 +00:00
committed by GitHub
parent f95df6f7d7
commit e4f567c65e
2 changed files with 15 additions and 11 deletions

View File

@@ -188,24 +188,28 @@ class GuildChannel extends Channel {
/**
* Replaces the permission overwrites in this channel.
* @param {Object} [options] Options
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [options.permissionOverwrites]
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} overwrites
* Permission overwrites the channel gets updated with
* @param {string} [options.reason] Reason for updating the channel overwrites
* @param {string} [reason] Reason for updating the channel overwrites
* @returns {Promise<GuildChannel>}
* @example
* channel.overwritePermissions({
* permissionOverwrites: [
* channel.overwritePermissions([
* {
* id: message.author.id,
* deny: ['VIEW_CHANNEL'],
* },
* ],
* reason: 'Needed to change permissions'
* });
* ], 'Needed to change permissions');
*/
overwritePermissions(options = {}) {
return this.edit(options).then(() => this);
overwritePermissions(overwrites, reason) {
if (!Array.isArray(overwrites) && !(overwrites instanceof Collection)) {
return Promise.reject(new TypeError(
'INVALID_TYPE',
'overwrites',
'Array or Collection of Permission Overwrites',
true,
));
}
return this.edit({ permissionOverwrites: overwrites, reason }).then(() => this);
}
/**