返回错误
(venv) C:UsersstastOneDriveРабочийстол ManagunBot> bot.py回溯(最近一次调用):文件"C:UsersstastOneDriveРабочий столManagunBotbot.py",第19行,in@bot.command ()AttributeError: 'Client' object没有属性'command'
import discord
from discord.ext import commands
from config import settings
prefix = settings['PREFIX']
bot = commands.Bot(command_prefix = settings['PREFIX'], intents=discord.Intents.all())
bot.remove_command('help')
bot = discord.Client(activity=discord.Game(name='!help')) # активность бота (во что играет)
@bot.event
async def on_ready():
print('Бот успешно запущен!') # Вывод готовности в консоль
@bot.command()
async def ping(ctx):
await ctx.send("Pong")
client.run (settings['TOKEN'])
你们用discord.Client()
代替了commands.Bot()
。试试这个:
import discord
from discord.ext import commands
from config import settings
prefix = settings['PREFIX']
bot = commands.Bot(command_prefix = settings['PREFIX'], intents=discord.Intents.all())
bot.remove_command('help')
@bot.event
async def on_ready():
print('Бот успешно запущен!') # Вывод готовности в консоль
await bot.change_presence(activity=discord.Game(name='!help')) # активность бота (во что играет)
@bot.command()
async def ping(ctx):
await ctx.send("Pong")
bot.run(settings['TOKEN'])