简体   繁体   English

Python AttributeError:“客户端”对象没有属性“命令”

[英]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.

相关问题 Python: AttributeError: 'Client' object 没有属性 'command' - Python: AttributeError: 'Client' object has no attribute 'command' 这段代码有什么问题?(Python) AttributeError: 'Client' object has no attribute 'command' - What is the problem with this code?(Python) AttributeError: 'Client' object has no attribute 'command' @bot.command() AttributeError: 'Client' object 没有属性 'command' - @bot.command() AttributeError: 'Client' object has no attribute 'command' AttributeError: 'Command' object 在 discord.py 中没有属性 'client' - AttributeError: 'Command' object has no attribute 'client' in discord.py AttributeError: 'Client' object 没有属性 'command' 第 45 行 - AttributeError: 'Client' object has no attribute 'command' Line 45 AttributeError:“客户端”对象没有属性“ send_message”(DiscordBot python) - AttributeError: 'Client' object has no attribute 'send_message' (DiscordBot python) Twilio Python 中的 API 返回 AttributeError: 'Client' ZA8CFDE6331BD59EB6666 没有属性'Ctudio' - Twilio API in Python Returning AttributeError: 'Client' object has no attribute 'studio' Python AttributeError: Object 没有属性 - Python AttributeError: Object has no attribute AttributeError: 'Client' 对象没有属性 'command'“@client.command() 模块中的第 6 行 - AttributeError: 'Client' object has no attribute 'command' "line 6 in module @client.command() AttributeError:'str'对象没有属性'client' - AttributeError: 'str' object has no attribute 'client'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM