Answer the question
In order to leave comments, you need to log in
Is it possible to make 2 different prefixes?
I want to make it accept 2 prefixes from me, but through different commands, that is:
bot1 = commands.Bot(command_prefix=['.'])
client = commands.Bot(command_prefix=settings['prefix'])
I do this and it just doesn't accept
@bot1.command()
async def ...
Answer the question
In order to leave comments, you need to log in
command_prefix
You can use the function
as an argument value :
Bot.command_prefix
The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.
SPECIAL_PREFIX = "."
def context_prefix(bot, message):
special_command = bot.get_command("choose")
if any(
message.content.startswith(f"{SPECIAL_PREFIX}{command_string}")
for command_string in [special_command.name, *special_command.aliases]
):
return SPECIAL_PREFIX
return "&"
bot = commands.Bot(command_prefix=context_prefix)
choose
will be called with the prefix .
, while the rest with the prefix &
:Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question