Питон, дискорд. Выполнение команды с телефона ломает скрипт

Не могу понять, почему если выполнять команду в Discord с клиента на компе, то все работает отлично. А если ее же с телефона, то скрипт вешается и больше не работает, пока не перезапустишь.

код

import disnake
from disnake.ext import commands

# Префикс для команд бота
bot = commands.Bot(command_prefix='/', help_command=None, intents=disnake.Intents.all())

# Эвент при запуске бота
@bot.event
async def on_ready():
    print(f"Bot {bot.user} is ready to work!")



#@bot.command(name="подарок", aliases=["gjlfhjr"])
@bot.slash_command(description="Быстрый расчет что нужно запихнуть клиенту в подарок. Пока без учета скидки клиента.")
async def gift(result_gift, сумма_подарка:int):

    # Сумма, на которую делаем подарки
    summ_podark = сумма_подарка

# Список товаров 'Имя':(цена,ценность)
# 
    stuffdict = {'GW40 210мл (973520-3210)':(300,1), 
                 'Перчатки (PGT-020)':(20,1), 
                 'Очки защитные Классик (GL-01010)':(61,1), 
                 'Очиститель тормозов (973520-0650)':(240,1),
                 'Разрушитель ржавчины (973520-4500)':(270,1),
                 'Паста-смывка 200мл (973515-4002)':(195,1),
                 'Отвертка трещоточная с набором бит (636120)':(816,1),
                 'Набор бит 1/4" 25 мм на держателе (ALK-8009-BIT1-CK)': (353,1),
                 'Фонарь налобный (GL-HLR300)':(2000,1)
                }

    def get_area_and_value(stuffdict):
        area = [stuffdict[item][0] for item in stuffdict]
        value = [stuffdict[item][1] for item in stuffdict]        
        return area, value

    def get_memtable(stuffdict, A=summ_podark):
          area, value = get_area_and_value(stuffdict)
          n = len(value) # находим размеры таблицы
      
          # создаем таблицу из нулевых значений
          V = [[0 for a in range(A+1)] for i in range(n+1)]

          for i in range(n+1):
                for a in range(A+1):
                      # базовый случай
                      if i == 0 or a == 0:
                            V[i][a] = 0

                      # если площадь предмета меньше площади столбца,
                      # максимизируем значение суммарной ценности
                      elif area[i-1] <= a:
                            V[i][a] = max(value[i-1] + V[i-1][a-area[i-1]], V[i-1][a])

                      # если площадь предмета больше площади столбца,
                      # забираем значение ячейки из предыдущей строки
                      else:
                            V[i][a] = V[i-1][a]       
          return V, area, value
          V[i][a] = max(value[i-1] + V[i-1][a-area[i-1]], V[i-1][a])


    def get_selected_items_list(stuffdict, A=summ_podark):
          V, area, value = get_memtable(stuffdict)
          n = len(value)
          res = V[n][A]      # начинаем с последнего элемента таблицы
          a = A              # начальная сумма - максимальная
          items_list = []    # список сумм и ценностей
    
          for i in range(n, 0, -1):  # идем в обратном порядке
                if res <= 0:  # условие прерывания - собрали "рюкзак" 
                      break
                if res == V[i-1][a]:  # ничего не делаем, двигаемся дальше
                      continue
                else:
                      # "забираем" предмет
                      items_list.append((area[i-1], value[i-1]))
                      res -= value[i-1]   # отнимаем значение ценности от общей
                      a -= area[i-1]  # отнимаем сумму от общей
            
          selected_stuff = []

          # находим ключи исходного словаря - названия предметов
          for search in items_list:
                for key, value in stuffdict.items():
                      if value == search:
                            selected_stuff.append(key)
            
          return selected_stuff

    stuff = get_selected_items_list(stuffdict)
#    print(stuff)
    d = stuff
#    print('\n'.join(d))
    await result_gift.send(str('\n'.join(d)))



# токен дискорд бота для запуска
bot.run("токен")

Если выполнить команду с телефона, я в консоли получу эту ошибку:

Ignoring exception in slash command 'gift':                                                                                     |
Traceback (most recent call last):                                                                                              |
  File "/usr/local/lib/python3.9/dist-packages/disnake/interactions/base.py", line 985, in send_message                         |
    await adapter.create_interaction_response(                                                                                  |
  File "/usr/local/lib/python3.9/dist-packages/disnake/webhook/async_.py", line 199, in request                                 |
    raise NotFound(response, data)                                                                                              |
disnake.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction                                                 |
                                                                                                                                |
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/disnake/ext/commands/slash_core.py", line 730, in invoke
    await call_param_func(self.callback, inter, self.cog, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/disnake/ext/commands/params.py", line 1022, in call_param_func
    return await maybe_coroutine(safe_call, function, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/disnake/utils.py", line 599, in maybe_coroutine
    return await value
  File "/home/Garwin_bot.py", line 103, in gift
    await result_gift.send(str('\n'.join(d)))
  File "/usr/local/lib/python3.9/dist-packages/disnake/interactions/base.py", line 672, in send
    await sender(
  File "/usr/local/lib/python3.9/dist-packages/disnake/interactions/base.py", line 995, in send_message
    raise InteractionTimedOut(self._parent) from e
disnake.errors.InteractionTimedOut: Interaction took more than 3 seconds to be responded to. Please defer it using "interaction.
response.defer" on the start of your command. Later you may send a response by editing the deferred message using "interaction.e
dit_original_response"
Note: This might also be caused by a misconfiguration in the components make sure you do not respond twice in case this is a com
ponent.

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/disnake/ext/commands/interaction_bot_base.py", line 1353, in process_application_
commands
    await app_command.invoke(interaction)
  File "/usr/local/lib/python3.9/dist-packages/disnake/ext/commands/slash_core.py", line 739, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: InteractionTimedOut: Interaction took more than 3 s
econds to be responded to. Please defer it using "interaction.response.defer" on the start of your command. Later you may send a
 response by editing the deferred message using "interaction.edit_original_response"
Note: This might also be caused by a misconfiguration in the components make sure you do not respond twice in case this is a com
ponent.

Python: 3.9.2 Disnake: 2.7.0


Ответы (0 шт):