【问题标题】:Responding to prefix (discord.py)响应前缀 (discord.py)
【发布时间】:2020-01-10 04:12:42
【问题描述】:

我正在尝试让我的机器人响应前缀。我只是无法让它这样做。我已经尝试了所有我(目前)知道的。 我的代码:

@client.event
async def on_ready(ctx):
client.when_mentioned(ctx.send='My prefix is `ja`')

【问题讨论】:

  • 请向我们展示更多您尝试过的方法以及您获得的相应输出。还请包括输入和预期输出。

标签: python python-3.x discord.py


【解决方案1】:

您可以编写一个on_message 事件来检查机器人用户是否在消息的提及中

@bot.event
async def on_message(message):
    if message.author.bot:
        return
    if bot.user in message.mentions: 
        await message.channel.send("My prefix is `ja`")
    await bot.process_commands(message)

【讨论】:

    猜你喜欢
    • 2021-03-31
    • 2021-07-07
    • 2021-02-07
    • 2021-04-08
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多