我想做的事:如果有人不知道前缀,他们可以提到bot,并使用该前缀。经过一些研究,我发现How to send commands to a bot by name?这让我想尝试在自定义前缀旁边使用commands.when_mentioned
或commands.when_mentioned_or
函数
我的问题:机器人要么只响应提及的内容(向我抛出错误),要么根本不响应
下面是我正在使用的自定义前缀代码:How to get a customizable prefix discord.py
以下是带有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
)
下面我列出了我尝试过的内容。我不确定下一步要尝试什么,因此我将感谢您提供的任何帮助。
试验1:
command_prefix= commands.when_mentioned_or((get_prefix))
结果:
TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not function
试验2:
command_prefix= commands.when_mentioned or (get_prefix)
结果:没有错误,但bot不再响应自定义前缀,如下所示
试验3:
command_prefix= commands.when_mentioned and (get_prefix)
结果:没有错误,但bot不再响应如下所示的提及
when_mentioned_or
应该传递前缀列表,而不是获取该列表的函数。不过,修改非常简单:相关问题 更多 >
编程相关推荐