mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +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.
|
* Replaces the permission overwrites in this channel.
|
||||||
* @param {Object} [options] Options
|
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} overwrites
|
||||||
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [options.permissionOverwrites]
|
|
||||||
* Permission overwrites the channel gets updated with
|
* 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>}
|
* @returns {Promise<GuildChannel>}
|
||||||
* @example
|
* @example
|
||||||
* channel.overwritePermissions({
|
* channel.overwritePermissions([
|
||||||
* permissionOverwrites: [
|
|
||||||
* {
|
* {
|
||||||
* id: message.author.id,
|
* id: message.author.id,
|
||||||
* deny: ['VIEW_CHANNEL'],
|
* deny: ['VIEW_CHANNEL'],
|
||||||
* },
|
* },
|
||||||
* ],
|
* ], 'Needed to change permissions');
|
||||||
* reason: 'Needed to change permissions'
|
|
||||||
* });
|
|
||||||
*/
|
*/
|
||||||
overwritePermissions(options = {}) {
|
overwritePermissions(overwrites, reason) {
|
||||||
return this.edit(options).then(() => this);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -787,7 +787,7 @@ declare module 'discord.js' {
|
|||||||
public equals(channel: GuildChannel): boolean;
|
public equals(channel: GuildChannel): boolean;
|
||||||
public fetchInvites(): Promise<Collection<string, Invite>>;
|
public fetchInvites(): Promise<Collection<string, Invite>>;
|
||||||
public lockPermissions(): Promise<this>;
|
public lockPermissions(): Promise<this>;
|
||||||
public overwritePermissions(options?: { permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>, reason?: string; }): Promise<this>;
|
public overwritePermissions(overwrites: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>, reason?: string): Promise<this>;
|
||||||
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
|
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
|
||||||
public setName(name: string, reason?: string): Promise<this>;
|
public setName(name: string, reason?: string): Promise<this>;
|
||||||
public setParent(channel: GuildChannel | Snowflake, options?: { lockPermissions?: boolean; reason?: string; }): Promise<this>;
|
public setParent(channel: GuildChannel | Snowflake, options?: { lockPermissions?: boolean; reason?: string; }): Promise<this>;
|
||||||
|
|||||||
Reference in New Issue
Block a user