我正在尝试制作一个不和谐的机器人,但我想知道如何制作它,以便如果用户没有正确调用它而将其留空,它仍然会发送消息。我的意思是,如果有人执行 //changelogs (number),那么如果用户在 (number) 中输入一个数字,机器人就会发送此版本的更改日志。但是,如果用户只是调用 //changelogs,它会显示一条消息,说明用户可以调用哪些版本的变更日志。
答案 0 :(得分:0)
@commands.command()
async def changelogs(ctx: Context, number: int = None):
if number is None:
await ctx.send("a message of what versions of changelogs the user can call")
else:
await ctx.send("the changelogs of this version")
参考资料:
commands.command
: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=commands%20command#discord.ext.commands.command