MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    如何发送图片呀

    开发交流
    5
    7
    573
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • nikerck
      nikerck last edited by Hoshino Tented

      some_pic.png
      只是想一次性发送图片给群里,但是不管这么弄都是各种报错

      1 Reply Last reply Reply Quote 0
      • Orisland
        Orisland 摸鱼 last edited by

        第一步
        第二步
        第三步

        nikerck 1 Reply Last reply Reply Quote 0
        • nikerck
          nikerck @Orisland last edited by

          20f8d4df-d14b-49ee-ae8a-2256fad351f8-image.png @Orisland
          按照你这样走 还是报错呀
          Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method net.mamoe.mirai.contact.Contact$Companion.uploadImage, parameter <this>

          H 1 Reply Last reply Reply Quote 0
          • LemonNeko2452
            LemonNeko2452 last edited by

            append的是图片的id吧

            1 Reply Last reply Reply Quote 0
            • H
              hundun000 ⭐2021⭐ @nikerck last edited by

              @nikerck

              commandSender.subject可能为null,此时无法uploadImage

              if (commandSender.getSubject() != null) {
                var image = Contact.uploadImage(sender.getSubject(), stream);
                // send
              } else {
                var plainText = new PlainText("已收到指令,但该接收者不支持图片");
                // send
              }
              
              nikerck 1 Reply Last reply Reply Quote 0
              • nikerck
                nikerck @hundun000 last edited by

                @hundun000 是的 命令行命令发现确实为空的 感谢

                1 Reply Last reply Reply Quote 0
                • Fndream
                  Fndream last edited by

                  得到Image(SingleMessage)对象,之后往MessageChain里把这个image append进去就可以了
                  QQ截图20220918113226.png

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact