【问题标题】:How to Make Your bot send animated messages (Like Hack Command of dank memer)如何让你的机器人发送动画消息(如 dank memer 的 Hack 命令)
【发布时间】:2021-09-24 18:08:08
【问题描述】:

大家好。我一直在编写代码,其中机器人通过快速编辑来发送动画消息(如 dank memer 的 hack 命令)。这是代码,但不幸的是它没有响应 并说“无法编辑由其他用户撰写的消息”

这是代码

     async def virus(self, ctx, user: discord.Member = None, *, virus: str = "trojan"):
      user54 = user or ctx.author
      list = (
          f"``[▓▓▓                    ] / {virus}-virus.exe Packing files.``",
          f"``[▓▓▓▓▓▓▓                ] - {virus}-virus.exe Packing files..``",
          f"``[▓▓▓▓▓▓▓▓▓▓▓▓           ] \ {virus}-virus.exe Packing files..``",
          f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓         ] | {virus}-virus.exe Packing files..``",
          f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓      ] / {virus}-virus.exe Packing files..``",
          f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓   ] - {virus}-virus.exe Packing files..``",
          f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ] \ {virus}-virus.exe Packing files..``",
          f"``Successfully downloaded {virus}-virus.exe``",
          "``Injecting virus.   |``",
          "``Injecting virus..  /``",
          "``Injecting virus... -``",
          f"``Successfully Injected {virus}-virus.exe into {user54.name}``",
      )
      for i in list:
          await asyncio.sleep(1.5)
          await ctx.message.edit(content=i)

【问题讨论】:

    标签: animation discord.py


    【解决方案1】:

    正如错误中所说,您无法编辑其他用户消息,ctx.message 指的是调用该命令的消息。您需要先发送一条消息,然后再对其进行编辑。

    这应该可行:

        async def virus(self, ctx, user: discord.Member = None, *, virus: str = "trojan"):
            user54 = user or ctx.author
            initial_message = await ctx.send(f"``[▓                    ] / {virus}-virus.exe Packing files.``")
            list = (
                f"``[▓▓▓                    ] / {virus}-virus.exe Packing files.``",
                f"``[▓▓▓▓▓▓▓                ] - {virus}-virus.exe Packing files..``",
                f"``[▓▓▓▓▓▓▓▓▓▓▓▓           ] \ {virus}-virus.exe Packing files..``",
                f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓         ] | {virus}-virus.exe Packing files..``",
                f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓      ] / {virus}-virus.exe Packing files..``",
                f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓   ] - {virus}-virus.exe Packing files..``",
                f"``[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ] \ {virus}-virus.exe Packing files..``",
                f"``Successfully downloaded {virus}-virus.exe``",
                "``Injecting virus.   |``",
                "``Injecting virus..  /``",
                "``Injecting virus... -``",
                f"``Successfully Injected {virus}-virus.exe into {user54.name}``",
                )
            for i in list:
                await asyncio.sleep(1.5)
                await initial_message.edit(content=i)
    

    【讨论】:

    • tysm 我一直在寻找解决方案很长一段时间
    猜你喜欢
    • 2021-08-17
    • 1970-01-01
    • 2022-01-03
    • 2019-06-29
    • 2020-12-02
    • 2022-01-23
    • 2018-05-26
    • 1970-01-01
    • 2021-04-25
    相关资源
    最近更新 更多