Command raised an exception: AttributeError: 'Context' object has no attribute 'response
await interaction.response.send_message(f'Проверьте: всё ли правильно написано, если нет, то снова введите команду `!description`.\nВаш текст: {prikol["service_description"]}', files=files_to_send, view=view, ephemeral=True)
выводит ошибку "Command raised an exception: AttributeError: 'Context' object has no attribute 'response''
". Пытался заменить response
на followup
, send_message
на просто send
.. Но все равно результат один.
Если заменить interaction.message.send_message
на interaction.send
и не убрать параметрephemeral=True
, то будет новая ошибка: "Command raised an exception: TypeError: Messageable.send() got an unexpected keyword argument 'ephemeral'
".
Команда, в которой используется данная строка:
@bot.command(name="description")
async def desc(interaction: disnake.MessageInteraction, *args): # interaction: disnake.MessageInteraction
global service_desc, picture_files
prikol["service_description"] = " ".join(args)
view = continue_button_class2()
order_channel = bot.get_channel(1130092027942555740)
if interaction.author != bot.user:
if len(interaction.message.attachments) > 0 and interaction.message.content:
picture_files = []
unsupported_files = []
for attachment in interaction.message.attachments:
await attachment.save(os.path.join("cache", attachment.filename))
if attachment.filename.lower().endswith((".png", ".jpg", ".jpeg", ".gif")):
file = File(os.path.join("cache", attachment.filename))
picture_files.append(file)
else:
unsupported_files.append(attachment.filename)
if unsupported_files:
await interaction.send("Формат следующих файлов не поддерживается: {}".format(", ".join(unsupported_files)))
username = interaction.author.name
file_count = 1
for file in picture_files:
filename, extension = os.path.splitext(file.filename)
if username in filename:
for fake_file in os.listdir("cache"):
#filename, extension = os.path.splitext(file)
os.remove(os.path.join("cache", fake_file))
new_filename = f"{username} ({file_count}){extension}"
file.close()
os.rename(os.path.join("cache", file.filename), os.path.join("cache", new_filename))
file_count += 1
files_to_send = []
for filename in os.listdir("cache"):
if username in filename:
with open(os.path.join("cache", filename), 'rb') as f:
file = disnake.File(f)
files_to_send.append(file)
if files_to_send:
await interaction.response.send_message(f'Проверьте: всё ли правильно написано, если нет, то снова введите команду `!description`.\nВаш текст: {prikol["service_description"]}',
files=files_to_send, view=view, ephemeral=True)
elif interaction.message.content:
await interaction.response.send_message(f'Проверьте: всё ли правильно написано, если нет, то снова введите команду `!description`.\nВаш текст: {prikol["service_description"]}',
view=view, ephemeral=True)
Источник: Stack Overflow на русском