LuaMiraiForAndroid icon indicating copy to clipboard operation
LuaMiraiForAndroid copied to clipboard

某些方法无法调用

Open HelloMitsuha opened this issue 3 years ago • 4 comments

Describe the bug 以下均为java.lang.reflect.InvocationTargetException异常 执行已存在的方法出错

event.group:setName("测试")--修改群名称?

在执行下面的代码时出现异常

local mb=event.group:get(tonumber(任意在群里的QQ号))--转换成Member以执行
event.group:sendMessage("尝试执行中...")
local time=60*60*60*24*29--简易计算

mb:mute(time)--禁言(异常处)

To Reproduce Steps to reproduce the behavior: 对任意Member调用方法mute即可,而且不局限于禁言,部分方法都会出现此异常(比如代码中出现但未在文档中出现的Group:setName(String)也无法调用)

Expected behavior 出现java.lang.reflect.InvocationTargetException错误,无法执行

Screenshots image image image image image

Desktop (please complete the following information):

  • OS: null
  • Browser null
  • Version null

Smartphone (please complete the following information):

  • Device: Android
  • OS: Android 9
  • Browser via
  • Version 1.0-alpha5

Additional context 为什么存在的方法也无法调用啊? image image

HelloMitsuha avatar Jun 26 '22 11:06 HelloMitsuha

目前找到一个解决方法,就是把setter/getter简写

event.group:get(mybot.id).nameCard="三葉"
--上面是简写,下面是普通写法(setter)
event.group:get(mybot.id).setNameCard("三葉")

HelloMitsuha avatar Jun 26 '22 12:06 HelloMitsuha

不知道为什么getter/setter总是不能用,只能用简写

HelloMitsuha avatar Jun 26 '22 12:06 HelloMitsuha

不知道为什么getter/setter总是不能用,只能用简写

HelloMitsuha avatar Jun 26 '22 12:06 HelloMitsuha

getter和setter方法的简写调用是feature哦。虽然编译后能看到getName、setName等方法,但在kotlin语言层面中这些方法会有相应的简写语法糖,luakt为此也对lua做了语法糖映射。

only52607 avatar Jun 26 '22 13:06 only52607