简体   繁体   中英

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'

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() . 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'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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