[英]Python AttributeError: 'Client' object has no attribute 'command'
returns an error返回错误
(venv) C:\\Users\\stast\\OneDrive\\Рабочий стол\\ManagunBot>bot.py Traceback (most recent call last): File "C:\\Users\\stast\\OneDrive\\Рабочий стол\\ManagunBot\\bot.py", line 19, in @bot.command() AttributeError: 'Client' object has no attribute 'command' (venv) C:\\Users\\stast\\OneDrive\\Рабочий стол\\ManagunBot>bot.py Traceback(最近一次调用最后一次):文件“C:\\Users\\stast\\OneDrive\\Рабочий стол\\ManagunBot\\bot.py”,行19、在@bot.command() AttributeError: 'Client' object has no attribute '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'])
You replaced your commands.Bot()
with discord.Client()
.你用discord.Client()
替换了你的commands.Bot()
discord.Client()
。 Try this instead:试试这个:
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'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.