discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.38k stars 3.97k forks source link

channel.clone() Doesn't clone a voice channel with the same parent #3763

Closed JamesButlin closed 4 years ago

JamesButlin commented 4 years ago

Please describe the problem you are having in as much detail as possible: When using channel.clone() , the API call doesn't seem to follow the same process as an admin using right click/clone channel. The newly cloned voice channel is created without a parent, instead of using the same parent channel (category) - as is the case with manual cloning.

Due to this, any users attempting to clone a voice channel dynamically through the API results in the channel appearing at the top, outside of any categories, and then having to manually be moved, resulting in really bad UX due to the new channel flashing above all others before moved. I believe newly cloned voice channels should keep the same parent, (if one exists).

I can see that this has previously been added, then seemingly removed from discord.js, but I couldn't seem to find a reason for the removal.

Include a reproducible code sample here, if possible:

// Clone a VC with a parent and check the parentID once cloned
channelToClone.clone(undefined, false, false, '').then(
    clone => console.log(clone.parentID)).catch(
    error => console.log(error)
    );

Further details:

almostSouji commented 4 years ago

The feature was added to the development branch #master (12.0.0-dev) with 4fb7e64a39b1889191634f5f60fe9e20ad71ebfe fixed in 986e6da196525ddf64d666a71c5dc70a450e6cd1 and expanded with more options with d92ee2ff999954899c891c093f5f107dd686b64f

It is still available on said branch: https://discord.js.org/#/docs/main/master/class/GuildChannel?scrollTo=clone

The reversion you see mentioned (probably in the PR #2259) was in a private fork of discord.js

The feature has not been backported to 11.5-dev as an options override (like Guild#createChannel) or released to the stable release channel yet.

TL;DR: Not a bug, not yet on stable or 11.5-dev, available on master

JamesButlin commented 4 years ago

@almostSouji Excellent, thanks! Sorry I couldn't seem to spot the addition. I'll have to check out the master branch and give it a try.