为什么discord.py中的bot.command函数不起作用?

时间:2020-02-22 20:15:03

标签: python discord discord.py

我尝试在互联网上寻找答案,但没有找到解决我问题的方法:

import os
import asyncio

import discord
from discord.ext import commands

token = "here is my token"

bot = discord.Client()

bot = commands.Bot(command_prefix='!')

@bot.command()
async def length(ctx):
    await ctx.send('your message is {} characters long.'.format(len(ctx.message.content)))
    print("test print")

bot.run(token)

length功能根本无法使用,并且无法在控制台中打印测试打印。

有人知道问题出在哪里吗?还有一些其他bot.xxx函数可以正常工作。

1 个答案:

答案 0 :(得分:0)

它不起作用,因为您有双重机器人。 您只能有bot = commands.Bot(command_prefix='!')