【问题标题】:Discord Bot Python Delete User Message After ExecutedDiscord Bot Python在执行后删除用户消息
【发布时间】:2020-10-27 11:34:06
【问题描述】:

有人可以帮我解决这个问题,我只是想删除作者发送的执行命令的消息

@bot.command(description="Displays the test on_member_join message", aliases=['tw'], pass_context=True)
@commands.has_permissions(administrator=True)
async def test_welcome(ctx):
    user = ctx.author
    if user.bot:
        pass
    else:
        now = datetime.now()
        dt_string = now.strftime("on %d/%m/%Y at %H:%M")
        embed = discord.Embed(description=f"{user.display_name} **Joined The Server**", colour=0x73D673)
        embed.set_author(name=user.display_name, icon_url=user.avatar_url)
        embed.set_thumbnail(url=thumbnail)
        embed.add_field(name="User ID:", value=user.id)
        embed.set_footer(text=dt_string)
        #how to make it delete the message the user sent to excute this command
        await ctx.send(embed=embed, delete_after=1)

【问题讨论】:

  • 欢迎,错误是什么,你想要的输出是什么

标签: python discord.py discord.py-rewrite


【解决方案1】:

如果要删除命令执行消息,如prefix test_welcome,可以使用await ctx.message.delete()

【讨论】:

    【解决方案2】:

    您可以使用await ctx.message.delete,无论哪种方式,我建议您阅读documentation

    【讨论】:

      猜你喜欢
      • 2020-08-25
      • 2020-12-03
      • 2021-10-18
      • 2021-01-28
      • 2018-11-07
      • 2017-10-25
      • 2018-07-24
      • 2018-09-07
      • 1970-01-01
      相关资源
      最近更新 更多