Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Guild/XChannel.clone() #2093

Closed
NCPlayz opened this issue Apr 17, 2019 · 4 comments

Comments

@NCPlayz
Copy link
Contributor

commented Apr 17, 2019

The Problem

In the Discord Client, there is a clone channel option on guild text and voice channels. It would be useful if you could replicate this in discord.py, since it could be used for backing up channels or just "wiping" messages from a channel (delete and create), which seems to be asked for sometimes in discord.py help channels.

The Ideal Solution

>>> await (TextChannel or VoiceChannel).clone() # be able to clone in the same guild
>>> await guild.clone(TextChannel or VoiceChannel)  # ^+ be able to clone in another guild?

# both return:

<TextChannel with the same name, topic, overwrites, nsfw, category, slowmode_delay>
# OR
<VoiceChannel with the same name, overwrites, category, bitrate, user_limit>

The Current Solution

>>> await guild.create_text_channel(channel.name, topic=channel.topic, 
... overwrites=channel.overwrites, nsfw=channel.nsfw, 
... category=channel.category, slowmode_delay=channel.slowmode_delay)

<TextChannel with the same name, topic, overwrites, nsfw, category, slowmode_delay>

# OR

>>> await guild.create_voice_channel(c.name, overwrites=c.overwrites,
... category=c.category, bitrate=c.bitrate, user_limit=c.user_limit)

<VoiceChannel with the same name, overwrites, category, bitrate, user_limit>

Summary

Replicate clone channel for text and voice channels.

I don't have any code to PR this instantly so feel free to do it if the idea is accepted :)

@BluePhoenixGame

This comment has been minimized.

Copy link
Contributor

commented Apr 18, 2019

Instead of guild.clone() can't we add a kwarg to guild.create_text_channel() where you can pass in a channel object? The same for all other create functions, like roles, categories etc.

@makusu2

This comment has been minimized.

Copy link
Contributor

commented Apr 18, 2019

@BluePhoenixGame clone works for voice channels too. Having it be generic (clone instead of create_text_channel and create_voice_channel) would make it a lot easier for the programmer, since they could check the channel type if it matters but they don't have to if it's irrelevant, like with a simple command that just clones a given channel by ID
❤️

@Rapptz

This comment has been minimized.

Copy link
Owner

commented Apr 18, 2019

abc.GuildChannel.clone seems like a valid feature request and one I actually have in my stash from 2017 :>

However, Guild.clone is incredibly outside the scope of the library and is a niche use case. It requires a mapping internally and it requires that mapping to be relatively consistent -- making it hard to implement in the library with a lot of room for failure with no good way to signal it.

@Rapptz Rapptz added this to the v1.1 milestone Apr 18, 2019

@NCPlayz

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

I agree with the Guild.clone part, it was just an afterthought, since it would've sort of been useful for me, but then again niche.

Since I wasn't planning to make a PR anyway, you know the best for discord.py's design, so you can add it :)

@Rapptz Rapptz self-assigned this Apr 19, 2019

@Rapptz Rapptz closed this in f5c38c3 Apr 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.