So I've been trying to make my Discord.py bot have 2 prefixes. For example the first one would be "a!" and the second one would be pinging it, but I can't just figure out how to do it. Here is my code :
bot = commands.Bot(command_prefix=commands.when_mentioned_or('$'))
CodePudding user response:
use the or
operator.
Not sure what you're trying to do, and I don't have much experience with discord.py over discord.js, but I'll grab a snippet from the Discord.py Quickstart page:
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if not message.startswith('a!') or not message.startswith(<bot mention>):
return
...
CodePudding user response:
You can supply a list of prefixes to command_prefix
, if you want it to include mentions you can also do it like this:
bot = commands.Bot(command_prefix=commands.when_mentioned_or(["!a", "$"])
CodePudding user response:
Try this:
bot = commands.Bot(command_prefix=["hi ","Hi "])