[英]How to make a discord bot accept multiple prefixes
I am making a bot with multiple commands and for the sake of relevancy I want one command to be used with a +
prefix and another one to be used with a !
我正在制作一个带有多个命令的机器人,为了相关性,我希望一个命令与+
前缀一起使用,另一个与!
prefix.字首。
I have a config file with a dictionary that I imported so I could use those to define my prefix.我有一个配置文件,其中包含我导入的字典,因此我可以使用它们来定义我的前缀。
Here is what my prefix bot thing is:这是我的前缀机器人:
bot = commands.Bot(command_prefix=BOT['DEFAULT_PREFIX'])
I tried making another prefix in the config file so it has two of them:我尝试在配置文件中添加另一个前缀,所以它有两个:
'DEFAULT_PREFIX': '+',
'SPECIAL_PREFIX': '!',
I could add a second variable such as client = command.Bot... but I already tried that and the default prefix ( +
) worked fine being used in my cogs.py but the special prefix ( !
) didn't work with my report
command.我可以添加第二个变量,例如 client = command.Bot... 但我已经尝试过了,默认前缀 ( +
) 在我的 cogs.py 中使用得很好,但特殊前缀 ( !
) 不适用于我的report
命令。
Is it possible to somehow have two available prefixes for commands to use?是否有可能以某种方式有两个可用的前缀供命令使用? Or even better , to assign a custom prefix to one decorator?或者更好的是,为一个装饰器分配一个自定义前缀? (I have tried doing bot.command(command_prefix='!')
but had no luck). (我试过做bot.command(command_prefix='!')
但没有运气)。
Thanks!谢谢!
bot = commands.Bot(command_prefix=['first prefix','second prefix'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.