Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
itzdrli opened this issue Apr 3, 2024 · 3 comments

Comments

@itzdrli
Copy link

itzdrli commented Apr 3, 2024

示例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
Copy link
Contributor

shigma commented Apr 3, 2024

image

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

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

@itzdrli
Copy link
Author

itzdrli commented Apr 3, 2024

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

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

@shigma
Copy link
Contributor

shigma commented Apr 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants