return self.client._interaction_lookup[self._command_name] KeyError: 'latestsong'

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

Делаю дискорд бота для своего сервера. Не знаю почему, но резко вылезла эта ошибка. Использую библиотеку interactions.py (последняя версия) для своего бота.

Код:

import interactions
from interactions import slash_command, SlashContext, Embed

# остальной код

@slash_command(description="Get the latest song from KGDPS that has been uploaded to the servers", group_name="extra", group_description="Commands connected with KGDPS Website")
async def song(ctx: SlashContext):
  async with aiohttp.ClientSession() as session:
    async with session.get(f"{link}/bot/latestSong.php") as song:
        song_text = await song.text()

        discordEmbed = Embed(title="Последняя песня с KGDPS", description="Последняя песня с KGDPS", color="#ffffff")

        song_data = song_text.split()
        discordEmbed.add_field(name="ID", value=song_data[3].replace(",", ""), inline=True)
        discordEmbed.add_field(name="Name", value=song_data[5], inline=True)

        await ctx.send(embed=discordEmbed)

Полная ошибка:

Task exception was never retrieved
future: <Task finished name='Task-69' coro=<Client._dispatch_interaction() done, defined at /home/runner/bot/venv/lib/python3.10/site-packages/interactions/client/client.py:1763> exception=KeyError('latestsong')>
Traceback (most recent call last):
  File "/home/runner/bot/venv/lib/python3.10/site-packages/interactions/client/client.py", line 1788, in _dispatch_interaction
    if ctx.command:
  File "/home/runner/bot/venv/lib/python3.10/site-packages/interactions/models/internal/context.py", line 311, in command
    return self.client._interaction_lookup[self._command_name]
KeyError: 'latestsong'

Ответы

▲ 0Принят

Проблема не в коде, а как я понял, в группе. Строчки с ними и вызывали ошибки. Исправленный код:

@slash_command(description="Get the latest song from KGDPS that has been uploaded to the servers")
async def song(ctx: SlashContext):
      # код