@nonebot.on_command('hello', aliases=('hi', 'hey')) async def hello(session: CommandSession): await session.send('Hello there!')
@nonebot.on_command('roll', aliases=('r',)) async def roll(session: CommandSession): arg = session.current_arg_text.strip().lower() if arg == 'd6': roll_result = random.randint(1, 6) await session.send(f'You rolled a {roll_result}!') elif arg == 'd20': roll_result = random.randint(1, 20) await session.send(f'You rolled a {roll_result}!') else: await session.send('Invalid argument. Usage: roll {d6 or d20}')This example shows a more complex command that takes an argument (either "d6" or "d20") and responds with the result of a random roll of the specified number of dice. In both examples, the session parameter is used to access the user's command message and to send a response back to the user. The package library used in these examples is nonebot.