MiraiForum

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

    sendMessage无法使用?

    开发交流
    7
    8
    186
    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.
    • J
      Jackwu945 last edited by

      如下图,我写了一个定时发送信息测试插件,但是ide似乎告诉我我不能这样用sendMessage,在这种情况下应该怎么样才能用sendMessage?
      cdc27dab-3d9f-48e7-b94d-5eed3b874fd9-image.png

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

        1. 搜索kotlin协程
        2. 别在 onEnable 写死循环
        1 Reply Last reply Reply Quote 0
        • Nambers
          Nambers 摸鱼 last edited by

          runBlocking{}

          1 Reply Last reply Reply Quote 0
          • M
            Michael1015198808 last edited by

            建议多了解一点Kotlin,然后阅读一下插件模板,新手可以在模板的基础上删删改改来实现自己的插件,追求从0开始的话很多地方容易踩坑

            J 1 Reply Last reply Reply Quote 0
            • J
              Jackwu945 @Michael1015198808 last edited by

              @michael1015198808 刚开始我是按照示例来的,但是示例模板没有主动发送消息的.

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

                快进到要求mirai框架每分钟广播一个ClockEvent

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

                  onEnable 需要快速完成,不允许进行发送消息这种高消耗(通常200ms)的操作。可以 lauch 一个协程,在协程里进行你想要的事情。

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

                    sendMessage 是一个 suspend 函数,关于 suspend 函数的详细解释和用法去看 kotlin 协程的相关内容

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