diff --git a/src/ARKServerManager/App.config b/src/ARKServerManager/App.config
index 6c98692e..10b747b7 100644
--- a/src/ARKServerManager/App.config
+++ b/src/ARKServerManager/App.config
@@ -814,7 +814,7 @@
False
- asm
+ asm!
@@ -851,14 +851,15 @@
-
-
-
+
False
+
+ Info
+
diff --git a/src/ARKServerManager/App.xaml.cs b/src/ARKServerManager/App.xaml.cs
index 85ffeb30..d4ae0ef4 100644
--- a/src/ARKServerManager/App.xaml.cs
+++ b/src/ARKServerManager/App.xaml.cs
@@ -287,7 +287,8 @@ namespace ServerManagerTool
}
if (!Config.Default.DiscordBotPrefixFixed)
{
- Config.Default.DiscordBotPrefix += "!";
+ if (!Config.Default.DiscordBotPrefix.EndsWith("!"))
+ Config.Default.DiscordBotPrefix += "!";
Config.Default.DiscordBotPrefixFixed = true;
Config.Default.Save();
Config.Default.Reload();
@@ -507,7 +508,7 @@ namespace ServerManagerTool
discordWhiteList.AddRange(Config.Default.DiscordBotWhitelist.Cast());
}
- await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotToken, Config.Default.DiscordBotPrefix, Config.Default.DataDir, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
+ await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotLogLevel, Config.Default.DiscordBotToken, Config.Default.DiscordBotPrefix, Config.Default.DataDir, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
}, _tokenSource.Token)
.ContinueWith(t => {
var message = t.Exception.InnerException is null ? t.Exception.Message : t.Exception.InnerException.Message;
diff --git a/src/ARKServerManager/Config.Designer.cs b/src/ARKServerManager/Config.Designer.cs
index dedd1a15..39bbded1 100644
--- a/src/ARKServerManager/Config.Designer.cs
+++ b/src/ARKServerManager/Config.Designer.cs
@@ -2827,7 +2827,7 @@ namespace ServerManagerTool {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("asm")]
+ [global::System.Configuration.DefaultSettingValueAttribute("asm!")]
public string DiscordBotPrefix {
get {
return ((string)(this["DiscordBotPrefix"]));
@@ -2990,8 +2990,7 @@ namespace ServerManagerTool {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n \r\n")]
+ "org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />")]
public global::System.Collections.Specialized.StringCollection DiscordBotWhitelist {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["DiscordBotWhitelist"]));
@@ -3012,5 +3011,17 @@ namespace ServerManagerTool {
this["DiscordBotPrefixFixed"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Info")]
+ public global::ServerManagerTool.DiscordBot.Enums.LogLevel DiscordBotLogLevel {
+ get {
+ return ((global::ServerManagerTool.DiscordBot.Enums.LogLevel)(this["DiscordBotLogLevel"]));
+ }
+ set {
+ this["DiscordBotLogLevel"] = value;
+ }
+ }
}
}
diff --git a/src/ARKServerManager/Config.settings b/src/ARKServerManager/Config.settings
index 4767021d..00b1e243 100644
--- a/src/ARKServerManager/Config.settings
+++ b/src/ARKServerManager/Config.settings
@@ -783,7 +783,7 @@
False
- asm
+ asm!
@@ -826,12 +826,13 @@
<?xml version="1.0" encoding="utf-16"?>
-<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <string />
-</ArrayOfString>
+<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
False
+
+ Info
+
\ No newline at end of file
diff --git a/src/ARKServerManager/Globalization/en-US/en-US.xaml b/src/ARKServerManager/Globalization/en-US/en-US.xaml
index 97418250..e8073fed 100644
--- a/src/ARKServerManager/Globalization/en-US/en-US.xaml
+++ b/src/ARKServerManager/Globalization/en-US/en-US.xaml
@@ -83,12 +83,21 @@
All
-
+
Normal
Minimized
Maximized
+
+ Critical
+ Error
+ Warning
+ Info
+ Verbose
+ Debug
+
+
Run as Administrator
This application requires administration priviledges to access ALL functionality. Would you like to Run as Administrator?
@@ -622,6 +631,7 @@
The id of the discord server the bot will listen to.
Prefix:
The prefix that must be used when sending a command via discord.
+ Log Level:
Get Token...
Help...
Bot Whitelist
diff --git a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml
index f0825055..bee4de9a 100644
--- a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml
+++ b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml
@@ -618,6 +618,8 @@
+
+
diff --git a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml.cs b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml.cs
index a7029e0f..3a2f2986 100644
--- a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml.cs
+++ b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml.cs
@@ -33,6 +33,7 @@ namespace ServerManagerTool
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty CommonConfigProperty = DependencyProperty.Register(nameof(CommonConfig), typeof(CommonConfig), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
+ public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public GlobalSettingsControl()
@@ -43,7 +44,11 @@ namespace ServerManagerTool
this.CommonConfig = CommonConfig.Default;
this.DataContext = this;
+ InitializeComponent();
+ WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
+
PopulateWindowsStatesComboBox();
+ PopulateDiscordBotLogLevelsComboBox();
DiscordBotWhitelist = new List();
if (Config.DiscordBotWhitelist != null)
@@ -54,9 +59,6 @@ namespace ServerManagerTool
}
}
- InitializeComponent();
- WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
-
this.IsAdministrator = SecurityUtils.IsAdministrator();
}
@@ -90,6 +92,12 @@ namespace ServerManagerTool
set { SetValue(WindowStatesProperty, value); }
}
+ public ComboBoxItemList DiscordBotLogLevels
+ {
+ get { return (ComboBoxItemList)GetValue(DiscordBotLogLevelsProperty); }
+ set { SetValue(DiscordBotLogLevelsProperty, value); }
+ }
+
public List DiscordBotWhitelist
{
get { return (List)GetValue(DiscordBotWhitelistProperty); }
@@ -476,21 +484,39 @@ namespace ServerManagerTool
private void PopulateWindowsStatesComboBox()
{
var selectedValue = this.WindowStateComboBox?.SelectedValue ?? Config.MainWindow_WindowState;
- var windowStates = new ComboBoxItemList();
+ var comboBoxList = new ComboBoxItemList();
foreach (WindowState windowState in Enum.GetValues(typeof(WindowState)))
{
var displayMember = _globalizer.GetResourceString($"WindowState_{windowState}") ?? windowState.ToString();
- windowStates.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
+ comboBoxList.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
- this.WindowStates = windowStates;
+ this.WindowStates = comboBoxList;
if (this.WindowStateComboBox != null)
{
this.WindowStateComboBox.SelectedValue = selectedValue;
}
}
+ private void PopulateDiscordBotLogLevelsComboBox()
+ {
+ var selectedValue = this.DiscordBotLogLevelComboBox?.SelectedValue ?? Config.DiscordBotLogLevel;
+ var comboBoxList = new ComboBoxItemList();
+
+ foreach (DiscordBot.Enums.LogLevel logLevel in Enum.GetValues(typeof(DiscordBot.Enums.LogLevel)))
+ {
+ var displayMember = _globalizer.GetResourceString($"DiscordBotLogLevel_{logLevel}") ?? logLevel.ToString();
+ comboBoxList.Add(new Common.Model.ComboBoxItem(logLevel.ToString(), displayMember));
+ }
+
+ this.DiscordBotLogLevels = comboBoxList;
+ if (this.DiscordBotLogLevelComboBox != null)
+ {
+ this.DiscordBotLogLevelComboBox.SelectedValue = selectedValue;
+ }
+ }
+
#region Discord Bot Whitelist
private void AddDiscordBotWhitelist_Click(object sender, RoutedEventArgs e)
{
diff --git a/src/ARKServerManager/VersionFeed.xml b/src/ARKServerManager/VersionFeed.xml
index 91a900da..e6600717 100644
--- a/src/ARKServerManager/VersionFeed.xml
+++ b/src/ARKServerManager/VersionFeed.xml
@@ -9,8 +9,8 @@
urn:uuid:3E33DCB2-ECFE-4489-B1A4-56F5D386F9DC
- 1.1.413 (1.1.413.4)
- 1.1.413.4
+ 1.1.413 (1.1.413.5)
+ 1.1.413.5
2021-12-16T00:00:00Z
@@ -19,6 +19,7 @@
NEW
+ - Global Settings - Discord Bot section - Added a log level droplist.
- Global Settings - Discord Bot section - Added a whitelist to allow bots to send commands to the server manager.
- Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.
diff --git a/src/ARKServerManager/VersionFeedBeta.xml b/src/ARKServerManager/VersionFeedBeta.xml
index d5256d65..ed1f4778 100644
--- a/src/ARKServerManager/VersionFeedBeta.xml
+++ b/src/ARKServerManager/VersionFeedBeta.xml
@@ -7,6 +7,29 @@
2021-12-16T00:00:00Z
+
+ urn:uuid:65A7E6B1-98D1-422D-B42F-B0EBB1D20E41
+ 1.1.413 (1.1.413.5)
+ 1.1.413.5
+
+ 2021-12-16T00:00:00Z
+
+
+
+ NEW
+
+
+ - Global Settings - Discord Bot section - Added a log level droplist.
+
+
+
+
+
+ bletch
+ bletch1971@hotmail.com
+
+
+
urn:uuid:98FFBFA1-4E99-4801-BF2B-CA68BE300C27
1.1.413 (1.1.413.4)
diff --git a/src/ConanServerManager/App.config b/src/ConanServerManager/App.config
index 27004551..e5424f03 100644
--- a/src/ConanServerManager/App.config
+++ b/src/ConanServerManager/App.config
@@ -580,7 +580,7 @@
False
- csm
+ csm!
@@ -617,14 +617,15 @@
-
-
-
+
False
+
+ Info
+
\ No newline at end of file
diff --git a/src/ConanServerManager/App.xaml.cs b/src/ConanServerManager/App.xaml.cs
index 1b75acb4..761109f7 100644
--- a/src/ConanServerManager/App.xaml.cs
+++ b/src/ConanServerManager/App.xaml.cs
@@ -280,7 +280,8 @@ namespace ServerManagerTool
}
if (!Config.Default.DiscordBotPrefixFixed)
{
- Config.Default.DiscordBotPrefix += "!";
+ if (!Config.Default.DiscordBotPrefix.EndsWith("!"))
+ Config.Default.DiscordBotPrefix += "!";
Config.Default.DiscordBotPrefixFixed = true;
Config.Default.Save();
Config.Default.Reload();
@@ -488,7 +489,7 @@ namespace ServerManagerTool
discordWhiteList.AddRange(Config.Default.DiscordBotWhitelist.Cast());
}
- await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotToken,Config.Default.DiscordBotPrefix, Config.Default.DataPath, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
+ await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotLogLevel, Config.Default.DiscordBotToken,Config.Default.DiscordBotPrefix, Config.Default.DataPath, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
}, _tokenSource.Token)
.ContinueWith(t => {
var message = t.Exception.InnerException is null ? t.Exception.Message : t.Exception.InnerException.Message;
diff --git a/src/ConanServerManager/Config.Designer.cs b/src/ConanServerManager/Config.Designer.cs
index 18c31f8d..e40502ea 100644
--- a/src/ConanServerManager/Config.Designer.cs
+++ b/src/ConanServerManager/Config.Designer.cs
@@ -1980,7 +1980,7 @@ namespace ServerManagerTool {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("csm")]
+ [global::System.Configuration.DefaultSettingValueAttribute("csm!")]
public string DiscordBotPrefix {
get {
return ((string)(this["DiscordBotPrefix"]));
@@ -2143,8 +2143,7 @@ namespace ServerManagerTool {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n \r\n")]
+ "org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />")]
public global::System.Collections.Specialized.StringCollection DiscordBotWhitelist {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["DiscordBotWhitelist"]));
@@ -2165,5 +2164,17 @@ namespace ServerManagerTool {
this["DiscordBotPrefixFixed"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Info")]
+ public global::ServerManagerTool.DiscordBot.Enums.LogLevel DiscordBotLogLevel {
+ get {
+ return ((global::ServerManagerTool.DiscordBot.Enums.LogLevel)(this["DiscordBotLogLevel"]));
+ }
+ set {
+ this["DiscordBotLogLevel"] = value;
+ }
+ }
}
}
diff --git a/src/ConanServerManager/Config.settings b/src/ConanServerManager/Config.settings
index 7e075b16..bc3afb46 100644
--- a/src/ConanServerManager/Config.settings
+++ b/src/ConanServerManager/Config.settings
@@ -549,7 +549,7 @@
False
- csm
+ csm!
@@ -592,12 +592,13 @@
<?xml version="1.0" encoding="utf-16"?>
-<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <string />
-</ArrayOfString>
+<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
False
+
+ Info
+
\ No newline at end of file
diff --git a/src/ConanServerManager/Globalization/en-US/en-US.xaml b/src/ConanServerManager/Globalization/en-US/en-US.xaml
index 486b8e37..a293c4b8 100644
--- a/src/ConanServerManager/Globalization/en-US/en-US.xaml
+++ b/src/ConanServerManager/Globalization/en-US/en-US.xaml
@@ -57,12 +57,21 @@
All
-
+
Normal
Minimized
Maximized
+
+ Critical
+ Error
+ Warning
+ Info
+ Verbose
+ Debug
+
+
x
%
@@ -780,6 +789,7 @@
The id of the discord server the bot will listen to.
Prefix:
The prefix that must be used when sending a command via discord.
+ Log Level:
Get Token...
Help...
Bot Whitelist
diff --git a/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml b/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml
index e85293d1..c2676d59 100644
--- a/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml
+++ b/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml
@@ -566,6 +566,8 @@
+
+
diff --git a/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml.cs b/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml.cs
index 8d2d1cd4..a89cbfb1 100644
--- a/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml.cs
+++ b/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml.cs
@@ -32,6 +32,7 @@ namespace ServerManagerTool
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty IsAdministratorProperty = DependencyProperty.Register(nameof(IsAdministrator), typeof(bool), typeof(GlobalSettingsControl), new PropertyMetadata(false));
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
+ public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public GlobalSettingsControl()
@@ -42,7 +43,11 @@ namespace ServerManagerTool
this.IsAdministrator = SecurityUtils.IsAdministrator();
this.Version = GetDeployedVersion();
+ InitializeComponent();
+ WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
+
PopulateWindowsStatesComboBox();
+ PopulateDiscordBotLogLevelsComboBox();
DiscordBotWhitelist = new List();
if (Config.DiscordBotWhitelist != null)
@@ -53,9 +58,6 @@ namespace ServerManagerTool
}
}
- InitializeComponent();
- WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
-
this.DataContext = this;
}
@@ -95,6 +97,12 @@ namespace ServerManagerTool
set;
}
+ public ComboBoxItemList DiscordBotLogLevels
+ {
+ get { return (ComboBoxItemList)GetValue(DiscordBotLogLevelsProperty); }
+ set { SetValue(DiscordBotLogLevelsProperty, value); }
+ }
+
public List DiscordBotWhitelist
{
get { return (List)GetValue(DiscordBotWhitelistProperty); }
@@ -500,6 +508,24 @@ namespace ServerManagerTool
}
}
+ private void PopulateDiscordBotLogLevelsComboBox()
+ {
+ var selectedValue = this.DiscordBotLogLevelComboBox?.SelectedValue ?? Config.DiscordBotLogLevel;
+ var comboBoxList = new ComboBoxItemList();
+
+ foreach (DiscordBot.Enums.LogLevel logLevel in Enum.GetValues(typeof(DiscordBot.Enums.LogLevel)))
+ {
+ var displayMember = _globalizer.GetResourceString($"DiscordBotLogLevel_{logLevel}") ?? logLevel.ToString();
+ comboBoxList.Add(new Common.Model.ComboBoxItem(logLevel.ToString(), displayMember));
+ }
+
+ this.DiscordBotLogLevels = comboBoxList;
+ if (this.DiscordBotLogLevelComboBox != null)
+ {
+ this.DiscordBotLogLevelComboBox.SelectedValue = selectedValue;
+ }
+ }
+
#region Discord Bot Whitelist
private void AddDiscordBotWhitelist_Click(object sender, RoutedEventArgs e)
{
diff --git a/src/ConanServerManager/VersionFeed.xml b/src/ConanServerManager/VersionFeed.xml
index 8329b387..5da92cb6 100644
--- a/src/ConanServerManager/VersionFeed.xml
+++ b/src/ConanServerManager/VersionFeed.xml
@@ -9,8 +9,8 @@
urn:uuid:19B09A66-43F2-4D5F-AF33-5C77D7EA9A6B
- 1.1.58 (1.1.58.4)
- 1.1.58.4
+ 1.1.58 (1.1.58.5)
+ 1.1.58.5
2021-12-16T00:00:00Z
@@ -19,6 +19,7 @@
NEW
+ - Global Settings - Discord Bot section - Added a log level droplist.
- Global Settings - Discord Bot section - Added a whitelist to allow bots to send commands to the server manager.
- Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.
diff --git a/src/ConanServerManager/VersionFeedBeta.xml b/src/ConanServerManager/VersionFeedBeta.xml
index e95fc7f0..de5884cb 100644
--- a/src/ConanServerManager/VersionFeedBeta.xml
+++ b/src/ConanServerManager/VersionFeedBeta.xml
@@ -7,6 +7,29 @@
2021-12-16T00:00:00Z
+
+ urn:uuid:A189668E-DA03-471A-9C5A-7FF2A7264F9C
+ 1.1.58 (1.1.58.5)
+ 1.1.58.5
+
+ 2021-12-16T00:00:00Z
+
+
+
+ NEW
+
+
+ - Global Settings - Discord Bot section - Added a log level droplist.
+
+
+
+
+
+ bletch
+ bletch1971@hotmail.com
+
+
+
urn:uuid:F3C22842-A089-46F7-AB1A-5D3DED105412
1.1.58 (1.1.58.4)
diff --git a/src/ServerManager.Discord/Enums/LogLevel.cs b/src/ServerManager.Discord/Enums/LogLevel.cs
new file mode 100644
index 00000000..8c18aeae
--- /dev/null
+++ b/src/ServerManager.Discord/Enums/LogLevel.cs
@@ -0,0 +1,25 @@
+using Discord;
+using System;
+
+namespace ServerManagerTool.DiscordBot.Enums
+{
+ public enum LogLevel
+ {
+ Critical = 0,
+ Error = 1,
+ Warning = 2,
+ Info = 3,
+ Verbose = 4,
+ Debug = 5
+ }
+
+ public class LogLevelHelper
+ {
+ public static LogSeverity GetLogSeverity(LogLevel logLevel)
+ {
+ if (Enum.TryParse(logLevel.ToString(), out LogSeverity logSeverity))
+ return logSeverity;
+ return LogSeverity.Info;
+ }
+ }
+}
diff --git a/src/ServerManager.Discord/Interfaces/IServerManagerBot.cs b/src/ServerManager.Discord/Interfaces/IServerManagerBot.cs
index 5206f7ed..7dc916c3 100644
--- a/src/ServerManager.Discord/Interfaces/IServerManagerBot.cs
+++ b/src/ServerManager.Discord/Interfaces/IServerManagerBot.cs
@@ -1,4 +1,5 @@
using ServerManagerTool.DiscordBot.Delegates;
+using ServerManagerTool.DiscordBot.Enums;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -9,6 +10,6 @@ namespace ServerManagerTool.DiscordBot.Interfaces
{
CancellationToken Token { get; }
- Task StartAsync(string discordToken, string commandPrefix, string dataDirectory, IEnumerable botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token);
+ Task StartAsync(LogLevel logLevel, string discordToken, string commandPrefix, string dataDirectory, IEnumerable botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token);
}
}
diff --git a/src/ServerManager.Discord/ServerManagerBot.cs b/src/ServerManager.Discord/ServerManagerBot.cs
index 0b7b1aab..e9950711 100644
--- a/src/ServerManager.Discord/ServerManagerBot.cs
+++ b/src/ServerManager.Discord/ServerManagerBot.cs
@@ -6,6 +6,7 @@ using Discord.WebSocket;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ServerManagerTool.DiscordBot.Delegates;
+using ServerManagerTool.DiscordBot.Enums;
using ServerManagerTool.DiscordBot.Interfaces;
using ServerManagerTool.DiscordBot.Models;
using ServerManagerTool.DiscordBot.Services;
@@ -28,7 +29,7 @@ namespace ServerManagerTool.DiscordBot
public CancellationToken Token { get; private set; }
public bool Started { get; private set; }
- public async Task StartAsync(string discordToken, string commandPrefix, string dataDirectory, IEnumerable botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token)
+ public async Task StartAsync(LogLevel logLevel, string discordToken, string commandPrefix, string dataDirectory, IEnumerable botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token)
{
if (Started)
{
@@ -43,11 +44,6 @@ namespace ServerManagerTool.DiscordBot
Token = token;
- //if (commandPrefix.Any(c => !char.IsLetterOrDigit(c)))
- //{
- // throw new Exception("#DiscordBot_InvalidPrefixError");
- //}
-
var settings = new Dictionary
{
{ "DiscordSettings:Token", discordToken },
@@ -62,12 +58,7 @@ namespace ServerManagerTool.DiscordBot
var socketConfig = new DiscordSocketConfig
{
- //#if DEBUG
- LogLevel = LogSeverity.Verbose,
- //#else
- // LogLevel = LogSeverity.Info,
- //#endif
- // Tell Discord.Net to cache 1000 messages per channel
+ LogLevel = LogLevelHelper.GetLogSeverity(logLevel),
MessageCacheSize = 1000,
};
if (Environment.OSVersion.Version < new Version(6, 2))
@@ -80,11 +71,7 @@ namespace ServerManagerTool.DiscordBot
{
// Force all commands to run async
DefaultRunMode = RunMode.Async,
- //#if DEBUG
- LogLevel = LogSeverity.Verbose,
- //#else
- // LogLevel = LogSeverity.Info,
- //#endif
+ LogLevel = LogLevelHelper.GetLogSeverity(logLevel),
};
var discordBotWhitelistConfig = new DiscordBotWhitelistConfig