问题
Is it possible to move a channel on discord.py? Im making a nuke command that clones and deletes the channel, and it worked, but now i need to find out how to move the channel up to the origonal place, if there's a code / docs, please tell me a example. Thank's
Edit: I Got a working edit but it's always drags it on top, i need it so it will drag the channel to the same position before it got nuked.
My code that i currently have
@client.command()
@commands.has_permissions(manage_channels=True)
async def nuke(ctx):
channel = ctx.channel
await channel.clone()
await channel.delete()
await channel.edit(position=0, sync_permissions=True)
return
回答1:
You can use await channel.edit(position=0) to change the position. In this case, since 0
is specified, the channel will be moved to the first position.
If you want to move it to the deleted channel's position then you can check channel.position.
@client.command()
@commands.has_permissions(manage_channels=True)
async def nuke(ctx):
channel = ctx.channel
channel_position = channel.position
new_channel = await channel.clone()
await channel.delete()
await new_channel.edit(position=channel_position, sync_permissions=True)
return
来源:https://stackoverflow.com/questions/63950798/discord-python-rewrite-move-channel