import datetime
import disnake
from disnake.ext import commands
from disnake import TextInputStyle
intents = disnake.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
# Наследуем модальное окно
class MyModal(disnake.ui.Modal, commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
# Детали модального окна и его компонентов
components = [
disnake.ui.TextInput(
label="Укажите время проведения мероприятия",
placeholder="Укажите время в формате xx:xx",
custom_id='time',
min_length=5,
max_length=5,
),
disnake.ui.TextInput(
label="Укажите дату провденеия мероприятия",
placeholder="Укажите дату в формате xx.xx.xxxx",
custom_id='date',
min_length=10,
max_length=10,
),
]
super().__init__(
title="Мероприятие \"Дикая Эвакуация\" ",
custom_id="custom_id",
components=components,
)
# Обработка ответа, после отправки модального окна
async def callback(self, inter: disnake.ModalInteraction):
for key, value in inter.text_values.items():
embed = disnake.Embed(title="Мероприятие \"Дикая Эвакуация\"",
description = f'Мероприятие пройдет в **{inter.text_values.get("time", " ")}, {inter.text_values.get("date", " " )}.**\nПравила: https://forum.arizona-v.com/threads/30652/',
colour=0xFFFFFF,)
embed.set_footer (text="За победу в раунде фракция получит награду в размере $3.000.000",
icon_url="https://media.discordapp.net/attachments/1222103795262291978/1222113292156145704/az-logo.png?ex=661508b2&is=660293b2&hm=e74fcd9e6e3f11e5166e26ed9f14f11725f5960bdf5ab061b38001dc6fa8dc9b&=&format=webp&quality=lossless",
)
embed.set_image(url="https://images-ext-2.discordapp.net/external/lerhzXafW-D6pvLW8EKbobMiexJAg8sjsFSXqrrfx8c/https/images-ext-2.discordapp.net/external/Ke4qodlofOl46uJ9oRmO3VgtqktNVxY-GBkjBh0X6Fo/https/i.imgur.com/39n7XOR.png?format=webp&quality=lossless")
await inter.response.send_message(embed=embed)
@bot.slash_command(description="Запуск Дикой Эвакуации", test_guilds=[1222102533577900112])
async def event_start(inter: disnake.AppCmdInter):
await inter.response.send_modal(modal=MyModal())
def setup(bot: commands.Bot):
bot.add_cog(MyModal(bot))