簡體   English   中英

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

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

我嘗試在 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)

length function 根本不起作用,它不在控制台打印測試打印。

有誰知道問題是什么? 那里還有一些其他的bot.xxx函數可以使用。

它不起作用,因為你有雙機器人。 你應該只有bot = commands.Bot(command_prefix='!')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM