Skip to content

插件加载抛出异常 Function importClass must be called with a class #10

@Taifendesune

Description

@Taifendesune

环境:

  • mirai-console: 2.8.0-M1
  • mirai-console-terminal: 2.8.0-M1
  • mirai-core-all: 2.8.0-M1
  • mirai-js: 2.0-RC-dev1

代码为示例代码:

importClass(net.mamoe.mirai.event.GlobalEventChannel);
importClass(net.mamoe.mirai.event.events.BotOnlineEvent);
importPackage(net.mamoe.mirai)

let bot = null;
let listener = GlobalEventChannel.INSTANCE.subscribeAlways(BotOnlineEvent, (event) => {
    logger.info("Bot " + event.getBot() + " is now online!");
    bot = event.getBot();
});

异常信息:
image

2021-10-17 01:50:59 E/org.itxtech.miraijs.MiraiJs: Error while loading studychat.zip: org.mozilla.javascript.EvaluatorException: Function importClass must be called with a class; had "[JavaPackage com.stardust.autojs.core.http.MutableOkHttp]" instead. (importOkHttpLib#12)

代码改为以下内容报同样错误:

// importClass(net.mamoe.mirai.event.GlobalEventChannel);
// importClass(net.mamoe.mirai.event.events.BotOnlineEvent);
// importPackage(net.mamoe.mirai)

let bot = null;
let listener = net.mamoe.mirai.event.GlobalEventChannel.INSTANCE.subscribeAlways(
  mirai.event.events.BotOnlineEvent,
  (event) => {
    logger.info("Bot " + event.getBot() + " is now online!");
    bot = event.getBot();
  }
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions