дискорд бот отправка нескольких файлов

Рейтинг: 0Ответов: 1Опубликовано: 28.01.2023

код:

import discord
from discord.ext import commands


intents = discord.Intents.all()
intents.message_content = True
bot = commands.Bot(command_prefix='!', case_insensitive=True, intents=intents)


@bot.command()
async def news(ctx):
    em=discord.Embed(
        title='немного статистики',
        description="```fix\nааа``",
        color=0x2ecc71 )
    channel = bot.get_channel(1041746076920713246)
    await channel.send(embed=em,files=[
        discord.file("f.png"),
        discord.file("ff.png"),
        discord.file("fff.png")])
    
@bot.command()
async def newss(ctx):
    em=discord.Embed(title='немного статистики', description="fix\nааа", color=0x2ecc71)
    channel = bot.get_channel(1041746076920713246)
    await channel.send(embed=em)
    await channel.send(file=discord.File("f.png"))
    await channel.send(file=discord.File("ff.png"))
    await channel.send(file=discord.File("fff.png")

bot.run('токен')

news не работает, newss работает, но мне надо отправить все одним сообщением ошибка:

  File "C:\Users\Student\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\com    ret = await coro(*args, **kwargs)    
  File "e:\bot\bote.py", line 18, in news    discord.file("f.png"),
TypeError: 'module' object is not callable

The above exception was the direct cause 
of the following exception:

Traceback (most recent call last):       
  File "C:\Users\Student\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.s\Python310\site-packages\discord\ext\commands\bot.py", line 1349, in invoke      
    await ctx.command.invoke(ctx)        
  File "C:\Users\Student\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 1023, in invoke     
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Student\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 238, in wrapped     
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'module' object is not callable

Ответы

▲ 0

Ошибка заключается в команде:

@bot.command()
async def news(ctx):
    em=discord.Embed(
        title='немного статистики',
        description="```fix\nааа``",
        color=0x2ecc71 )
    channel = bot.get_channel(1041746076920713246)
    await channel.send(embed=em,files=[
        discord.file("f.png"),
        discord.file("ff.png"),
        discord.file("fff.png")])

А конкретнее в строках:

        discord.file("f.png"),
        discord.file("ff.png"),
        discord.file("fff.png")])

Вы указали discord.file в нижнем регистре. Исправьте это:

        discord.File("f.png"),
        discord.File("ff.png"),
        discord.File("fff.png")])

Будьте, пожалуйста, внимательней.