Ответы пользователя по тегу discord.py
  • Как исправить ошибку AttributeError: 'Client' object has no attribute 'command'?

    @AlmazZzik
    Приветствую!
    Исправил ваш код(ниже будет)

    Вместо client.command - bot.command

    Также посоветую убрать:
    await ctx.channel.purge()

    Опасная штука : )

    import discord
    
    from discord.ext import commands
    from discord.utils import get
    from discord.ext.commands import Bot
    
    config = {
    
    'token': 'Токен',
    'prefix': '>',
    
    
    }
    
    intents = discord.Intents.all()
    client = discord.Client(intents=discord.Intents.default())
    bot = commands.Bot(command_prefix= ">", intents=intents)
    
    @bot.command()
    async def Проверка(ctx):
        await ctx.send("Бот работает" )
    
    @bot.command(pass_context = True)
    async def kick(ctx, member: discord.Member, *, reason = None):
        await ctx.channel.purge()
        await member.kick(reason = reason)
    
    bot.run(config['token'])
    Ответ написан
    2 комментария