python - 如何在 discord.py 中使命令不区分大小写

标签 python python-3.x discord discord.py

如果不为不同大小写添加许多别名,如何使命令不区分大小写,如下所示:

@bot.command(pass_context = True, name = 'test', aliases=['Test', 'tEst', 'teSt', 'tesT', 'TEst', 'TeSt', 'TesT', 'tESt', 'tEsT'])
async def test(self, ctx):
    #do stuff      

最佳答案

在重写分支上,commands.Bot 接受 case_insensitive参数

bot = commands.Bot(command_prefix='!', case_insensitive=True)

请注意,使用此功能会降低性能。

关于python - 如何在 discord.py 中使命令不区分大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48120312/

相关文章:

python - 1048, "Column ' user_id' 不能为空

python - Django 中是否有任何函数可以测试模型的字段实例是否为主键?

python - 无法从每次单击时激活的类似容器的盒子中解析信息

discord - 如何获得在线成员(member)数量?

python - 在 pandas.DataFrame 中更改年份

Python。定义 "attribute initial method"

python-3.x - python Pandas 中的条件日期连接

python 3.6 协程从未被期待

java - 如何使用基于 JDA 的 Discord 机器人遍历公会的所有成员并更改他们的昵称

javascript - Discord.js - 让用户上次事件?