Ответы пользователя по тегу Python
  • Почему бот подключается, но не распознает команды?

    LIREN
    @LIREN
    Пунктумофоб
    для создания команд лучше использовать @bot.command() ...
    + commands.Bot, а не discord.Client.

    from discord.ext import commands
    
    intents = discord.Intents.all()
    
    command_prefix = "!"
    bot = commands.Bot(
        command_prefix = command_prefix, 
        intents = intents, 
        help_command = None
    )
    
    COMMANDS = [
        "refresh"
    ]
    
    @bot.event
    async def on_message(message):
        if (message.author == bot.user):
            return
    
        elif (message.content.startswith(command_prefix)):
            if (message.content in command_prefix + COMMANDS):
                pass
            else:
                response = get_city(message.content)
                await message.channel.send(response)
    
    @bot.command()
    async def refresh(ctx):
        refresh()
    
    bot.run(TOKEN)
    Ответ написан
    Комментировать