首页 文章

删除discord.py中的消息Discord bot

提问于
浏览
0

我用Python 3.6 IDLE编写了一个机器人,我想添加一个 purge 命令,但我不知道如何添加它 . 有些人可以帮我提供任何示例或建议我会很高兴谢谢 .

2 回答

  • 0
    @bot.command(pass_context=True)
    async def purge(ctx, amount):
        await bot.purge_from(ctx.message.channel, limit=amount)
    

    相当肯定会有用 .

  • 1
    @client.command(pass_context = True, aliases=['Clear'])
    async def clear(ctx, number):
        mgs = [] #Empty list to put all the messages in the log
        number = int(number) #Converting the amount of messages to delete to an 
        integer
        async for x in client.logs_from(ctx.message.channel, limit = number):
            mgs.append(x)
        await client.delete_messages(mgs)
    

相关问题