不和谐主持人Bot

时间:2020-04-15 17:58:16

标签: python bots discord discord.py

我不知道on_message事件 一切似乎都是正确的,控制台中没有错误,但是该漫游器没有响应消息

import discord
from discord.ext import commands
from discord.ext.commands import Bot
client = commands.Bot(command_prefix='!')

hello_words = ["Hello", "Hi", "qq", "w'zz"]


@client.event
async def on_ready():
    print("Ready") # if the bot running


async def on_message(message):
    msg = message.content.lower()
    if msg in hello_words:
        await message.channel.send("Hello")

client.run("token")

1 个答案:

答案 0 :(得分:0)

您需要将client.event装饰器添加到on_message函数中。您还应该添加检查以确保该漫游器不会响应其自身的消息。

@client.event
async def on_message(message):
    if message.author.bot: 
        return
    msg = message.content.lower()
    if msg in hello_words:
        await message.channel.send("Hello")