【问题标题】:resorting channels when deleting and cloning [duplicate]删除和克隆时使用频道[重复]
【发布时间】:2020-12-14 19:52:41
【问题描述】:
@client.command()
@commands.has_permissions(manage_messages=True)
async def nuke(ctx):
await ctx.channel.delete()
newchannel = await ctx.channel.clone(reason="Channel has been nuked")
await newchannel.send("Nuked this channel ???? https://imgur.com/LIyGeCR")
我编写了这个 nuke 命令,但是当它执行时,频道会转到类别的底部。如何让它留在同一个地方,但仍然是核武器。
【问题讨论】:
标签:
python
discord
discord.py
【解决方案1】:
默认情况下应该在同一个位置创建,如果不是你可以简单地 .edit 与旧频道位置的position kwarg
@client.command()
@commands.has_permissions(manage_messages=True)
async def nuke(ctx):
await ctx.channel.delete()
newchannel = await ctx.channel.clone(reason="Channel has been nuked")
# Editing the position here
await newchannel.edit(position=ctx.channel.position)
await newchannel.send("Nuked this channel ? https://imgur.com/LIyGeCR")