import os
import disnake
from disnake.ext import commands
from disnake import ui
TOKEN = os.environ['TOKEN_DISCORD']
bot = commands.InteractionBot()
@bot.slash_command(name="support", description="Система поддержки")
async def support(inter: disnake.ApplicationCommandInteraction):
await inter.response.send_message(
components=[
ui.Container(
ui.TextDisplay(
content=(
"## Система поддержки\n"
"Выберите тип обращения, а сотрудники нашего сообщества "
"своевременно и качественно помогут решить это."
)
),
ui.TextDisplay(content="### Жалобы"),
ui.Section(
ui.TextDisplay(content="Жалоба на игрока"),
accessory=ui.Button(
emoji="",
style=disnake.ButtonStyle.secondary,
custom_id="complaint_player"
)
),
ui.Section(
ui.TextDisplay(content="Жалоба на персонал"),
accessory=ui.Button(
emoji="️",
style=disnake.ButtonStyle.secondary,
custom_id="complaint_staff"
)
),
ui.Separator(),
ui.TextDisplay(content="### Заявки"),
ui.Section(
ui.TextDisplay(content="Подать апелляцию"),
accessory=ui.Button(
emoji="",
style=disnake.ButtonStyle.secondary,
custom_id="appeal"
)
),
ui.Separator(),
ui.TextDisplay(content="### Улучшения"),
ui.Section(
ui.TextDisplay(content="Сообщить о баге"),
accessory=ui.Button(
emoji="",
style=disnake.ButtonStyle.secondary,
custom_id="bug_report"
)
),
ui.Section(
ui.TextDisplay(content="Предложить улучшение"),
accessory=ui.Button(
emoji="⚙️",
style=disnake.ButtonStyle.secondary,
custom_id="suggestion"
)
),
ui.Separator(),
ui.TextDisplay(content="### Верификация"),
ui.Section(
ui.TextDisplay(content="Заявка роль 18+"),
accessory=ui.Button(
emoji="",
style=disnake.ButtonStyle.secondary,
custom_id="verify_18"
)
),
accent_colour=disnake.Colour.from_rgb(249, 134, 106),
),
# Select ВСЕГДА ВНЕ Container
ui.StringSelect(
placeholder="❓ Частые вопросы",
custom_id="faq_select",
options=[
disnake.SelectOption(label="Как подать жалобу?", value="faq_complaint"),
disnake.SelectOption(label="Сколько рассматривается заявка?", value="faq_time"),
disnake.SelectOption(label="Куда отправляются обращения?", value="faq_where"),
]
)
]
)
# ───── Обработчик кнопок ─────
@bot.listen("on_button_click")
async def on_button(inter: disnake.MessageInteraction):
cid = inter.component.custom_id
modal = ui.Modal(
title="Обращение в поддержку",
custom_id=f"modal_{cid}",
components=[
ui.TextInput(
label="Опишите проблему",
custom_id="text",
style=disnake.TextInputStyle.paragraph,
required=True,
max_length=1000,
)
],
)
await inter.response.send_modal(modal)
bot.run(TOKEN)