add notary module, utilities and server online in bot`s game

This commit is contained in:
Дмитрий Шиманский
2023-11-11 18:08:33 +03:00
parent dde8b38520
commit 7ce56c1388
12 changed files with 514 additions and 27 deletions

View File

@@ -26,8 +26,10 @@ namespace DiscordApp.Justice.Interactions
return;
}
User spApplicant = await User.CreateUser(applicant.Applicant);
var employees = new List<int>();
employees.Add(applicant.Id);
var employees = new List<int>
{
applicant.Id
};
Bizness biznessDB = new()
{

View File

@@ -1,6 +1,10 @@
using Discord.Interactions;
using Discord;
using Discord.Interactions;
using DiscordApp.Database.Tables;
using DiscordApp.Justice.Modals;
using DiscordApp.Types;
using DiscordApp.Utilities;
using Microsoft.AspNetCore.Authorization;
namespace DiscordApp.Justice.Interactions
{
@@ -17,19 +21,75 @@ namespace DiscordApp.Justice.Interactions
int passportId;
int documentId;
int certificateId;
string thumbnailUrl;
Passport passport;
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)
Utilities.Utilities.IdGenerator(out certificateId);
documentId = Startup.appDbContext.Certificates.OrderBy(t => t.Id).FirstOrDefault().Id;
documentId += 1;
if (!int.TryParse(modal.passportId, out passportId))
{
await FollowupAsync($"Айди паспорта еще старое, попробуй использовать другого бота.", ephemeral: true);
return;
}
else if (Startup.appDbContext.Passport.Find(passportId) == null)
else if (Utilities.Utilities.IsPassport(passportId, out passport))
{
await FollowupAsync($"Паспорт не найден в базе данных, попробуй написать правильно", ephemeral: true);
return;
}
Certificate certificate = new()
{
Date = DateOnly.FromDateTime(DateTime.Now),
DocumentId = documentId,
Employee = ((IGuildUser)Context.User).DisplayName,
Id = certificateId,
passport = passport,
Text = modal.documentText,
DocumentType = modal.documentType
};
Reports report = new()
{
Employee = Startup.sp.GetUser(Context.User.Id.ToString()).Result.Name,
type = ReportTypes.editPassport
};
await Startup.appDbContext.Reports.AddAsync(report);
await Startup.appDbContext.Certificates.AddAsync(certificate);
if (!modal.documentText.StartsWith("test"))
await Startup.appDbContext.SaveChangesAsync();
try
{
thumbnailUrl = spworlds.Types.User.CreateUser(passport.Applicant).Result.GetSkinPart(spworlds.Types.SkinPart.face);
}
catch
{
thumbnailUrl = null;
}
var author = new EmbedAuthorBuilder()
.WithName(((IGuildUser)Context.User).DisplayName)
.WithIconUrl(((IGuildUser)Context.User).GetDisplayAvatarUrl());
var field1 = new EmbedFieldBuilder()
.WithName("Данные документа:")
.WithValue($"ID документа: {documentId}\nID паспорта: {passport.Id}\nID сертификата: {certificateId}\n\nАпликант: {passport.Applicant}");
var field2 = new EmbedFieldBuilder()
.WithName("Текст документа:")
.WithValue($"```{modal.documentText}```");
var embed = new EmbedBuilder()
.WithTitle("Заверен новый документ")
.WithAuthor(author)
.WithThumbnailUrl(thumbnailUrl)
.WithFields(field1)
.WithFields(field2)
.WithColor(Color.DarkBlue)
.Build();
var channel = Context.Guild.GetChannel(1172879659193606164) as ITextChannel;
await channel.SendMessageAsync(embed: embed);
await FollowupAsync(embed: embed);
}
}
}

View File

@@ -15,6 +15,7 @@ namespace DiscordApp.Justice.Interactions
{
await DeferAsync(true);
int passportId;
string thumbnailUrl;
Passport passport;
bool isInteger = int.TryParse(modal.passport, out passportId);
if (isInteger)
@@ -42,11 +43,18 @@ namespace DiscordApp.Justice.Interactions
new EmbedFieldBuilder().WithName("Годен до").WithValue($"<t:{passport.Date}:D>").WithIsInline(true),
new EmbedFieldBuilder().WithName("Паспортист").WithValue($"<@{passport.Employee}>").WithIsInline(true)
};
var spUser = await spworlds.Types.User.CreateUser(passport.Applicant);
var embed = new EmbedBuilder()
try
{
thumbnailUrl = spworlds.Types.User.CreateUser(passport.Applicant).Result.GetSkinPart(spworlds.Types.SkinPart.face);
}
catch
{
thumbnailUrl = null;
}
var embed = new EmbedBuilder()
.WithTitle("**Информация о паспорте**")
.WithFields(fields)
.WithThumbnailUrl(spUser.GetSkinPart(spworlds.Types.SkinPart.face))
.WithThumbnailUrl(thumbnailUrl)
.Build();
await FollowupAsync(embed:embed, ephemeral: true);

View File

@@ -159,7 +159,7 @@ namespace DiscordApp.Justice.Interactions
DateTimeOffset toTime;
DateOnly birthDate;
int id;
Utilities.IdChecker.IdLenghtIsLower(out id);
Utilities.Utilities.IdGenerator(out id);
long unixBirthDateTime;
string cityName;
string cardNumber;
@@ -242,7 +242,7 @@ namespace DiscordApp.Justice.Interactions
bool isUnical = false;
while (!isUnical)
{
Utilities.IdChecker.IdLenghtIsLower(out id);
Utilities.Utilities.IdGenerator(out id);
passport.Id = id;
Console.WriteLine(passport.Id);
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result == null) { break; }