mirror of
https://github.com/yawaflua/PL_JusticeBot.git
synced 2025-12-09 20:09:31 +02:00
add patents add change days on passporot
This commit is contained in:
@@ -1,22 +1,18 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Interactions;
|
using Discord.Interactions;
|
||||||
using Discord.Rest;
|
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using DiscordApp.Database.Tables;
|
using DiscordApp.Database.Tables;
|
||||||
using DiscordApp.Enums;
|
using DiscordApp.Enums;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using spworlds.Types;
|
using spworlds.Types;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace DiscordApp.Justice.Interactions
|
namespace DiscordApp.Justice.Interactions
|
||||||
{
|
{
|
||||||
public class PassportInteraction : InteractionModuleBase<SocketInteractionContext>
|
public class PassportInteraction : InteractionModuleBase<SocketInteractionContext>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected private int _AddDays = 60;
|
||||||
|
|
||||||
|
|
||||||
[ComponentInteraction("newPassport")]
|
[ComponentInteraction("newPassport")]
|
||||||
public async Task AplyWork()
|
public async Task AplyWork()
|
||||||
=> await Context.Interaction.RespondWithModalAsync<NewPassportModal>("passportModal");
|
=> await Context.Interaction.RespondWithModalAsync<NewPassportModal>("passportModal");
|
||||||
@@ -45,9 +41,18 @@ namespace DiscordApp.Justice.Interactions
|
|||||||
SocketGuildUser user = Context.Guild.GetUser(Context.User.Id);
|
SocketGuildUser user = Context.Guild.GetUser(Context.User.Id);
|
||||||
Random random = new();
|
Random random = new();
|
||||||
User spUser = await User.CreateUser(passport.Applicant);
|
User spUser = await User.CreateUser(passport.Applicant);
|
||||||
|
DateTimeOffset toTime;
|
||||||
|
if (DateTimeOffset.FromUnixTimeSeconds(passport.birthDate).AddDays(14) < DateTimeOffset.Now)
|
||||||
|
{
|
||||||
|
toTime = DateTime.Now.AddDays(_AddDays);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toTime = DateTime.Now.AddDays(14);
|
||||||
|
}
|
||||||
|
|
||||||
DateTimeOffset toTime = DateTime.Now.AddDays(31);
|
|
||||||
int id = random.Next(00001, 99999);
|
int id = random.Next(00001, 99999);
|
||||||
|
while (id.ToString().Length < 5) { id = random.Next(00001, 99999); }
|
||||||
long unixTime = toTime.ToUnixTimeSeconds();
|
long unixTime = toTime.ToUnixTimeSeconds();
|
||||||
long nowUnixTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
long nowUnixTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||||
|
|
||||||
@@ -87,6 +92,7 @@ namespace DiscordApp.Justice.Interactions
|
|||||||
{
|
{
|
||||||
id = random.Next(00001, 99999);
|
id = random.Next(00001, 99999);
|
||||||
passport.Id = id;
|
passport.Id = id;
|
||||||
|
while (id.ToString().Length < 5) { id = random.Next(00001, 99999); }
|
||||||
Console.WriteLine(passport.Id);
|
Console.WriteLine(passport.Id);
|
||||||
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result == null) { break; }
|
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result == null) { break; }
|
||||||
}
|
}
|
||||||
@@ -117,11 +123,11 @@ namespace DiscordApp.Justice.Interactions
|
|||||||
Random random = new();
|
Random random = new();
|
||||||
User spUser = await User.CreateUser(name);
|
User spUser = await User.CreateUser(name);
|
||||||
|
|
||||||
DateTimeOffset toTime = DateTime.Now.AddDays(60);
|
DateTimeOffset toTime = DateTime.Now.AddDays(_AddDays);
|
||||||
DateTime birthDate;
|
DateTime birthDate;
|
||||||
int id = random.Next(00001, 99999);
|
int id = random.Next(00001, 99999);
|
||||||
|
while (id.ToString().Length < 5) { id = random.Next(00001, 99999); }
|
||||||
long unixTime = toTime.ToUnixTimeSeconds();
|
long unixTime = toTime.ToUnixTimeSeconds();
|
||||||
long toUnixTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -129,7 +135,7 @@ namespace DiscordApp.Justice.Interactions
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await FollowupAsync($"Возможно, с датой {modal.Birthday} какая-то ошибка, попробуйте такой тип: 14.02.2023", ephemeral: true);
|
await FollowupAsync($"Возможно, с датой `{modal.Birthday}` какая-то ошибка, попробуйте такой тип: 14.02.2023", ephemeral: true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +177,7 @@ namespace DiscordApp.Justice.Interactions
|
|||||||
while (!isUnical)
|
while (!isUnical)
|
||||||
{
|
{
|
||||||
id = random.Next(00001, 99999);
|
id = random.Next(00001, 99999);
|
||||||
|
while (id.ToString().Length < 5) { id = random.Next(00001, 99999); }
|
||||||
passport.Id = id;
|
passport.Id = id;
|
||||||
Console.WriteLine(passport.Id);
|
Console.WriteLine(passport.Id);
|
||||||
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result == null) { break; }
|
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result == null) { break; }
|
||||||
@@ -238,7 +245,7 @@ namespace DiscordApp.Justice.Interactions
|
|||||||
if (birthDate.AddDays(14) < DateTime.Now)
|
if (birthDate.AddDays(14) < DateTime.Now)
|
||||||
{
|
{
|
||||||
await FollowupAsync($"Возможно, игрок {name} больше не новичек, и бесплатный паспорт ему не положен! Оформляю паспорт на месяц...0", ephemeral: true);
|
await FollowupAsync($"Возможно, игрок {name} больше не новичек, и бесплатный паспорт ему не положен! Оформляю паспорт на месяц...0", ephemeral: true);
|
||||||
toTime = DateTimeOffset.Now.AddDays(31);
|
toTime = DateTimeOffset.Now.AddDays(60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
6
Justice/Interactions/Patents.cs
Normal file
6
Justice/Interactions/Patents.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace DiscordApp.Justice.Interactions
|
||||||
|
{
|
||||||
|
public class Patents
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user