我希望能够输入“@Cool Boi prefix”,机器人将响应当前的前缀,由于某种原因它不起作用,并且它也没有显示错误消息,我当前的代码是:
@bot.event
async def on_message(message):
if message.content.startswith('@Cool Boi prefix')
await bot.say(' The current prefix is👌')
最佳答案
提及的实际文本与 Discord 显示的内容略有不同。检查您是否被提及的一种方法是使用 bot.user. said_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.user.mention
构建字符串
@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}')
关于python - 当我提到它时,让机器人用前缀进行响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54084366/