Files
PL_JusticeBot/Justice/Interactions/NotaryInteractions.cs
Дмитрий Шиманский dde8b38520 updated
2023-11-09 00:24:18 +03:00

36 lines
1.5 KiB
C#

using Discord.Interactions;
using DiscordApp.Justice.Modals;
using DiscordApp.Utilities;
namespace DiscordApp.Justice.Interactions
{
public class NotaryInteractions : InteractionModuleBase<SocketInteractionContext>
{
[ComponentInteraction("NewDocumentCertificate")]
public async Task newCertificatedDocument()
=> await Context.Interaction.RespondWithModalAsync<INotaryModal>("newCertificatedDocument");
[ModalInteraction("newCertificatedDocument")]
public async Task newCertificatedDocumentModal(INotaryModal modal)
{
await DeferAsync(true);
int passportId;
int documentId;
int certificateId;
Random random = new Random();
IdChecker.IdLenghtIsLower(out certificateId);
documentId = Startup.appDbContext.Certificates.OrderBy(t => t.Id).First().Id + 1;
bool isInt = int.TryParse(modal.passportId, out passportId);
if (!isInt)
{
await FollowupAsync($"Айди паспорта еще старое, попробуй использовать другого бота.", ephemeral: true);
}
else if (Startup.appDbContext.Passport.Find(passportId) == null)
{
await FollowupAsync($"Паспорт не найден в базе данных, попробуй написать правильно", ephemeral: true);
}
}
}
}