Added AppName and AppVersion optional fields to DiscordConfig. UserAgent is now readonly.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
@@ -38,9 +39,33 @@ namespace Discord
|
|||||||
/// <summary> Specifies the minimum log level severity that will be sent to the LogMessage event. Warning: setting this to debug will really hurt performance but should help investigate any internal issues. </summary>
|
/// <summary> Specifies the minimum log level severity that will be sent to the LogMessage event. Warning: setting this to debug will really hurt performance but should help investigate any internal issues. </summary>
|
||||||
public LogSeverity LogLevel { get { return _logLevel; } set { SetValue(ref _logLevel, value); } }
|
public LogSeverity LogLevel { get { return _logLevel; } set { SetValue(ref _logLevel, value); } }
|
||||||
private LogSeverity _logLevel = LogSeverity.Info;
|
private LogSeverity _logLevel = LogSeverity.Info;
|
||||||
|
|
||||||
|
/// <summary> Name of your application. </summary>
|
||||||
|
public string AppName { get { return _appName; } set { SetValue(ref _appName, value); UpdateUserAgent(); } }
|
||||||
|
private string _appName = null;
|
||||||
|
/// <summary> Version of your application. </summary>
|
||||||
|
public string AppVersion { get { return _appVersion; } set { SetValue(ref _appVersion, value); UpdateUserAgent(); } }
|
||||||
|
private string _appVersion = null;
|
||||||
|
|
||||||
/// <summary> User Agent string to use when connecting to Discord. </summary>
|
/// <summary> User Agent string to use when connecting to Discord. </summary>
|
||||||
public string UserAgent { get { return _userAgent; } set { SetValue(ref _userAgent, value); } }
|
public string UserAgent { get { return _userAgent; } }
|
||||||
private string _userAgent = $"Discord.Net/{DiscordClient.Version} (https://github.com/RogueException/Discord.Net)";
|
private string _userAgent;
|
||||||
|
private void UpdateUserAgent()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
if (!string.IsNullOrEmpty(_appName))
|
||||||
|
{
|
||||||
|
builder.Append(_appName);
|
||||||
|
if (!string.IsNullOrEmpty(_appVersion))
|
||||||
|
{
|
||||||
|
builder.Append('/');
|
||||||
|
builder.Append(_appVersion);
|
||||||
|
}
|
||||||
|
builder.Append(' ');
|
||||||
|
}
|
||||||
|
builder.Append($"DiscordBot (https://github.com/RogueException/Discord.Net, v{DiscordClient.Version})");
|
||||||
|
_userAgent = builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
//Rest
|
//Rest
|
||||||
|
|
||||||
@@ -89,5 +114,10 @@ namespace Discord
|
|||||||
/// <summary> Maintains the LastActivity property for users, showing when they last made an action (sent message, joined server, typed, etc). </summary>
|
/// <summary> Maintains the LastActivity property for users, showing when they last made an action (sent message, joined server, typed, etc). </summary>
|
||||||
public bool TrackActivity { get { return _trackActivity; } set { SetValue(ref _trackActivity, value); } }
|
public bool TrackActivity { get { return _trackActivity; } set { SetValue(ref _trackActivity, value); } }
|
||||||
private bool _trackActivity = true;
|
private bool _trackActivity = true;
|
||||||
|
|
||||||
|
public DiscordConfig()
|
||||||
|
{
|
||||||
|
UpdateUserAgent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user