无论我怎么努力,bot.command 都不起作用 (discord.py)



我一直在尝试制作一个discord bot,我已经能够让它响应消息事件,但我无法让命令工作,我尝试了我在堆栈上看到的几乎所有解决方案。我确实收到错误陈述

Unused import statement 'import discord':2

这是代码-

from discord.ext import commands
import discord
bot = commands.Bot(command_prefix='.')

@bot.command(pass_context=True)
async def ping(ctx):
await ctx.send('pong!')

@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.content.startswith('yo'):
await message.channel.send('yo momma is fat')
bot.run('token')

您不需要pass_context=True,它很旧,不确定从哪里得到的,而且,在discord.ext之前导入discord.eext(仅用于格式化(

最新更新