如果消息有关键字,则发送消息。不和谐派

时间:2021-06-08 12:34:51

标签: python discord discord.py

所以我希望机器人在每次有人在句子中提到它的名字时都回复“你好”。 我写了这个,但它不起作用,有人可以帮忙:)

@client.event
async def on_message(msg, ctx):
    if 'astro' in msg.content:
        await ctx.send('hi')here

error

1 个答案:

答案 0 :(得分:2)

on_message 不接受 ctx 参数:

@client.event
async def on_message(msg):
    if 'astro' in msg.content:
        channel = msg.channel
        await channel.send('Hi there!')