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

Feature: 指令参数类型增加非负整数 #1398

Closed
idranme opened this issue May 12, 2024 · 3 comments
Closed

Feature: 指令参数类型增加非负整数 #1398

idranme opened this issue May 12, 2024 · 3 comments
Labels
feature 新特性

Comments

@idranme
Copy link

idranme commented May 12, 2024

Describe the problem related to the feature request

仅允许参数的值为非负整数

Describe the solution you'd like

指令参数类型增加非负整数

Describe alternatives you've considered

No response

Additional context

No response

@idranme idranme added the feature 新特性 label May 12, 2024
@DGCK81LNN
Copy link
Contributor

DGCK81LNN commented Jun 4, 2024

natural

this.domain('natural', (source, session) => {
const value = +source
if (value * 0 === 0 && Math.floor(value) === value && value >= 0) return value
throw new Error('internal.invalid-natural')
}, { numeric: true })

@idranme
Copy link
Author

idranme commented Jun 4, 2024

natural

this.domain('natural', (source, session) => {
const value = +source
if (value * 0 === 0 && Math.floor(value) === value && value >= 0) return value
throw new Error('internal.invalid-natural')
}, { numeric: true })

https://koishi.chat/zh-CN/guide/basic/command.html#argument-type
目前文档未提及

@shigma
Copy link
Member

shigma commented Jun 4, 2024

嗯……也行,我先补一个文档吧

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

No branches or pull requests

3 participants