Discord Python 重写 - 移动频道
Discord Python Rewrite - Move channel
是否可以在 discord.py 上移动频道?我正在制作一个克隆和删除频道的 nuke 命令,并且它有效,但现在我需要找出如何将频道移动到原始位置,如果有代码/文档,请告诉我一个例子。谢谢
编辑:
我得到了一个有效的编辑,但它总是把它拖到上面,我需要它,所以它会在它被破坏之前将频道拖到相同的位置。
我目前拥有的代码
@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
您可以使用await channel.edit(position=0)
改变位置。在这种情况下,由于指定了 0
,因此频道将移至第一个位置。
如果你想把它移动到删除频道的位置,那么你可以检查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
是否可以在 discord.py 上移动频道?我正在制作一个克隆和删除频道的 nuke 命令,并且它有效,但现在我需要找出如何将频道移动到原始位置,如果有代码/文档,请告诉我一个例子。谢谢
编辑: 我得到了一个有效的编辑,但它总是把它拖到上面,我需要它,所以它会在它被破坏之前将频道拖到相同的位置。
我目前拥有的代码
@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
您可以使用await channel.edit(position=0)
改变位置。在这种情况下,由于指定了 0
,因此频道将移至第一个位置。
如果你想把它移动到删除频道的位置,那么你可以检查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