From dddef2d25d4180f8f7a0e1e122f6cb5ff8f58988 Mon Sep 17 00:00:00 2001 From: easly1989 Date: Wed, 13 Nov 2019 13:17:33 +0100 Subject: [PATCH] Added @username to the message sent from Discord --- DFAssist/Helpers/DiscordHelper.cs | 12 +++++++----- SharedAssemblyInfo.cs | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DFAssist/Helpers/DiscordHelper.cs b/DFAssist/Helpers/DiscordHelper.cs index 1bbc247..a637c01 100644 --- a/DFAssist/Helpers/DiscordHelper.cs +++ b/DFAssist/Helpers/DiscordHelper.cs @@ -13,13 +13,15 @@ protected override void OnSendNotification(string title, string message, string return; } - if(string.IsNullOrWhiteSpace(MainControl.DiscordUsernameTextBox.Text)) + var username = MainControl.DiscordUsernameTextBox.Text; + if(string.IsNullOrWhiteSpace(username)) { Logger.Write("UI: Specify a Username for the Discord settings", LogLevel.Warn); return; } - if(string.IsNullOrWhiteSpace(MainControl.DiscordWebhookTextBox.Text)) + var webhookUrl = MainControl.DiscordWebhookTextBox.Text; + if(string.IsNullOrWhiteSpace(webhookUrl)) { Logger.Write("UI: Specify a valid Webhook URL for the Discord settings", LogLevel.Warn); return; @@ -27,14 +29,14 @@ protected override void OnSendNotification(string title, string message, string Logger.Write("UI: Sending Discord Notification...", LogLevel.Debug); - var content = $"{title}\n>>>>> {message}"; + var content = $"@{username} | {title}\n>>>>> {message}"; if(!string.IsNullOrWhiteSpace(testing)) content += $" [{testing}]"; - var webhook = new Webhook(MainControl.DiscordWebhookTextBox.Text); + var webhook = new Webhook(webhookUrl); var webHookObj = new WebhookObject { - username = MainControl.DiscordUsernameTextBox.Text, + username = username, content = content }; diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs index 8f05611..0406861 100644 --- a/SharedAssemblyInfo.cs +++ b/SharedAssemblyInfo.cs @@ -35,12 +35,12 @@ // to distinguish one build from another. AssemblyFileVersion is specified // in AssemblyVersionInfo.cs so that it can be easily incremented by the // automated build process. -[assembly: AssemblyVersion("2.2.3")] +[assembly: AssemblyVersion("2.2.4")] // By default, the "Product version" shown in the file properties window is // the same as the value specified for AssemblyFileVersionAttribute. // Set AssemblyInformationalVersionAttribute to be the same as // AssemblyVersionAttribute so that the "Product version" in the file // properties window matches the version displayed in the GAC shell extension. -[assembly: AssemblyInformationalVersion("2.2.3")] // a.k.a. "Product version" +[assembly: AssemblyInformationalVersion("2.2.4")] // a.k.a. "Product version"