【问题标题】:Is there a event in the Discord API that triggers whenever any message is sent?Discord API 中是否有在发送任何消息时触发的事件?
【发布时间】:2020-04-16 10:30:27
【问题描述】:

我正在尝试编写一个 Discord 机器人,它在读取其内容并将其存储在变量中后回复频道中的每条消息。它看起来像这样:

@bot.event
async def whenMessageSent()
    i=readmessage()
    print(i)
#replace WhenMessageSent and ReadMessage with the correct function names.

我需要找到正确的函数来替换“whenMessageSent”和“ReadMessage”。我正在使用最新的 Discord Python API,但没有任何文档可以帮助我解决这个问题。非常感谢任何帮助。

【问题讨论】:

    标签: python discord


    【解决方案1】:
    @bot.event
    async def on_message(message):
        i = message.content
        print(i) 
    

    on_message(message) 是 whenMessageSend()

    message.content 是 readmessage()

    阅读Discord Python API Documentary 了解更多信息。

    【讨论】:

    • context please... ATM 你的答案是赢得 2019 年低质量帖子审查奖!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 2016-02-04
    相关资源
    最近更新 更多