如何删除discord.py中的用户命令消息?

时间:2021-02-08 10:03:19

标签: python discord discord.py

我有这个命令的代码。如何删除用户命令消息?

@bot.command()
@commands.has_role("Referee")
async def game(ctx, winner, loser, score, MVP):
    teams = winner + " vs " + loser
    embed = discord.Embed(title = "Shell League Game | Season 1 ", color = 0xfca426)
    embed.add_field(name = "Teams", value = teams, inline = False)
    embed.add_field(name = "Score", value = score, inline = False)
    embed.add_field(name = "MVP", value = MVP, inline = False)
    await ctx.send(embed = embed)

1 个答案:

答案 0 :(得分:0)

您必须将 await ctx.message.delete() 放在函数定义的开头。给你:

@bot.command()
@commands.has_role("Referee")
async def game(ctx, winner, loser, score, MVP):
    await ctx.message.delete() # deletes author's command message
    # rest of your command's code