简体   繁体   English

为什么我的 bot.command function 在 discord.py 不工作?

[英]Why is my bot.command function in discord.py not working?

I have tried looking around the inte.net for answers but I'm not finding anything that fixes my problem:我尝试在 inte.net 上寻找答案,但没有找到任何可以解决我问题的方法:

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)

The length function does not work at all, and its not printing test print in the console. length function 根本不起作用,它不在控制台打印测试打印。

Does anyone know what the problem is?有谁知道问题是什么? there are a few other bot.xxx functions in there that works.那里还有一些其他的bot.xxx函数可以使用。

It does not work because you have double bot.它不起作用,因为你有双机器人。 Your should only have bot = commands.Bot(command_prefix='!')你应该只有bot = commands.Bot(command_prefix='!')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM