Drincann / Mirai-js

运行在 Node.js、浏览器下,基于 mirai-api-http 的 QQ 机器人开发框架。
https://mirai-js-drincann.vercel.app
GNU Affero General Public License v3.0
252 stars 31 forks source link

Error: 指定对象不存在 #234

Closed YuziO2 closed 1 year ago

YuziO2 commented 1 year ago

代码:

const { Bot, Message } = require('mirai-js');

const bot = new Bot();

// 连接到一个 mirai-api-http 服务
async function main() {
  await bot.open({
    baseUrl: 'http://localhost:9292',
    verifyKey: 'xxxxx',
    // 要绑定的 qq,须确保该用户已在 mirai-console 登录
    qq: 1111,
  });

  await bot.sendMessage({
    // 好友 qq 号
    group: '11111',
    // Message 实例,表示一条消息
    message: new Message().addText('hello world!'),
  });

  await bot.close()
}

main()

报错如下:

mirai-js: error core.sendGroupMessage /home/yuzi/Mirai/Mirai-js/node_modules/mirai-js/dist/node/util/errorHandler.js:25 throw new Error([message, miraiMessage, resMessage, response === null || response === void 0 ? void 0 : response.data].filter(msg => typeof msg == 'string').join('\n')); ^

Error: 指定对象不存在 at module.exports (/home/yuzi/Mirai/Mirai-js/node_modules/mirai-js/dist/node/util/errorHandler.js:25:11) at module.exports (/home/yuzi/Mirai/Mirai-js/node_modules/mirai-js/dist/node/core/sendGroupMessage.js:70:5) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Bot.sendMessage (/home/yuzi/Mirai/Mirai-js/node_modules/mirai-js/dist/node/Bot.js:399:16) at async main (/home/yuzi/Mirai/Mirai-js/index.js:15:3)

Node.js v18.13.0

mirai和http-api都是最新的

Drincann commented 1 year ago

group 字段传一个 number 试试。

YuziO2 commented 1 year ago

group 字段传一个 number 试试。

问题依然存在

Drincann commented 1 year ago
YuziO2 commented 1 year ago
  • 确定 group 对应的 qq 群存在,换到其他 qq 群问题仍然存在
  • 换到 friend: 问题仍然存在

确定,都试过了

Drincann commented 1 year ago

我这里无法复现,看看还有没有什么补充信息?

YuziO2 commented 1 year ago

Mirai-Console 2.14.0 mirai-api-http 2.9.1 mirai-js 2.8.11

index.js:

const { Bot, Message } = require('mirai-js');

const bot = new Bot();

async function main() {
  // 连接到一个 mirai-api-http 服务
  await bot.open({
    baseUrl: 'http://127.0.0.1:9292',
    verifyKey: 'kkkk',
    // 要绑定的 qq,须确保该用户已在 mirai-console 登录
    qq: 1111,
  });

  await bot.sendMessage({
    // 好友 qq 号
    group: 101111,
    // Message 实例,表示一条消息
    message: new Message().addText('hello world!')
  });
}

main()

启动命令:node ./index.js

安装方式: npm i mirai-js

报错是在sendMessage那一行发生的

YuziO2 commented 1 year ago

我去,我重启了一下服务器,发现好了,我大意了啊