diff --git a/Database/AppDbContext.cs b/Database/AppDbContext.cs index 8cdfa2d..9d6b048 100644 --- a/Database/AppDbContext.cs +++ b/Database/AppDbContext.cs @@ -9,7 +9,6 @@ namespace DiscordApp.Database public DbSet Passport { get; set; } public DbSet Autobranches { get; set; } - public DbSet Autoreactions { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/Database/Tables/Autoreactions.cs b/Database/Tables/Autoreactions.cs deleted file mode 100644 index 2ff6818..0000000 --- a/Database/Tables/Autoreactions.cs +++ /dev/null @@ -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; } - - } -} \ No newline at end of file diff --git a/Database/Tables/Passport.cs b/Database/Tables/Passport.cs index c06666f..e119917 100644 --- a/Database/Tables/Passport.cs +++ b/Database/Tables/Passport.cs @@ -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; } diff --git a/DiscordApp.csproj b/DiscordApp.csproj index 192fca8..1a44963 100644 --- a/DiscordApp.csproj +++ b/DiscordApp.csproj @@ -7,6 +7,7 @@ 392a6656-544a-410a-9be8-214215cd1cc8 Linux . + True @@ -18,8 +19,12 @@ - + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/Justice/Commands/Settings.cs b/Justice/Commands/Settings.cs index b393899..88f63d7 100644 --- a/Justice/Commands/Settings.cs +++ b/Justice/Commands/Settings.cs @@ -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)] diff --git a/Justice/Events/Events.cs b/Justice/Events/Events.cs index 5cc9bd6..6f5394d 100644 --- a/Justice/Events/Events.cs +++ b/Justice/Events/Events.cs @@ -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); - } - } - **/ + + } } } diff --git a/Justice/Interactions/PassportInteraction.cs b/Justice/Interactions/PassportInteraction.cs index e322355..a7d7629 100644 --- a/Justice/Interactions/PassportInteraction.cs +++ b/Justice/Interactions/PassportInteraction.cs @@ -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("passportModal"); + [ComponentInteraction("reworkPassport")] + public async Task reCreatePassport() + => await Context.Interaction.RespondWithModalAsync("reworkpassportModal"); + [ComponentInteraction("reNewPassportButton")] + public async Task reNewPassportModal() => await Context.Interaction.RespondWithModalAsync("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} +Дата рождения: ") + .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($"").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} +Дата рождения: ").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($"").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} +Дата рождения: ") + .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($"").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; } + + } + } diff --git a/Migrations/20231026134430_InternalMigration.Designer.cs b/Migrations/20231026134430_InternalMigration.Designer.cs new file mode 100644 index 0000000..02656f5 --- /dev/null +++ b/Migrations/20231026134430_InternalMigration.Designer.cs @@ -0,0 +1,93 @@ +// +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 + { + /// + 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("ChannelId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)"); + + b.Property("BranchName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ChannelId"); + + b.ToTable("Autobranches", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Autoreactions", b => + { + b.Property("ChannelId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)"); + + b.Property("EmoteId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ChannelId"); + + b.ToTable("Autoreactions", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Applicant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("bigint"); + + b.Property("Employee") + .HasColumnType("numeric(20,0)"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("text"); + + b.Property("RpName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Support") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Passport", "public"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20231026134430_InternalMigration.cs b/Migrations/20231026134430_InternalMigration.cs new file mode 100644 index 0000000..3b8daee --- /dev/null +++ b/Migrations/20231026134430_InternalMigration.cs @@ -0,0 +1,79 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DiscordApp.Migrations +{ + /// + public partial class InternalMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "public"); + + migrationBuilder.CreateTable( + name: "Autobranches", + schema: "public", + columns: table => new + { + ChannelId = table.Column(type: "numeric(20,0)", nullable: false), + BranchName = table.Column(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(type: "numeric(20,0)", nullable: false), + EmoteId = table.Column(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(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Employee = table.Column(type: "numeric(20,0)", nullable: false), + Applicant = table.Column(type: "text", nullable: false), + Date = table.Column(type: "bigint", nullable: false), + Support = table.Column(type: "integer", nullable: false), + Gender = table.Column(type: "text", nullable: false), + RpName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Passport", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Autobranches", + schema: "public"); + + migrationBuilder.DropTable( + name: "Autoreactions", + schema: "public"); + + migrationBuilder.DropTable( + name: "Passport", + schema: "public"); + } + } +} diff --git a/Migrations/20231026161439_AddBitrhDate.Designer.cs b/Migrations/20231026161439_AddBitrhDate.Designer.cs new file mode 100644 index 0000000..d5dda86 --- /dev/null +++ b/Migrations/20231026161439_AddBitrhDate.Designer.cs @@ -0,0 +1,81 @@ +// +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 + { + /// + 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("ChannelId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)"); + + b.Property("BranchName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ChannelId"); + + b.ToTable("Autobranches", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Applicant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("bigint"); + + b.Property("Employee") + .HasColumnType("numeric(20,0)"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("text"); + + b.Property("RpName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Support") + .HasColumnType("integer"); + + b.Property("birthDate") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Passport", "public"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20231026161439_AddBitrhDate.cs b/Migrations/20231026161439_AddBitrhDate.cs new file mode 100644 index 0000000..bb2f83a --- /dev/null +++ b/Migrations/20231026161439_AddBitrhDate.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiscordApp.Migrations +{ + /// + public partial class AddBitrhDate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Autoreactions", + schema: "public"); + + migrationBuilder.AddColumn( + name: "birthDate", + schema: "public", + table: "Passport", + type: "bigint", + nullable: false, + defaultValue: 0L); + } + + /// + 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(type: "numeric(20,0)", nullable: false), + EmoteId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Autoreactions", x => x.ChannelId); + }); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..f29f0f0 --- /dev/null +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,78 @@ +// +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("ChannelId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)"); + + b.Property("BranchName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ChannelId"); + + b.ToTable("Autobranches", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Applicant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("bigint"); + + b.Property("Employee") + .HasColumnType("numeric(20,0)"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("text"); + + b.Property("RpName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Support") + .HasColumnType("integer"); + + b.Property("birthDate") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Passport", "public"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Startup.cs b/Startup.cs index 89d0d45..d059fa7 100644 --- a/Startup.cs +++ b/Startup.cs @@ -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())) .AddSingleton() .AddSingleton(sp) - .AddDbContext(c => c.UseNpgsql(@"Host=185.104.112.180;Username=yaflay;Password=hQgtruasSS;Database=spw_store")) + .AddDbContext(c => c.UseNpgsql(@"Host=185.104.112.180;Username=yaflay;Password=hQgtruasSS;Database=poopland")) .AddAuthentication(options => { options.DefaultAuthenticateScheme = "Bearer";