Discord.py大写和小写

混沌

我希望命令在字母为大写和小写时起作用,但我不知道该怎么做。请帮我。例如:Ping PINg PiNg

@client.command()
async def ping(ctx):
    await ctx.send(f'Pong! ``{round(client.latency * 1000)}``')
迪格

您可以在实例化漫游器/客户端时指定不区分大小写:

client = commands.Bot(command_prefix="!", case_insensitive=True)

它的默认值为false,但将其设置为True会允许任何大小写的命令组合。

和等效的在以下命令中创建命令时on_message

if message.content.lower().startswith("!ping"):
    # do stuff

参考文献:

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章