Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 让机器人在我提到它时用前缀响应_Python_Python 3.x_Discord_Discord.py - Fatal编程技术网

Python 让机器人在我提到它时用前缀响应

Python 让机器人在我提到它时用前缀响应,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我希望能够键入“@Cool Boi prefix”,bot将响应当前前缀,由于某些原因,它不工作,并且它也不会显示错误消息,我当前的代码是: @bot.event async def on_message(message): if message.content.startswith('@Cool Boi prefix') await bot.say(' The current prefix isThe actual text of the mention is slig

我希望能够键入“@Cool Boi prefix”,bot将响应当前前缀,由于某些原因,它不工作,并且它也不会显示错误消息,我当前的代码是:

@bot.event
async def on_message(message):
    if message.content.startswith('@Cool Boi prefix')
        await bot.say(' The current prefix isThe actual text of the mention is slightly different from what Discord displays. One way to check if you've been mentioned is to use 
bot.user.mentioned_in

@bot.event
async def on_message(message):
    if bot.user.mentioned_in(message) and 'prefix' in message.content:
        await bot.send_message(message.channel, f'My Prefix is {bot.command_prefix}')
@bot.event
异步def on_消息(消息):
如果message.content.startswith(“@Cool Boi prefix”)

wait bot.say('当前前缀为提及的实际文本与Discord显示的文本略有不同。检查您是否被提及的一种方法是使用
bot.user.noteded_in

@bot.event
async def on_message(message):
    if message.content.startswith(f'{bot.user.mention} prefix'):
        await bot.send_message(message.channel, f'My Prefix is {bot.command_prefix}')
或者您可以使用
bot.user.antify构建字符串