From 9950801644aa2614f4795632e4a333248fb65587 Mon Sep 17 00:00:00 2001 From: Sean Stoves Date: Sun, 9 Aug 2020 10:19:29 -0400 Subject: [PATCH] Setting default level to 1 --- ChaosBot/Discord/Services/ExperienceHandler.cs | 15 +++++++++++++-- .../Migrations/20200804213001_ExperiencePoints.cs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChaosBot/Discord/Services/ExperienceHandler.cs b/ChaosBot/Discord/Services/ExperienceHandler.cs index efb65eb..e879653 100644 --- a/ChaosBot/Discord/Services/ExperienceHandler.cs +++ b/ChaosBot/Discord/Services/ExperienceHandler.cs @@ -58,10 +58,21 @@ namespace ChaosBot.Discord.Services usrNewXp.DiscordGuildId = context.Guild.Id; usrNewXp.DiscordUserId = context.User.Id; usrNewXp.LastUpdated = DateTime.Now; - usrNewXp.Level = 0; + usrNewXp.Level = 1; await dbContext.ExperiencePoints.Upsert(usrNewXp) .On(x => new { x.DiscordGuildId, x.DiscordUserId}).RunAsync(); + + string ConfigSet = ConfigurationRepository.GetValue("LevelUp:Channel", context.Guild.Id, "false"); + + if (ConfigSet != "false") + { + ulong channelId = Convert.ToUInt64(ConfigSet.Substring(2, ConfigSet.Length - 3)); + await context.Guild.GetTextChannel(channelId).SendMessageAsync( + $"Grats <@{context.User.Id}>! You have reached level 1 :wot:"); + } + else + await context.Channel.SendMessageAsync($"Grats <@{context.User.Id}>! You have reached level 1 :wot:"); } } } @@ -74,7 +85,7 @@ namespace ChaosBot.Discord.Services public static async Task checkLevel(Experience usrExperience, SocketCommandContext context) { - ulong curLevel = 0; + ulong curLevel = 1; try { diff --git a/ChaosBot/Migrations/20200804213001_ExperiencePoints.cs b/ChaosBot/Migrations/20200804213001_ExperiencePoints.cs index 1ef77de..5ae0270 100644 --- a/ChaosBot/Migrations/20200804213001_ExperiencePoints.cs +++ b/ChaosBot/Migrations/20200804213001_ExperiencePoints.cs @@ -17,7 +17,7 @@ namespace ChaosBot.Migrations DiscordGuildId = table.Column(nullable: false), DiscordUserId = table.Column(nullable: false), Amount = table.Column(nullable: false, defaultValue: 0), - Level = table.Column(nullable: false, defaultValue: 0), + Level = table.Column(nullable: false, defaultValue: 1), lastUpdated = table.Column(nullable:false, defaultValue: "0000-00-00 00:00:00") }, constraints: table =>