From 44dcc7feb4f7d944d25984f833b594328e75f623 Mon Sep 17 00:00:00 2001 From: Melissa Date: Sun, 10 Feb 2019 15:03:17 +0000 Subject: [PATCH 1/4] Added AwardingEXPMentionUser to the Configuration to enable or disable mentions in the 'User Levelled Up' embed --- DiscordBot/Common/Configuration.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DiscordBot/Common/Configuration.cs b/DiscordBot/Common/Configuration.cs index 51e9038..a034c7c 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; From 8512950166c720a4420bcb304979d603c1167980 Mon Sep 17 00:00:00 2001 From: Melissa Date: Sun, 10 Feb 2019 15:04:27 +0000 Subject: [PATCH 2/4] Added AwardingEXPMentionUser to UpdateConfiguration --- DiscordBot/Common/Configuration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DiscordBot/Common/Configuration.cs b/DiscordBot/Common/Configuration.cs index a034c7c..a25508c 100644 --- a/DiscordBot/Common/Configuration.cs +++ b/DiscordBot/Common/Configuration.cs @@ -119,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) @@ -145,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, From d43740bf460b8d0b09f16ae400c49723d21081c0 Mon Sep 17 00:00:00 2001 From: Melissa Date: Sun, 10 Feb 2019 15:23:05 +0000 Subject: [PATCH 3/4] Added a check to see if the user gets mentioned when they have leveled up --- DiscordBot/Extensions/UserExtensions.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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? From bce0ba1e9c717e5368b421e772cbff48cf158c4f Mon Sep 17 00:00:00 2001 From: Melissa Date: Sun, 10 Feb 2019 17:21:27 +0000 Subject: [PATCH 4/4] Added a command to toggle AwardingEXPMentionUser --- DiscordBot/Modules/Owner/ConfigModule.cs | 8 ++++++++ 1 file changed, 8 insertions(+) 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")]