satorijs / satori

The Universal Messenger Protocol
MIT License
157 stars 46 forks source link

Bug: adapter-discord的slash command中的变量(占位符?) 类型出现问题 #255

Open itzdrli opened 6 months ago

itzdrli commented 6 months ago

示例1: 代码 (koishi):

  ctx.command('getid <profLink:string>', '获取Steam ID', { authority: 0 })
    .action(async ({ session }, profLink) => {
      if (!profLink.startsWith("https://steamcommunity.com/")) {
        return '请输入正确的Steam个人资料链接';
      }

使用非 slash command 执行结果: image 同样的内容使用 slash command 执行结果: image 报错:

2024-04-03 18:03:42 [W] command getid
                        TypeError: Cannot read properties of undefined (reading 'startsWith')
                            at Command.<anonymous> (/home/dev/koishi/external/cs-lookup/src/commands/getid.ts:7:21)
                            at Array.<anonymous> (/home/dev/koishi/node_modules/@koishijs/core/src/command/command.ts:287:27)
                            at Object.argv.next (/home/dev/koishi/node_modules/@koishijs/core/src/command/command.ts:299:27)
                            at Command.execute (/home/dev/koishi/node_modules/@koishijs/core/src/command/command.ts:303:33)
                            at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
                            at <anonymous> (/home/dev/koishi/node_modules/@koishijs/core/src/session.ts:396:22)
                            at Proxy.withScope (/home/dev/koishi/node_modules/@koishijs/core/src/session.ts:293:22)

示例2: 代码:Github 使用非 slash command 执行结果: image 使用 slash command 执行结果: image 无报错

shigma commented 6 months ago

image

因为你没有传这个参数啊……

还是说这个 Bug 指的是它应该返回「缺少参数」?

itzdrli commented 6 months ago

还是说这个 Bug 指的是它应该返回「缺少参数」?

不理解,为什么同样的代码可以在不使用slash command的时候正常执行呢

shigma commented 6 months ago

哦你传了 id。那我或者 LTC 晚点研究一下。