【问题标题】:discord.py - bot not responding even though no error messagesdiscord.py - 即使没有错误消息,机器人也没有响应
【发布时间】:2020-09-10 08:24:48
【问题描述】:

我刚开始学习 discordpy,但我的机器人没有响应,即使我遵循了文档并且没有错误消息,我也被卡住了。机器人在线,但没有回复我的消息。我正在使用 python 3.8

import discord

client = discord.Client()


@client.event
async def onmessage(message):
    message.content.lower()
    if message.content.startswith("hello"):
        await message.channel.send("Hello!")

client.run('token')

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    onmessage 更改为on_message

    【讨论】:

      【解决方案2】:

      onmessage 更改为on_message。 也做from discord.ext import commands。 这就是您所缺少的,因为要使用 @client.event,您必须导入 discord.ext ...您的代码应该在那之后工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-08-18
        • 2021-11-03
        • 2020-12-03
        • 1970-01-01
        • 2022-11-27
        • 1970-01-01
        • 2016-12-27
        • 1970-01-01
        相关资源
        最近更新 更多