2020年12月20日星期日

discord.py commands.when_mentioned not working with custom prefix

What I'm trying to do: If someone doesn't know the prefix, they can mention the bot and use the mention instead. After some research, I had found How to send commands to a bot by name? This made me want to try using the commands.when_mentioned or commands.when_mentioned_or functions alongside my custom prefix.

My problem: The bot either only responds to the mention (while throwing errors at me), or does not respond at all.

Here is the custom prefix code I am using: How to get a customizable prefix discord.py

Here is the client definition with the command_prefix:

intents = discord.Intents.all()  client = commands.Bot(      command_prefix= (get_prefix),      description='A bot who wants your toes',      owner_id=(394506589350002688),      case_insensitive=True,      intents=intents      )  

Below I have listed what I have tried. I am not sure what to try next, so I will be grateful for any help provided.

Trial 1:

command_prefix= commands.when_mentioned_or((get_prefix))  

Result:

TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not function  

Trial 2:

command_prefix= commands.when_mentioned or (get_prefix)  

Result: No error, but bot no longer responds to custom prefix as seen below.

Bot does not respond to bl!

Trial 3:

command_prefix= commands.when_mentioned and (get_prefix)  

Result: No error, but bot no longer responds to mention as seen below.

Bot no longer responds to mention

https://stackoverflow.com/questions/65386984/discord-py-commands-when-mentioned-not-working-with-custom-prefix December 21, 2020 at 10:49AM

没有评论:

发表评论