nonebot / adapter-discord

NoneBot2 Discord 适配器 / Discord adapter for nonebot2
20 stars 6 forks source link

`IntergerOption` 无法将输入值转换为 `int` #5

Closed jks15satoshi closed 11 months ago

jks15satoshi commented 11 months ago

示例代码:

matcher = on_slash_command(
    "echo",
    "Send a message",
    options=[
        SubCommandOption(
            name="integer",
            description="Send an integer message",
            options=[
                IntegerOption(
                    name="value", description="The integer value", required=True
                )
            ]
        )
    ]
)

@matcher.handler_sub_command("integer")
async def handler_integer(value: CommandOption[int]) -> None:
    await matcher.finish(f"{value} (type: {type(value)})")

输入:/echo integer 0 期望输出:0 (type: <class 'int'>) 实际输出:0 (type: &lt;class 'str'&gt;) (转义问题见 #4)