试图制作一个不和谐的聊天机器人,但它不起作用

时间:2021-06-29 15:46:21

标签: python discord command discord.py bots

我正在用 python (discord.py) 开发一个不和谐的机器人。 我试图为我的机器人发出聊天命令,但它没有回复,也没有错误。 我问了我的朋友,但他也不知道如何制作以及有什么问题。 我的目标是让机器人做出回应,例如,如果我说你好,它会回应你提到的 hello + me。

这是我的代码:

async def chat(ctx):
    await ctx.send("Chat mode ON")
    hi = "hello", "hi", "hallo"
    hgh = "how are you doing", "how are you doing?", "hoe gaat het?","how are you"
    exit = "bye", "exit", "Bye","Exit"
    invite = "invite", "can i get your invite link?"
    
    
    msg = await  bot.wait_for("message" )

    if msg.content == hi:
        await ctx.send("Hello " + ctx.message.author.mention)
    if msg.content == hgh:
        await ctx.send("Im doing as long as my script is running, how are you? " + ctx.message.author.mention)
    if msg.content == exit:
        await ctx.send("Bye, hope to see you again soon " + ctx.message.author.mention)
    if msg.content == invite:
        await ctx.send("This is my invite link: https://discord.com/oauth2/authorize?client_id=858775426490957845&permissions=8&scope=bot " + ctx.message.author.mention)```



If you know what is wrong with it and how to fix it please let me know, it would mean a lot to me.

 

1 个答案:

答案 0 :(得分:0)

如果您想要聊天机器人,请使用 on_message(message),您创建了一个名为“chat”的命令。

<form onSubmit={() => { router.push('/search') }}>
  <input type="text" placeholder="test" />
</form>