Библиотека: disnake
Code:
@client.listen("on_button_click")
async def button_click_event(inter):
custom_id = inter.component.custom_id
if custom_id=='register':
await inter.response.send_modal(
title='Зарегистрироватся на сервер',
custom_id='model',
components = [
disnake.ui.TextInput(
label='Ваш ник',
placeholder='nikck',
custom_id='nick',
style=disnake.TextInputStyle.short,
min_length=5,
max_length=50
)
]
)
try:
modal_inter: disnake.ModalInteraction = await client.wait_for(
"modal_submit",
check=lambda i: i.custom_id == "model" and i.author.id == inter.author.id,
timeout=600,
)
except asyncio.TimeoutError:
# The user didn't submit the modal in the specified period of time.
# This is done since Discord doesn't dispatch any event for when a modal is closed/dismissed.
return
nick = modal_inter.text_values['nick']
result = db.check_open(inter.user.id)
if result == False:
dt = datetime.datetime.today()
time = dt.strftime('`%H:%M - %m.%d.%Y`')
embedvar = disnake.Embed(title=f'',description=f"**Успешная регистрация <:1130232102831534121:1150033114375147571>**\n\nТеперь вы сможете играть на сервере\nЕсли у вас проблема со входом обращайтесь сюда: <#1145655430333333545>", color=0x00ff00)
await function.sendc(command=f'easywl add {nick}')
await inter.response.send_message(embed=embedvar,ephemeral=True)
await db.accept(inter.user.id)
embedown = disnake.Embed(title=f'',description=f'**Игрок успешно зарегистрировался <:1130232102831534121:1150033114375147571>**\n\nЕго никнейм `{nick}`\nДата/Время {time}')
await client.get_user(812661717099741186).send(embed=embedown)
await client.get_user(1066020104388755567).send(embed=embedown)
else:
embedvar=disnake.Embed(title=f'',description=f'**Вы уже зарегистрировались**')
await response.send_message.send(f'',embed=embedvar)
Ошибка:
Ignoring exception in on_button_click
Traceback (most recent call last):
File "C:\Python312\Lib\site-packages\disnake\client.py", line 703, in _run_event
await coro(*args, **kwargs)
File "D:\botuni\main.py", line 49, in button_click_event
await inter.response.send_message(embed=embedvar,ephemeral=True)
File "C:\Python312\Lib\site-packages\disnake\interactions\base.py", line 957, in send_message
raise InteractionResponded(self._parent)
disnake.errors.InteractionResponded: This interaction has already been responded to before