【问题标题】: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")
    

    【讨论】:

    • 如果有帮助,请务必接受答案
    猜你喜欢
    • 2021-01-25
    • 1970-01-01
    • 2015-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-11
    • 2018-03-03
    • 2019-11-17
    相关资源
    最近更新 更多