mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
feat(GuildChannel): allow to set all options when cloning (#2937)
This commit is contained in:
@@ -447,35 +447,37 @@ class GuildChannel extends Channel {
|
|||||||
return invites;
|
return invites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable max-len */
|
||||||
/**
|
/**
|
||||||
* Clones this channel.
|
* Clones this channel.
|
||||||
* @param {Object} [options] The options
|
* @param {Object} [options] The options
|
||||||
* @param {string} [options.name=this.name] Optional name for the new channel, otherwise it has the name
|
* @param {string} [options.name=this.name] Name of the new channel
|
||||||
* of this channel
|
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [options.permissionOverwrites=this.permissionOverwrites]
|
||||||
* @param {boolean} [options.withPermissions=true] Whether to clone the channel with this channel's
|
* Permission overwrites of the new channel
|
||||||
* permission overwrites
|
* @param {string} [options.type=this.type] Type of the new channel
|
||||||
* @param {boolean} [options.withTopic=true] Whether to clone the channel with this channel's topic
|
* @param {string} [options.topic=this.topic] Topic of the new channel (only text)
|
||||||
* @param {boolean} [options.nsfw=this.nsfw] Whether the new channel is nsfw (only text)
|
* @param {boolean} [options.nsfw=this.nsfw] Whether the new channel is nsfw (only text)
|
||||||
* @param {number} [options.bitrate=this.bitrate] Bitrate of the new channel in bits (only voice)
|
* @param {number} [options.bitrate=this.bitrate] Bitrate of the new channel in bits (only voice)
|
||||||
* @param {number} [options.userLimit=this.userLimit] Maximum amount of users allowed in the new channel (only voice)
|
* @param {number} [options.userLimit=this.userLimit] Maximum amount of users allowed in the new channel (only voice)
|
||||||
* @param {ChannelResolvable} [options.parent=this.parent] The parent of the new channel
|
* @param {number} [options.rateLimitPerUser=ThisType.rateLimitPerUser] Ratelimit per user for the new channel (only text)
|
||||||
|
* @param {ChannelResolvable} [options.parent=this.parent] Parent of the new channel
|
||||||
* @param {string} [options.reason] Reason for cloning this channel
|
* @param {string} [options.reason] Reason for cloning this channel
|
||||||
* @returns {Promise<GuildChannel>}
|
* @returns {Promise<GuildChannel>}
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable max-len */
|
||||||
clone(options = {}) {
|
clone(options = {}) {
|
||||||
if (typeof options.withPermissions === 'undefined') options.withPermissions = true;
|
|
||||||
if (typeof options.withTopic === 'undefined') options.withTopic = true;
|
|
||||||
Util.mergeDefault({
|
Util.mergeDefault({
|
||||||
name: this.name,
|
name: this.name,
|
||||||
permissionOverwrites: options.withPermissions ? this.permissionOverwrites : [],
|
permissionOverwrites: this.permissionOverwrites,
|
||||||
topic: options.withTopic ? this.topic : undefined,
|
topic: this.topic,
|
||||||
|
type: this.type,
|
||||||
nsfw: this.nsfw,
|
nsfw: this.nsfw,
|
||||||
parent: this.parent,
|
parent: this.parent,
|
||||||
bitrate: this.bitrate,
|
bitrate: this.bitrate,
|
||||||
userLimit: this.userLimit,
|
userLimit: this.userLimit,
|
||||||
|
rateLimitPerUser: this.rateLimitPerUser,
|
||||||
reason: null,
|
reason: null,
|
||||||
}, options);
|
}, options);
|
||||||
options.type = this.type;
|
|
||||||
return this.guild.channels.create(options.name, options);
|
return this.guild.channels.create(options.name, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
typings/index.d.ts
vendored
13
typings/index.d.ts
vendored
@@ -523,7 +523,7 @@ declare module 'discord.js' {
|
|||||||
public readonly permissionsLocked: boolean;
|
public readonly permissionsLocked: boolean;
|
||||||
public readonly position: number;
|
public readonly position: number;
|
||||||
public rawPosition: number;
|
public rawPosition: number;
|
||||||
public clone(options?: GuildChannelCloneOptions): Promise<GuildChannel>;
|
public clone(options?: GuildCreateChannelOptions): Promise<GuildChannel>;
|
||||||
public createInvite(options?: InviteOptions): Promise<Invite>;
|
public createInvite(options?: InviteOptions): Promise<Invite>;
|
||||||
public createOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<GuildChannel>;
|
public createOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<GuildChannel>;
|
||||||
public edit(data: ChannelData, reason?: string): Promise<GuildChannel>;
|
public edit(data: ChannelData, reason?: string): Promise<GuildChannel>;
|
||||||
@@ -1772,17 +1772,6 @@ declare module 'discord.js' {
|
|||||||
MESSAGE?: string;
|
MESSAGE?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type GuildChannelCloneOptions = {
|
|
||||||
bitrate?: number;
|
|
||||||
name?: string;
|
|
||||||
nsfw?: boolean;
|
|
||||||
parent?: ChannelResolvable;
|
|
||||||
reason?: string;
|
|
||||||
userLimit?: number;
|
|
||||||
withPermissions?: boolean;
|
|
||||||
withTopic?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type GuildChannelResolvable = Snowflake | GuildChannel;
|
type GuildChannelResolvable = Snowflake | GuildChannel;
|
||||||
|
|
||||||
type GuildCreateChannelOptions = {
|
type GuildCreateChannelOptions = {
|
||||||
|
|||||||
Reference in New Issue
Block a user