Server Manager Changes

1. Added Discord Bot section to Global Settings
2. Added Discord Bot section to Server Settings.
This commit is contained in:
Brett Hewitson 2021-12-04 14:36:34 +10:00
parent c5775181b3
commit a792b10253
20 changed files with 389 additions and 11 deletions

View file

@ -347,6 +347,12 @@
<setting name="DefaultDataDirectoryName" serializeAs="String">
<value>asmdata</value>
</setting>
<setting name="DiscordBotApplyUrl" serializeAs="String">
<value>https://discord.com/developers/applications</value>
</setting>
<setting name="DiscordBotHelpUrl" serializeAs="String">
<value>https://arkservermanager.freeforums.net/thread/8764/get-own-discord-bot</value>
</setting>
</ServerManagerTool.Config>
<ServerManagerTool.Common.CommonConfig>
<setting name="DefaultSteamAPIKey" serializeAs="String">
@ -813,6 +819,12 @@
<setting name="DiscordBotToken" serializeAs="String">
<value />
</setting>
<setting name="DiscordBotServerId" serializeAs="String">
<value />
</setting>
<setting name="SectionDiscordBotIsExpanded" serializeAs="String">
<value>False</value>
</setting>
</ServerManagerTool.Config>
</userSettings>
</configuration>

View file

@ -231,9 +231,9 @@ namespace ServerManagerTool
return LogManager.GetLogger(loggerName);
}
private static IList<string> HandleDiscordCommand(CommandType commandType, string channelId, string profileId)
private static IList<string> HandleDiscordCommand(CommandType commandType, string serverId, string channelId, string profileId)
{
return new List<string>() { $"{commandType}; {channelId}; {profileId ?? "no profile"}" };
return new List<string>() { $"{commandType}; {serverId}; {channelId}; {profileId ?? "no profile"}" };
}
private static void MigrateSettings()
@ -481,7 +481,7 @@ namespace ServerManagerTool
Task discordTask = Task.Run(async () =>
{
await ServerManagerBot.StartAsync(Config.Default.DiscordBotPrefix, Config.Default.DiscordBotToken, Config.Default.DataDir, HandleDiscordCommand, _tokenSource.Token);
await ServerManagerBot.StartAsync(Config.Default.DiscordBotToken, Config.Default.DiscordBotPrefix, Config.Default.DataDir, HandleDiscordCommand, _tokenSource.Token);
}, _tokenSource.Token)
.ContinueWith(t => {
var message = t.Exception.InnerException is null ? t.Exception.Message : t.Exception.InnerException.Message;

View file

@ -2848,5 +2848,47 @@ namespace ServerManagerTool {
this["DiscordBotToken"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string DiscordBotServerId {
get {
return ((string)(this["DiscordBotServerId"]));
}
set {
this["DiscordBotServerId"] = value;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://discord.com/developers/applications")]
public string DiscordBotApplyUrl {
get {
return ((string)(this["DiscordBotApplyUrl"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://arkservermanager.freeforums.net/thread/8764/get-own-discord-bot")]
public string DiscordBotHelpUrl {
get {
return ((string)(this["DiscordBotHelpUrl"]));
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool SectionDiscordBotIsExpanded {
get {
return ((bool)(this["SectionDiscordBotIsExpanded"]));
}
set {
this["SectionDiscordBotIsExpanded"] = value;
}
}
}
}

View file

@ -788,5 +788,17 @@
<Setting Name="DiscordBotToken" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="DiscordBotServerId" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="DiscordBotApplyUrl" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://discord.com/developers/applications</Value>
</Setting>
<Setting Name="DiscordBotHelpUrl" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://arkservermanager.freeforums.net/thread/8764/get-own-discord-bot</Value>
</Setting>
<Setting Name="SectionDiscordBotIsExpanded" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -610,7 +610,18 @@
<sys:String x:Key="GlobalSettings_ShutdownCancelTooltip">This message will be displayed when the server shutdown has been cancelled.</sys:String>
<sys:String x:Key="GlobalSettings_ShutdownAllMessagesShowReasonLabel">Show shutdown reason with ALL shutdown messages</sys:String>
<sys:String x:Key="GlobalSettings_ShutdownAllMessagesShowReasonTooltip">If enabled, the shutdown reason will be shown with all shutdown message; otherwise it will only be shown at the start of the server shutdown.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotLabel">Enable Discord Bot</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotInformationLabel">You will need to restart the server manager if you change any settings for the Discord Bot.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotTokenLabel">Token:</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotTokenTooltip">The token associated with the discord bot.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotServerLabel">Server Id:</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotServerTooltip">The id of the discord server the bot will listen to.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotPrefixLabel">Prefix:</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotPrefixTooltip">The prefix that must be used when sending a command via discord.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotApplyButtonLabel">Get Token...</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotHelpButtonLabel">Help...</sys:String>
<sys:String x:Key="GlobalSettings_EmailSettingsLabel">SMTP Email Settings</sys:String>
<sys:String x:Key="GlobalSettings_EmailHostLabel">Host:</sys:String>
<sys:String x:Key="GlobalSettings_EmailHostTooltip">The name or IP address of the host used for SMTP transmissions.</sys:String>
@ -1179,6 +1190,12 @@
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">If enabled, the server will be restarted even if shutdown for Auto-Restarts and Auto-Updates.</sys:String>
<!--#endregion-->
<!--#region Server Settings - Discord Bot Details -->
<sys:String x:Key="ServerSettings_DiscordBotLabel">Discord Bot Details</sys:String>
<sys:String x:Key="ServerSettings_DiscordBotChannelLabel">Channel Id:</sys:String>
<sys:String x:Key="ServerSettings_DiscordBotChannelTooltip">The id of the discord server channel the bot will listen to.</sys:String>
<!--#endregion-->
<!--#region Server Settings - Rules -->
<sys:String x:Key="ServerSettings_RulesLabel">Rules</sys:String>
<sys:String x:Key="ServerSettings_EnableHardcoreLabel">Enable Hardcore Mode</sys:String>

View file

@ -957,6 +957,16 @@ namespace ServerManagerTool.Lib
}
#endregion
#region Discord Bot
public static readonly DependencyProperty DiscordChannelIdProperty = DependencyProperty.Register(nameof(DiscordChannelId), typeof(string), typeof(ServerProfile), new PropertyMetadata(String.Empty));
[DataMember]
public string DiscordChannelId
{
get { return (string)GetValue(DiscordChannelIdProperty); }
set { SetValue(DiscordChannelIdProperty, value); }
}
#endregion
#region Rules
public static readonly DependencyProperty EnableHardcoreProperty = DependencyProperty.Register(nameof(EnableHardcore), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false));
[IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_ServerSettings, ServerProfileCategory.Rules, "ServerHardcore")]

View file

@ -713,5 +713,15 @@
<Label Content="{DynamicResource GlobalSettings_SetLocationButtonLabel}" VerticalAlignment="Center" Margin="0,-3,0,-3"/>
</StackPanel>
</ContentControl>
<ContentControl x:Key="DiscordBotApplyButtonContent">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource GlobalSettings_DiscordBotApplyButtonLabel}" VerticalAlignment="Center" Margin="0,-2,0,-2"/>
</StackPanel>
</ContentControl>
<ContentControl x:Key="DiscordBotHelpButtonContent">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource GlobalSettings_DiscordBotHelpButtonLabel}" VerticalAlignment="Center" Margin="0,-2,0,-2"/>
</StackPanel>
</ContentControl>
</Globalization:StyleResourceDictionary>

View file

@ -579,6 +579,43 @@
</GroupBox>
<GroupBox Grid.Row="19" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<CheckBox IsChecked="{Binding CurrentConfig.DiscordBotEnabled}" Content="{DynamicResource GlobalSettings_DiscordBotLabel}" VerticalAlignment="Center"/>
</GroupBox.Header>
<Grid IsEnabled="{Binding CurrentConfig.DiscordBotEnabled}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" Margin="5" Text="{DynamicResource GlobalSettings_DiscordBotInformationLabel}" TextWrapping="Wrap" VerticalAlignment="Center" FontWeight="Bold" Foreground="{DynamicResource WarningMessage}"/>
<Label Grid.Row="1" Grid.Column="0" Content="{DynamicResource GlobalSettings_DiscordBotTokenLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Margin="1" Name="HideDiscordBotTokenTextBox" Text="{DynamicResource ServerSettings_HidePasswordText}" ToolTip="{DynamicResource ServerSettings_HidePasswordTooltip}" GotFocus="HiddenField_GotFocus" Style="{StaticResource HiddenTextBoxStyle}"/>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Margin="1" Name="DiscordBotTokenTextBox" Text="{Binding CurrentConfig.DiscordBotToken}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotTokenTooltip}" LostFocus="HiddenField_LostFocus" Visibility="Collapsed"/>
<Button Grid.Row="1" Grid.Column="5" Margin="1" Content="{DynamicResource DiscordBotApplyButtonContent}" Click="DiscordBotApply_Click"/>
<Button Grid.Row="1" Grid.Column="6" Margin="1" Content="{DynamicResource DiscordBotHelpButtonContent}" Click="DiscordBotHelp_Click"/>
<Label Grid.Row="2" Grid.Column="0" Content="{DynamicResource GlobalSettings_DiscordBotServerLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding CurrentConfig.DiscordBotServerId}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotServerTooltip}"/>
<Label Grid.Row="2" Grid.Column="3" Content="{DynamicResource GlobalSettings_DiscordBotPrefixLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="4" Margin="1" Text="{Binding CurrentConfig.DiscordBotPrefix}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotPrefixTooltip}"/>
</Grid>
</GroupBox>
<GroupBox Grid.Row="20" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<Label Content="{DynamicResource GlobalSettings_EmailSettingsLabel}"/>
</GroupBox.Header>
@ -621,7 +658,7 @@
</Grid>
</GroupBox>
<GroupBox Grid.Row="20" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox Grid.Row="21" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<Label Content="{DynamicResource GlobalSettings_EmailNotifySettingsLabel}"/>
</GroupBox.Header>
@ -645,7 +682,7 @@
</Grid>
</GroupBox>
<GroupBox Grid.Row="21" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox Grid.Row="22" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<Label Content="{DynamicResource GlobalSettings_AdvancedSettingsLabel}"/>
</GroupBox.Header>

View file

@ -289,6 +289,16 @@ namespace ServerManagerTool
}
}
private void DiscordBotApply_Click(object sender, RoutedEventArgs e)
{
Process.Start(Config.Default.DiscordBotApplyUrl);
}
private void DiscordBotHelp_Click(object sender, RoutedEventArgs e)
{
Process.Start(Config.Default.DiscordBotHelpUrl);
}
private void ComboBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
var comboBox = sender as ComboBox;
@ -326,6 +336,8 @@ namespace ServerManagerTool
textBox = SteamAPIKeyTextBox;
if (Equals(hideTextBox, HideEmailPasswordTextBox))
textBox = EmailPasswordTextBox;
if (Equals(hideTextBox, HideDiscordBotTokenTextBox))
textBox = DiscordBotTokenTextBox;
if (textBox != null)
{
@ -349,6 +361,8 @@ namespace ServerManagerTool
hideTextBox = HideSteamAPIKeyTextBox;
if (textBox == EmailPasswordTextBox)
hideTextBox = HideEmailPasswordTextBox;
if (textBox == DiscordBotTokenTextBox)
hideTextBox = HideDiscordBotTokenTextBox;
if (hideTextBox != null)
{

View file

@ -1579,6 +1579,45 @@
</StackPanel>
</Expander>
<Expander Name="SectionDiscordBot" IsExpanded="{Binding CurrentConfig.SectionDiscordBotIsExpanded, ElementName=SettingsControl, FallbackValue=True, Mode=TwoWay}" Visibility="{Binding CurrentConfig.DiscordBotEnabled, ElementName=SettingsControl, Converter={StaticResource BooleanToVisibilityConverter}}">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{DynamicResource ServerSettings_DiscordBotLabel}" Style="{StaticResource ExpanderHeaderTextStyle}"/>
</StackPanel>
</Expander.Header>
<Expander.Style>
<Style BasedOn="{StaticResource ExpanderStyle1}" TargetType="{x:Type Expander}">
<Setter Property="Template" Value="{StaticResource ExpanderTemplateSE}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked}" Value="True">
<Setter Property="Template" Value="{StaticResource ExpanderTemplateSotF}"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=EnablePGMCheckbox, Path=IsChecked}" Value="True">
<Setter Property="Template" Value="{StaticResource ExpanderTemplatePGM}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Expander.Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" MinWidth="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{DynamicResource ServerSettings_DiscordBotChannelLabel}" ToolTip="{DynamicResource ServerSettings_DiscordBotChannelTooltip}" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding DiscordChannelId, Mode=TwoWay}" ToolTip="{DynamicResource ServerSettings_DiscordBotChannelTooltip}" VerticalContentAlignment="Center" />
</Grid>
</Expander>
<Expander Name="SectionRules" IsExpanded="{Binding CurrentConfig.SectionRulesIsExpanded, ElementName=SettingsControl, FallbackValue=True, Mode=TwoWay}">
<Expander.Header>
<StackPanel Orientation="Horizontal">

View file

@ -257,6 +257,12 @@
<setting name="DefaultDataDirectoryName" serializeAs="String">
<value>csmdata</value>
</setting>
<setting name="DiscordBotApplyUrl" serializeAs="String">
<value>https://discord.com/developers/applications</value>
</setting>
<setting name="DiscordBotHelpUrl" serializeAs="String">
<value>https://servermanagers.freeforums.net/thread/99/get-own-discord-bot</value>
</setting>
</ServerManagerTool.Config>
<ServerManagerTool.Common.CommonConfig>
<setting name="DefaultSteamAPIKey" serializeAs="String">
@ -579,6 +585,12 @@
<setting name="DiscordBotToken" serializeAs="String">
<value />
</setting>
<setting name="DiscordBotServerId" serializeAs="String">
<value />
</setting>
<setting name="SectionDiscordBotIsExpanded" serializeAs="String">
<value>False</value>
</setting>
</ServerManagerTool.Config>
</userSettings>
</configuration>

View file

@ -230,9 +230,9 @@ namespace ServerManagerTool
return LogManager.GetLogger(loggerName);
}
private static IList<string> HandleDiscordCommand(CommandType commandType, string channelId, string profileId)
private static IList<string> HandleDiscordCommand(CommandType commandType, string serverId, string channelId, string profileId)
{
return null;
return new List<string>() { $"{commandType}; {serverId}; {channelId}; {profileId ?? "no profile"}" };
}
private static void MigrateSettings()
@ -462,7 +462,7 @@ namespace ServerManagerTool
Task discordTask = Task.Run(async () =>
{
await ServerManagerBot.StartAsync(Config.Default.DiscordBotPrefix, Config.Default.DiscordBotToken, Config.Default.DataPath, HandleDiscordCommand, _tokenSource.Token);
await ServerManagerBot.StartAsync(Config.Default.DiscordBotToken,Config.Default.DiscordBotPrefix, Config.Default.DataPath, HandleDiscordCommand, _tokenSource.Token);
}, _tokenSource.Token)
.ContinueWith(t => {
var message = t.Exception.InnerException is null ? t.Exception.Message : t.Exception.InnerException.Message;

View file

@ -2001,5 +2001,47 @@ namespace ServerManagerTool {
this["DiscordBotToken"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string DiscordBotServerId {
get {
return ((string)(this["DiscordBotServerId"]));
}
set {
this["DiscordBotServerId"] = value;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://discord.com/developers/applications")]
public string DiscordBotApplyUrl {
get {
return ((string)(this["DiscordBotApplyUrl"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://servermanagers.freeforums.net/thread/99/get-own-discord-bot")]
public string DiscordBotHelpUrl {
get {
return ((string)(this["DiscordBotHelpUrl"]));
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool SectionDiscordBotIsExpanded {
get {
return ((bool)(this["SectionDiscordBotIsExpanded"]));
}
set {
this["SectionDiscordBotIsExpanded"] = value;
}
}
}
}

View file

@ -554,5 +554,17 @@
<Setting Name="DiscordBotToken" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="DiscordBotServerId" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="DiscordBotApplyUrl" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://discord.com/developers/applications</Value>
</Setting>
<Setting Name="DiscordBotHelpUrl" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://servermanagers.freeforums.net/thread/99/get-own-discord-bot</Value>
</Setting>
<Setting Name="SectionDiscordBotIsExpanded" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -768,6 +768,17 @@
<sys:String x:Key="GlobalSettings_ShutdownAllMessagesShowReasonLabel">Show shutdown reason with ALL shutdown messages</sys:String>
<sys:String x:Key="GlobalSettings_ShutdownAllMessagesShowReasonTooltip">If enabled, the shutdown reason will be shown with all shutdown message; otherwise it will only be shown at the start of the server shutdown.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotLabel">Enable Discord Bot</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotInformationLabel">You will need to restart the server manager if you change any settings for the Discord Bot.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotTokenLabel">Token:</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotTokenTooltip">The token associated with the discord bot.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotServerLabel">Server Id:</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotServerTooltip">The id of the discord server the bot will listen to.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotPrefixLabel">Prefix:</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotPrefixTooltip">The prefix that must be used when sending a command via discord.</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotApplyButtonLabel">Get Token...</sys:String>
<sys:String x:Key="GlobalSettings_DiscordBotHelpButtonLabel">Help...</sys:String>
<sys:String x:Key="GlobalSettings_EmailSettingsLabel">SMTP Email Settings</sys:String>
<sys:String x:Key="GlobalSettings_EmailHostLabel">Host:</sys:String>
<sys:String x:Key="GlobalSettings_EmailHostTooltip">The name or IP address of the host used for SMTP transmissions.</sys:String>
@ -1121,6 +1132,12 @@
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">If enabled, the server will be restarted even if shutdown for Auto-Restarts and Auto-Updates.</sys:String>
<!--#endregion-->
<!--#region Server Settings - Discord Bot Details -->
<sys:String x:Key="ServerSettings_DiscordBotLabel">Discord Bot Details</sys:String>
<sys:String x:Key="ServerSettings_DiscordBotChannelLabel">Channel Id:</sys:String>
<sys:String x:Key="ServerSettings_DiscordBotChannelTooltip">The id of the discord server channel the bot will listen to.</sys:String>
<!--#endregion-->
<!--#region Server Settings - Server File Details -->
<sys:String x:Key="ServerSettings_ServerFilesLabel">Server File Details</sys:String>
<sys:String x:Key="ServerSettings_ServerFilesWarningLabel">NOTE: Any changes will require a server restart to take effect.</sys:String>

View file

@ -567,6 +567,16 @@ namespace ServerManagerTool.Lib
}
#endregion
#region Discord Bot
public static readonly DependencyProperty DiscordChannelIdProperty = DependencyProperty.Register(nameof(DiscordChannelId), typeof(string), typeof(ServerProfile), new PropertyMetadata(String.Empty));
[DataMember]
public string DiscordChannelId
{
get { return (string)GetValue(DiscordChannelIdProperty); }
set { SetValue(DiscordChannelIdProperty, value); }
}
#endregion
#region Server Files
public static readonly DependencyProperty ServerFilesBlacklistedProperty = DependencyProperty.Register(nameof(ServerFilesBlacklisted), typeof(PlayerUserList), typeof(ServerProfile), new PropertyMetadata(null));
[DataMember]

View file

@ -671,5 +671,15 @@
<Label Content="{DynamicResource GlobalSettings_CacheDirectoryButtonLabel}" VerticalAlignment="Center" Margin="0,-3,0,-3"/>
</StackPanel>
</ContentControl>
<ContentControl x:Key="DiscordBotApplyButtonContent">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource GlobalSettings_DiscordBotApplyButtonLabel}" VerticalAlignment="Center" Margin="0,-2,0,-2"/>
</StackPanel>
</ContentControl>
<ContentControl x:Key="DiscordBotHelpButtonContent">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource GlobalSettings_DiscordBotHelpButtonLabel}" VerticalAlignment="Center" Margin="0,-2,0,-2"/>
</StackPanel>
</ContentControl>
</Globalization:StyleResourceDictionary>

View file

@ -527,6 +527,43 @@
</GroupBox>
<GroupBox Grid.Row="19" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<CheckBox IsChecked="{Binding Config.DiscordBotEnabled}" Content="{DynamicResource GlobalSettings_DiscordBotLabel}" VerticalAlignment="Center"/>
</GroupBox.Header>
<Grid IsEnabled="{Binding Config.DiscordBotEnabled}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" Margin="5" Text="{DynamicResource GlobalSettings_DiscordBotInformationLabel}" TextWrapping="Wrap" VerticalAlignment="Center" FontWeight="Bold" Foreground="{DynamicResource WarningMessage}"/>
<Label Grid.Row="1" Grid.Column="0" Content="{DynamicResource GlobalSettings_DiscordBotTokenLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Margin="1" Name="HideDiscordBotTokenTextBox" Text="{DynamicResource ServerSettings_HidePasswordText}" ToolTip="{DynamicResource ServerSettings_HidePasswordTooltip}" GotFocus="HiddenField_GotFocus" Style="{StaticResource HiddenTextBoxStyle}"/>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Margin="1" Name="DiscordBotTokenTextBox" Text="{Binding Config.DiscordBotToken}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotTokenTooltip}" LostFocus="HiddenField_LostFocus" Visibility="Collapsed"/>
<Button Grid.Row="1" Grid.Column="5" Margin="1" Content="{DynamicResource DiscordBotApplyButtonContent}" Click="DiscordBotApply_Click"/>
<Button Grid.Row="1" Grid.Column="6" Margin="1" Content="{DynamicResource DiscordBotHelpButtonContent}" Click="DiscordBotHelp_Click"/>
<Label Grid.Row="2" Grid.Column="0" Content="{DynamicResource GlobalSettings_DiscordBotServerLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding Config.DiscordBotServerId}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotServerTooltip}"/>
<Label Grid.Row="2" Grid.Column="3" Content="{DynamicResource GlobalSettings_DiscordBotPrefixLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="4" Margin="1" Text="{Binding Config.DiscordBotPrefix}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotPrefixTooltip}"/>
</Grid>
</GroupBox>
<GroupBox Grid.Row="20" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<Label Content="{DynamicResource GlobalSettings_EmailSettingsLabel}"/>
</GroupBox.Header>
@ -569,7 +606,7 @@
</Grid>
</GroupBox>
<GroupBox Grid.Row="20" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox Grid.Row="21" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<Label Content="{DynamicResource GlobalSettings_EmailNotifySettingsLabel}"/>
</GroupBox.Header>
@ -593,7 +630,7 @@
</Grid>
</GroupBox>
<GroupBox Grid.Row="21" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox Grid.Row="22" Grid.Column="0" Grid.ColumnSpan="4" Style="{StaticResource GroupBoxStyle}">
<GroupBox.Header>
<Label Content="{DynamicResource GlobalSettings_AdvancedSettingsLabel}"/>
</GroupBox.Header>

View file

@ -257,6 +257,16 @@ namespace ServerManagerTool
Process.Start(Config.Default.SteamWebAPIKeyHelpUrl);
}
private void DiscordBotApply_Click(object sender, RoutedEventArgs e)
{
Process.Start(Config.Default.DiscordBotApplyUrl);
}
private void DiscordBotHelp_Click(object sender, RoutedEventArgs e)
{
Process.Start(Config.Default.DiscordBotHelpUrl);
}
private async void SteamCMDAuthenticate_Click(object sender, RoutedEventArgs e)
{
var cursor = this.Cursor;
@ -335,6 +345,8 @@ namespace ServerManagerTool
textBox = SteamAPIKeyTextBox;
if (Equals(hideTextBox, HideEmailPasswordTextBox))
textBox = EmailPasswordTextBox;
if (Equals(hideTextBox, HideDiscordBotTokenTextBox))
textBox = DiscordBotTokenTextBox;
if (textBox != null)
{
@ -358,6 +370,8 @@ namespace ServerManagerTool
hideTextBox = HideSteamAPIKeyTextBox;
if (textBox == EmailPasswordTextBox)
hideTextBox = HideEmailPasswordTextBox;
if (textBox == DiscordBotTokenTextBox)
hideTextBox = HideDiscordBotTokenTextBox;
if (hideTextBox != null)
{

View file

@ -1062,6 +1062,37 @@
</StackPanel>
</Expander>
<Expander Name="SectionDiscordBot" IsExpanded="{Binding Config.SectionDiscordBotIsExpanded, ElementName=SettingsControl, FallbackValue=True, Mode=TwoWay}" Visibility="{Binding Config.DiscordBotEnabled, ElementName=SettingsControl, Converter={StaticResource BooleanToVisibilityConverter}}">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{DynamicResource ServerSettings_DiscordBotLabel}" Style="{StaticResource ExpanderHeaderTextStyle}"/>
</StackPanel>
</Expander.Header>
<Expander.Style>
<Style BasedOn="{StaticResource ExpanderStyle1}" TargetType="{x:Type Expander}">
<Setter Property="Template" Value="{StaticResource ExpanderTemplateSE}"/>
</Style>
</Expander.Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" MinWidth="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{DynamicResource ServerSettings_DiscordBotChannelLabel}" ToolTip="{DynamicResource ServerSettings_DiscordBotChannelTooltip}" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding DiscordChannelId, Mode=TwoWay}" ToolTip="{DynamicResource ServerSettings_DiscordBotChannelTooltip}" VerticalContentAlignment="Center" />
</Grid>
</Expander>
<Expander Name="SectionServerFiles" IsExpanded="{Binding Config.SectionServerFilesIsExpanded, ElementName=SettingsControl, FallbackValue=True, Mode=TwoWay}">
<Expander.Header>
<StackPanel Orientation="Horizontal">