mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user