добавил переделывание паспортов

This commit is contained in:
Дмитрий Шиманский
2023-10-26 19:57:40 +03:00
parent b4f1dfdbb4
commit d612c80bc9
13 changed files with 622 additions and 63 deletions

View File

@@ -9,7 +9,6 @@ namespace DiscordApp.Database
public DbSet<Passport> Passport { get; set; }
public DbSet<Autobranches> Autobranches { get; set; }
public DbSet<Autoreactions> Autoreactions { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

View File

@@ -1,14 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DiscordApp.Database.Tables
{
[Table("Autoreactions", Schema = "public")]
public class Autoreactions
{
[Key]
public ulong ChannelId { get; set; }
public string EmoteId { get; set; }
}
}

View File

@@ -12,6 +12,7 @@ namespace DiscordApp.Database.Tables
public ulong Employee { get; set; }
public string Applicant { get; set; }
public long Date { get; set; }
public long birthDate { get; set; }
public Supporter Support { get; set; }
public string Gender { get; set; }
public string RpName { get; set; }

View File

@@ -7,6 +7,7 @@
<UserSecretsId>392a6656-544a-410a-9be8-214215cd1cc8</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<ItemGroup>
@@ -18,8 +19,12 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
<PackageReference Include="spworlds" Version="1.0.4" />
<PackageReference Include="spworlds" Version="1.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@@ -15,30 +15,17 @@ namespace DiscordApp.Discord.Commands
[DefaultMemberPermissions(GuildPermission.Administrator)]
public async Task addAutoBranches(IChannel channel, string branchName = "Обсуждение")
{
await RespondAsync($"Автоветки для канала {channel.Name} настроены", ephemeral: true);
//await DeferAsync(true);
Autobranches autobranches = new()
{
ChannelId = channel.Id,
BranchName = branchName
};
Startup.appDbContext.Autobranches.Add(autobranches);
await Startup.appDbContext.SaveChangesAsync();
await FollowupAsync($"Автоветки для канала <#{channel.Id}> настроены", ephemeral: true);
}
[SlashCommand("emotes", "Настройка автоэмоций")]
[DefaultMemberPermissions(GuildPermission.Administrator)]
public async Task addAutoReact(string emote, IChannel channel)
{
var emotes = Emote.Parse(emote);
await RespondAsync($"Автореакция {emotes.Url} для канала {channel.Name} настроены", ephemeral: true);
Autoreactions autoreactions = new()
{
ChannelId = channel.Id,
EmoteId = emotes.ToString()
};
Startup.appDbContext.Autoreactions.Add(autoreactions);
}
[SlashCommand("embed", "Отправить эмбед")]
[DefaultMemberPermissions(GuildPermission.Administrator)]

View File

@@ -36,22 +36,15 @@ namespace DiscordApp.Justice.Events
public static async Task onMessageCreate(SocketMessage message)
{
/**
if (message.Type != MessageType.Default) { return; }
var autoBranchesDatabase = await Startup.appDbContext.Autobranches.FindAsync(message.Channel.Id);
var autoReactDatabase = await Startup.appDbContext.Autoreactions.ForEachAsync(s => s.ChannelId == message.Channel.Id);
if (autoBranchesDatabase != null)
{
await ((ITextChannel)message.Channel).CreateThreadAsync(autoBranchesDatabase.BranchName);
await ((ITextChannel)message.Channel).CreateThreadAsync(autoBranchesDatabase.BranchName, ThreadType.PublicThread, message: message);
}
if (autoReactDatabase != false)
{
foreach (Autoreactions autoreaction in autoReactDatabase)
{
var Emoji = Emote.Parse(autoreaction.EmoteId);
await message.AddReactionAsync(Emoji);
}
}
**/
}
}
}

View File

@@ -8,7 +8,9 @@ using Microsoft.EntityFrameworkCore;
using spworlds.Types;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
namespace DiscordApp.Justice.Interactions
{
@@ -18,9 +20,90 @@ namespace DiscordApp.Justice.Interactions
[ComponentInteraction("newPassport")]
public async Task AplyWork()
=> await Context.Interaction.RespondWithModalAsync<NewPassportModal>("passportModal");
[ComponentInteraction("reworkPassport")]
public async Task reCreatePassport()
=> await Context.Interaction.RespondWithModalAsync<ReWorkPassportModal>("reworkpassportModal");
[ComponentInteraction("reNewPassportButton")]
public async Task reNewPassportModal() => await Context.Interaction.RespondWithModalAsync<NewPassportModal>("ReNewPassportModal");
[ModalInteraction("passportModal")]
public async Task createPassportInteraction(NewPassportModal modal)
[ModalInteraction("reworkpassportModal")]
public async Task reCreatePassportInteraction(ReWorkPassportModal modal)
{
await DeferAsync(true);
double passportId = modal.Id;
bool recreatePassport = modal.IsNewPassport == 1;
if (recreatePassport)
{
await FollowupAsync("Нажмите на кнопку ниже", components: new ComponentBuilder().WithButton(new ButtonBuilder("Кнопочка", "reNewPassportButton")).Build(), ephemeral: true);
}
else
{
var passport = Startup.appDbContext.Passport.Where(x => x.Id == passportId).FirstOrDefault();
if (passport == null) { await FollowupAsync("ID паспорта не правильный, или не существует.", ephemeral: true); return; }
SocketGuildUser user = Context.Guild.GetUser(Context.User.Id);
Random random = new();
User spUser = await User.CreateUser(passport.Applicant);
DateTimeOffset toTime = DateTime.Now.AddDays(31);
int id = random.Next(00001, 99999);
long unixTime = toTime.ToUnixTimeSeconds();
long nowUnixTime = DateTimeOffset.Now.ToUnixTimeSeconds();
passport.Id = id;
passport.Date = nowUnixTime;
var passportData = new EmbedFieldBuilder()
.WithName("Данные паспорта:")
.WithValue(@$"
Имя: {passport.Applicant}
РП Имя: {passport.RpName}
Айди: {id}
Благотворитель: {passport.Support}
Гендер: {passport.Gender}
Дата рождения: <t:{passport.birthDate}:D>")
.WithIsInline(true);
var author = new EmbedAuthorBuilder()
.WithName(user.DisplayName)
.WithIconUrl(user.GetDisplayAvatarUrl());
var embed = new EmbedBuilder()
.WithTitle("**Паспорт переделан**")
.AddField(passportData)
.AddField(new EmbedFieldBuilder().WithName("Составитель: ").WithValue(user.GlobalName).WithIsInline(true))
.AddField(new EmbedFieldBuilder().WithName("Доступен до: ").WithValue($"<t:{toTime.ToUnixTimeSeconds()}:D>").WithIsInline(true))
.WithThumbnailUrl(spUser.GetSkinPart(SkinPart.face))
.WithColor(Color.DarkBlue)
.WithAuthor(author)
.WithTimestamp(toTime)
.Build();
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result != null)
{
bool isUnical = false;
while (!isUnical)
{
id = random.Next(00001, 99999);
passport.Id = id;
Console.WriteLine(passport.Id);
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result == null) { break; }
}
}
await Startup.appDbContext.Passport.AddAsync(passport);
await Startup.appDbContext.SaveChangesAsync();
await FollowupAsync($"ID для паспорта: {id}", embed: embed, ephemeral: true);
var channel = Context.Guild.GetChannel(1108006685626355733) as ITextChannel;
var message = await channel.SendMessageAsync(embed: embed);
}
}
[ModalInteraction("ReNewPassportModal")]
public async Task renewPassportInteraction(NewPassportModal modal)
{
await DeferAsync(true);
string name = modal.NickName;
@@ -32,21 +115,17 @@ namespace DiscordApp.Justice.Interactions
SocketGuildUser user = Context.Guild.GetUser(Context.User.Id);
Supporter supporter;
Random random = new();
spworlds.Types.User spUser = await spworlds.Types.User.CreateUser(name);
User spUser = await User.CreateUser(name);
DateTimeOffset toTime = DateTime.Now.AddDays(14);
DateTimeOffset toTime = DateTime.Now.AddDays(31);
DateTime birthDate;
int id = random.Next(00001, 99999);
long unixTime;
long unixTime = toTime.ToUnixTimeSeconds();
long toUnixTime = DateTimeOffset.Now.ToUnixTimeSeconds();
try
{
birthDate = DateTime.Parse(birthday);
unixTime = ((DateTimeOffset)birthDate).ToUnixTimeSeconds();
if (birthDate.AddDays(14) < DateTime.Now)
{
await FollowupAsync($"Возможно, игрок {name} больше не новичек, и бесплатный паспорт ему не положен!", ephemeral: true);
}
}
catch
{
@@ -74,29 +153,121 @@ namespace DiscordApp.Justice.Interactions
return;
}
Passport passport = new()
{
Employee = user.Id,
RpName = RpName,
Gender = gender,
Date = unixTime,
birthDate = ((DateTimeOffset)birthDate).ToUnixTimeSeconds(),
Applicant = name,
Id = id,
Support = supporter
};
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result != null)
{
bool isUnical = false;
while (!isUnical)
{
id = random.Next(00001, 99999);
passport.Id = id;
Console.WriteLine(passport.Id);
if (Startup.appDbContext.Passport.FindAsync(passport.Id).Result == null) { break; }
}
}
var passportData = new EmbedFieldBuilder()
.WithName("Данные паспорта:")
.WithValue($"```\nИмя: {name}\nРП Имя: {RpName}\nАйди: {id}\nБлаготворитель: {supporter}\nГендер: {gender}\nДата рождения: {birthDate.ToShortDateString()}```")
.WithIsInline(true);
.WithValue(@$"
Имя: {passport.Applicant}
РП Имя: {passport.RpName}
Айди: {id}
Благотворитель: {passport.Support}
Гендер: {passport.Gender}
Дата рождения: <t:{passport.birthDate}:D>").WithIsInline(true);
var author = new EmbedAuthorBuilder()
.WithName(user.DisplayName)
.WithIconUrl(user.GetDisplayAvatarUrl());
var faceUrl = "https://visage.surgeplay.com/face/64/" + spUser.Uuid;
Console.WriteLine(faceUrl);
var embed = new EmbedBuilder()
.WithTitle("**Новый паспорт**")
.WithTitle("**Паспорт переделан**")
.AddField(passportData)
.AddField(new EmbedFieldBuilder().WithName("Составитель: ").WithValue(user.GlobalName).WithIsInline(true))
.AddField(new EmbedFieldBuilder().WithName("Доступен до: ").WithValue($"<t:{toTime.ToUnixTimeSeconds()}:D>").WithIsInline(true))
.WithThumbnailUrl(faceUrl)
.WithThumbnailUrl(spUser.GetSkinPart(SkinPart.face))
.WithColor(Color.DarkBlue)
.WithAuthor(author)
.WithTimestamp(toTime)
.Build();
await Startup.appDbContext.Passport.AddAsync(passport);
await Startup.appDbContext.SaveChangesAsync();
await FollowupAsync($"ID для паспорта: {id}", embed: embed, ephemeral: true);
var channel = Context.Guild.GetChannel(1108006685626355733) as ITextChannel;
var message = await channel.SendMessageAsync(embed: embed);
}
[ModalInteraction("passportModal")]
public async Task createPassportInteraction(NewPassportModal modal)
{
await DeferAsync(true);
string name = modal.NickName;
string RpName = modal.RPName;
int supporterInt = modal.Supporter;
string birthday = modal.Birthday;
string gender = modal.Gender;
SocketGuildUser user = Context.Guild.GetUser(Context.User.Id);
Supporter supporter;
Random random = new();
User spUser = await User.CreateUser(name);
DateTimeOffset toTime = DateTime.Now.AddDays(14);
DateTime birthDate;
int id = random.Next(00001, 99999);
long unixTime;
try
{
birthDate = DateTime.Parse(birthday);
unixTime = ((DateTimeOffset)birthDate).ToUnixTimeSeconds();
if (birthDate.AddDays(14) < DateTime.Now)
{
await FollowupAsync($"Возможно, игрок {name} больше не новичек, и бесплатный паспорт ему не положен! Оформляю паспорт на месяц...0", ephemeral: true);
toTime = DateTimeOffset.Now.AddDays(31);
}
}
catch (Exception ex)
{
await FollowupAsync($"Возможно, с датой {modal.Birthday} какая-то ошибка, попробуйте такой тип: 14.02.2023", ephemeral: true);
Console.WriteLine($"Error in 237-243 line. Error: {ex.Message}");
return;
}
switch (supporterInt)
{
case 0:
supporter = Supporter.None;
break;
case 1:
supporter = Supporter.FirstLvl;
break;
case 2:
supporter = Supporter.SecondLvl;
break;
case 3:
supporter = Supporter.ThirdLvl;
break;
default:
await FollowupAsync("Неправильно указан уровень благотворителя. Используйте числа от 0 до 3(в зависимости от уровня)", ephemeral: true);
return;
}
Passport passport = new()
{
Employee = user.Id,
@@ -113,7 +284,6 @@ namespace DiscordApp.Justice.Interactions
bool isUnical = false;
while (!isUnical)
{
id = random.Next(00001, 99999);
passport.Id = id;
Console.WriteLine(passport.Id);
@@ -121,7 +291,31 @@ namespace DiscordApp.Justice.Interactions
}
}
var passportData = new EmbedFieldBuilder()
.WithName("Данные паспорта:")
.WithValue(@$"
Имя: {passport.Applicant}
РП Имя: {passport.RpName}
Айди: {id}
Благотворитель: {passport.Support}
Гендер: {passport.Gender}
Дата рождения: <t:{passport.birthDate}:D>")
.WithIsInline(true);
var author = new EmbedAuthorBuilder()
.WithName(user.DisplayName)
.WithIconUrl(user.GetDisplayAvatarUrl());
var embed = new EmbedBuilder()
.WithTitle("**Новый паспорт**")
.AddField(passportData)
.AddField(new EmbedFieldBuilder().WithName("Составитель: ").WithValue(user.GlobalName).WithIsInline(true))
.AddField(new EmbedFieldBuilder().WithName("Доступен до: ").WithValue($"<t:{toTime.ToUnixTimeSeconds()}:D>").WithIsInline(true))
.WithThumbnailUrl(spUser.GetSkinPart(SkinPart.face))
.WithColor(Color.DarkBlue)
.WithAuthor(author)
.WithTimestamp(toTime)
.Build();
await Startup.appDbContext.Passport.AddAsync(passport);
@@ -159,4 +353,18 @@ namespace DiscordApp.Justice.Interactions
}
public class ReWorkPassportModal : IModal
{
public string Title => "Создание паспорта";
[InputLabel("ID паспорта")]
[ModalTextInput("id", TextInputStyle.Short, placeholder: "82-777", maxLength: 7)]
public double Id { get; set; }
[InputLabel("Новые данные(0/1)")]
[ModalTextInput("isNewPassportData", TextInputStyle.Short, placeholder: "1 - да, 0 - нет", maxLength: 1, initValue: "0")]
public int IsNewPassport { get; set; }
}
}

View File

@@ -0,0 +1,93 @@
// <auto-generated />
using DiscordApp.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DiscordApp.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20231026134430_InternalMigration")]
partial class InternalMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DiscordApp.Database.Tables.Autobranches", b =>
{
b.Property<decimal>("ChannelId")
.ValueGeneratedOnAdd()
.HasColumnType("numeric(20,0)");
b.Property<string>("BranchName")
.IsRequired()
.HasColumnType("text");
b.HasKey("ChannelId");
b.ToTable("Autobranches", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Autoreactions", b =>
{
b.Property<decimal>("ChannelId")
.ValueGeneratedOnAdd()
.HasColumnType("numeric(20,0)");
b.Property<string>("EmoteId")
.IsRequired()
.HasColumnType("text");
b.HasKey("ChannelId");
b.ToTable("Autoreactions", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<long>("Date")
.HasColumnType("bigint");
b.Property<decimal>("Employee")
.HasColumnType("numeric(20,0)");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RpName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Support")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Passport", "public");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,79 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DiscordApp.Migrations
{
/// <inheritdoc />
public partial class InternalMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "public");
migrationBuilder.CreateTable(
name: "Autobranches",
schema: "public",
columns: table => new
{
ChannelId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
BranchName = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Autobranches", x => x.ChannelId);
});
migrationBuilder.CreateTable(
name: "Autoreactions",
schema: "public",
columns: table => new
{
ChannelId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
EmoteId = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Autoreactions", x => x.ChannelId);
});
migrationBuilder.CreateTable(
name: "Passport",
schema: "public",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Employee = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
Applicant = table.Column<string>(type: "text", nullable: false),
Date = table.Column<long>(type: "bigint", nullable: false),
Support = table.Column<int>(type: "integer", nullable: false),
Gender = table.Column<string>(type: "text", nullable: false),
RpName = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Passport", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Autobranches",
schema: "public");
migrationBuilder.DropTable(
name: "Autoreactions",
schema: "public");
migrationBuilder.DropTable(
name: "Passport",
schema: "public");
}
}
}

View File

@@ -0,0 +1,81 @@
// <auto-generated />
using DiscordApp.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DiscordApp.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20231026161439_AddBitrhDate")]
partial class AddBitrhDate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DiscordApp.Database.Tables.Autobranches", b =>
{
b.Property<decimal>("ChannelId")
.ValueGeneratedOnAdd()
.HasColumnType("numeric(20,0)");
b.Property<string>("BranchName")
.IsRequired()
.HasColumnType("text");
b.HasKey("ChannelId");
b.ToTable("Autobranches", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<long>("Date")
.HasColumnType("bigint");
b.Property<decimal>("Employee")
.HasColumnType("numeric(20,0)");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RpName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Support")
.HasColumnType("integer");
b.Property<long>("birthDate")
.HasColumnType("bigint");
b.HasKey("Id");
b.ToTable("Passport", "public");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DiscordApp.Migrations
{
/// <inheritdoc />
public partial class AddBitrhDate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Autoreactions",
schema: "public");
migrationBuilder.AddColumn<long>(
name: "birthDate",
schema: "public",
table: "Passport",
type: "bigint",
nullable: false,
defaultValue: 0L);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "birthDate",
schema: "public",
table: "Passport");
migrationBuilder.CreateTable(
name: "Autoreactions",
schema: "public",
columns: table => new
{
ChannelId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
EmoteId = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Autoreactions", x => x.ChannelId);
});
}
}
}

View File

@@ -0,0 +1,78 @@
// <auto-generated />
using DiscordApp.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DiscordApp.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DiscordApp.Database.Tables.Autobranches", b =>
{
b.Property<decimal>("ChannelId")
.ValueGeneratedOnAdd()
.HasColumnType("numeric(20,0)");
b.Property<string>("BranchName")
.IsRequired()
.HasColumnType("text");
b.HasKey("ChannelId");
b.ToTable("Autobranches", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<long>("Date")
.HasColumnType("bigint");
b.Property<decimal>("Employee")
.HasColumnType("numeric(20,0)");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RpName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Support")
.HasColumnType("integer");
b.Property<long>("birthDate")
.HasColumnType("bigint");
b.HasKey("Id");
b.ToTable("Passport", "public");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -7,6 +7,7 @@ using DiscordApp.Auth;
using DiscordApp.Database;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using spworlds;
using System;
@@ -51,7 +52,7 @@ namespace DiscordApp
.AddSingleton(x => new InteractionService(x.GetRequiredService<DiscordSocketClient>()))
.AddSingleton<JusticeHandler>()
.AddSingleton(sp)
.AddDbContext<AppDbContext>(c => c.UseNpgsql(@"Host=185.104.112.180;Username=yaflay;Password=hQgtruasSS;Database=spw_store"))
.AddDbContext<AppDbContext>(c => c.UseNpgsql(@"Host=185.104.112.180;Username=yaflay;Password=hQgtruasSS;Database=poopland"))
.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = "Bearer";