diff --git a/DiscordBot/Common/Configuration.cs b/DiscordBot/Common/Configuration.cs index 51e9038..a25508c 100644 --- a/DiscordBot/Common/Configuration.cs +++ b/DiscordBot/Common/Configuration.cs @@ -35,6 +35,7 @@ public class Configuration public bool UnknownCommandEnabled { get; set; } = true; public bool AwardingEXPEnabled { get; set; } = true; + public bool AwardingEXPMentionUser { get; set; } = true; public int LeaderboardAmount { get; set; } = 5; public int QuoteLevelRequirement { get; set; } = 10; @@ -118,7 +119,7 @@ public string ToJson() public static void UpdateConfiguration(string botToken = null, ulong? developer = null, string statusText = null, string statusLink = null, string databaseHost = null, int? databasePort = null, string databaseUser = null, string databasePassword = null, string databaseName = null, bool? showAllAwards = null, string awardsIconUrl = null, - int? statusActivity = null, UserStatus? status = null, bool? unknownCommandEnabled = null, bool? awardingEXPEnabled = null, + int? statusActivity = null, UserStatus? status = null, bool? unknownCommandEnabled = null, bool? awardingEXPEnabled = null, bool? awardingEXPMentionUser = null, int? leaderboardAmount = null, string leaderboardTrophyUrl = null, uint? leaderboardEmbedColor = null, int? quoteLevelRequirement = null, int? prefixLevelRequirement = null, int? senpaiChanceRate = null, int? rgbLevelRequirement = null, ulong? logChannelId = null, int? respects = null, int? minLengthForEXP = null, int? maxRuleXGamble = null) @@ -144,6 +145,7 @@ public static void UpdateConfiguration(string botToken = null, ulong? developer UnknownCommandEnabled = unknownCommandEnabled ?? Load().UnknownCommandEnabled, AwardingEXPEnabled = awardingEXPEnabled ?? Load().AwardingEXPEnabled, + AwardingEXPMentionUser = awardingEXPMentionUser ?? Load().AwardingEXPMentionUser, LeaderboardAmount = leaderboardAmount ?? Load().LeaderboardAmount, LeaderboardTrophyUrl = leaderboardTrophyUrl ?? Load().LeaderboardTrophyUrl, diff --git a/DiscordBot/Extensions/UserExtensions.cs b/DiscordBot/Extensions/UserExtensions.cs index a7e7b3b..031cb53 100644 --- a/DiscordBot/Extensions/UserExtensions.cs +++ b/DiscordBot/Extensions/UserExtensions.cs @@ -126,9 +126,23 @@ public static async void AttemptLevelUp(this IUser user, SocketGuild guild) EmbedBuilder eb = new EmbedBuilder() { Title = "Level Up!", - Color = user.GetCustomRGB(), - Description = "Well done " + user.Mention + "! You levelled up to level " + user.GetLevel() + "! Gain " + (Math.Round(EXPToLevelUp(user)) - user.GetEXP()) + " more EXP to level up again!", + Color = user.GetCustomRGB() }.WithCurrentTimestamp(); + + if (Configuration.Load().AwardingEXPMentionUser) + { + eb.WithDescription("Well done " + user.Mention + "! You levelled up to level " + + user.GetLevel() + "! Gain " + + (Math.Round(EXPToLevelUp(user)) - user.GetEXP()) + + " more EXP to level up again!"); + } + else + { + eb.WithDescription("Well done " + user.Username + "! You levelled up to level " + + user.GetLevel() + "! Gain " + + (Math.Round(EXPToLevelUp(user)) - user.GetEXP()) + + " more EXP to level up again!"); + } var msg = await botChannel.SendMessageAsync("", false, eb.Build()); //msg.DeleteAfter(300); // todo: updated from 120 to don't delete, maybe make configurable? diff --git a/DiscordBot/Modules/Owner/ConfigModule.cs b/DiscordBot/Modules/Owner/ConfigModule.cs index a0e244c..b897bd6 100644 --- a/DiscordBot/Modules/Owner/ConfigModule.cs +++ b/DiscordBot/Modules/Owner/ConfigModule.cs @@ -43,6 +43,7 @@ await ReplyAsync("**Syntax:** " + "[14] toggleexpawarding\n" + "[15] toggleshowallawards\n" + "[16] awardsiconurl [link]\n" + + "[17] toggleawardingexpmention\n" + "```"); } @@ -224,6 +225,13 @@ public async Task SetAwardsIconUrl(string link) Configuration.UpdateConfiguration(awardsIconUrl: link); await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync(Context.User.Mention + " has updated the Awards Icon URL to: " + link + " (was: " + oldValue + ")"); } + + [Command("toggleawardingexpmention"), Summary("Toggles if users get mentioned when they level up.")] + public async Task ToggleAwardingEXPMention() + { + Configuration.UpdateConfiguration(awardingEXPMentionUser: !Configuration.Load().AwardingEXPMentionUser); + await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("AwardingEXPMentionUser has been toggled by " + Context.User.Mention + " (enabled: " + Configuration.Load().AwardingEXPMentionUser.ToYesNo() + ")"); + } } [Group("editdatabase")]