【发布时间】:2021-03-30 21:00:26
【问题描述】:
我正在尝试做的事情:如果有人不知道前缀,他们可以提及机器人并改用提及。经过一番研究,我发现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
)
下面我列出了我尝试过的内容。我不确定接下来要尝试什么,因此我将不胜感激提供的任何帮助。
试验一:
command_prefix= commands.when_mentioned_or((get_prefix))
结果:
TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not function
试炼二:
command_prefix= commands.when_mentioned or (get_prefix)
结果:没有错误,但机器人不再响应自定义前缀,如下所示。
试验 3:
command_prefix= commands.when_mentioned and (get_prefix)
结果:没有错误,但机器人不再响应提及,如下所示。
【问题讨论】:
标签: python discord.py discord.py-rewrite