执行roll命令后删除作者消息

时间:2019-05-02 13:23:27

标签: python asynchronous bots discord discord.py

我正在努力删除作者信息,例如滚动并仍然执行我的命令。

(Discord.py异步0.16“我认为”)

@client.command(name = 'roll',
                 description = 'Rolls a 6 sided dice.',
                 brief = 'Rolls a dice!',
                 pass_context = True)
async def dice(context):
    possible_responses = [
        ':game_die: 1',
        ':game_die: 2',
        ':game_die: 3',
        ':game_die: 4',
        ':game_die: 5',
        ':game_die: 6'
    ]
    await client.say(context.message.author.mention + ' , Rolls a ' + random.choice(possible_responses))```

1 个答案:

答案 0 :(得分:0)

添加:await client.delete_message(context.message)

您的代码应如下所示:

@client.command(name = 'roll',
                 description = 'Rolls a 6 sided dice.',
                 brief = 'Rolls a dice!',
                 pass_context = True)
async def dice(context):
    possible_responses = [
        ':game_die: 1',
        ':game_die: 2',
        ':game_die: 3',
        ':game_die: 4',
        ':game_die: 5',
        ':game_die: 6'
    ]
    await client.say(context.message.author.mention + ' , Rolls a ' + random.choice(possible_responses))
    await client.delete_message(context.message)

这将在命令运行后删除消息,请确保漫游器具有删除消息的正确权限。您可以在discord.py 0.16文档中找到更多信息