我不知道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")
答案 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")