Moved UserAgent to Config
This commit is contained in:
@@ -21,12 +21,10 @@ namespace Discord.API
|
||||
private readonly LogMessageSeverity _logLevel;
|
||||
private CancellationToken _cancelToken;
|
||||
|
||||
public RestClient(LogMessageSeverity logLevel, int timeout)
|
||||
public RestClient(LogMessageSeverity logLevel, string userAgent, int timeout)
|
||||
{
|
||||
_logLevel = logLevel;
|
||||
|
||||
string version = typeof(RestClient).GetTypeInfo().Assembly.GetName().Version.ToString(2);
|
||||
string userAgent = $"Discord.Net/{version} (https://github.com/RogueException/Discord.Net)";
|
||||
|
||||
#if DNXCORE50
|
||||
_engine = new BuiltInRestEngine(userAgent, timeout);
|
||||
#else
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace Discord
|
||||
internal RestClient RestClient => _rest;
|
||||
private readonly RestClient _rest;
|
||||
|
||||
public DiscordAPIClient(LogMessageSeverity logLevel, int timeout)
|
||||
public DiscordAPIClient(LogMessageSeverity logLevel, string userAgent, int timeout)
|
||||
{
|
||||
_rest = new RestClient(logLevel, timeout);
|
||||
_rest = new RestClient(logLevel, userAgent, timeout);
|
||||
}
|
||||
|
||||
private string _token;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Discord
|
||||
: base(config)
|
||||
{
|
||||
_rand = new Random();
|
||||
_api = new DiscordAPIClient(_config.LogLevel, _config.APITimeout);
|
||||
_api = new DiscordAPIClient(_config.LogLevel, _config.UserAgent, _config.APITimeout);
|
||||
if (_config.UseMessageQueue)
|
||||
_pendingMessages = new ConcurrentQueue<Message>();
|
||||
if (_config.EnableVoiceMultiserver)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
@@ -68,6 +69,15 @@ namespace Discord
|
||||
internal uint VoiceClientId { get { return _voiceClientId; } set { SetValue(ref _voiceClientId, value); } }
|
||||
private uint _voiceClientId;
|
||||
|
||||
internal string UserAgent
|
||||
{
|
||||
get
|
||||
{
|
||||
string version = typeof(DiscordClientConfig).GetTypeInfo().Assembly.GetName().Version.ToString(2);
|
||||
return $"Discord.Net/{version} (https://github.com/RogueException/Discord.Net)";
|
||||
}
|
||||
}
|
||||
|
||||
//Lock
|
||||
private bool _isLocked;
|
||||
internal void Lock() { _isLocked = true; }
|
||||
|
||||
Reference in New Issue
Block a user