简体   繁体   中英

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.

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).

Thanks!

bot = commands.Bot(command_prefix=['first prefix','second prefix'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM