Discord机器人未响应命令

时间:2019-09-08 20:37:39

标签: python discord.py

我正在设置Discord Bot做事。在它所做的事情中,它应该接受命令,但是这部分不起作用。

这是完整的代码

import os
import discord
from dotenv import load_dotenv
from random import randint
from discord.ext import commands

load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
bot = commands.Bot(command_prefix = "!")

@bot.event
async def on_ready():
    print(f'{bot.user} is online')

@bot.event
async def on_member_join(member):
    await member.create_dm()
    await member.dm_channel.send("Welcome")

@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    if "tea" in message.content:
        response = f"Here is your tea, {message.author.name}."
        await message.channel.send(response)

@bot.command()
async def foo(ctx):
    await ctx.send("foo")


bot.run(TOKEN)

机器人联机,打印on_ready消息,响应tea,在on_member_join触发,但不响应!foo。我在做什么错了?

0 个答案:

没有答案
相关问题