| @@ -21,12 +21,10 @@ namespace Discord.API | |||||
| private readonly LogMessageSeverity _logLevel; | private readonly LogMessageSeverity _logLevel; | ||||
| private CancellationToken _cancelToken; | private CancellationToken _cancelToken; | ||||
| public RestClient(LogMessageSeverity logLevel, int timeout) | |||||
| public RestClient(LogMessageSeverity logLevel, string userAgent, int timeout) | |||||
| { | { | ||||
| _logLevel = logLevel; | _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 | #if DNXCORE50 | ||||
| _engine = new BuiltInRestEngine(userAgent, timeout); | _engine = new BuiltInRestEngine(userAgent, timeout); | ||||
| #else | #else | ||||
| @@ -11,9 +11,9 @@ namespace Discord | |||||
| internal RestClient RestClient => _rest; | internal RestClient RestClient => _rest; | ||||
| private readonly 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; | private string _token; | ||||
| @@ -54,7 +54,7 @@ namespace Discord | |||||
| : base(config) | : base(config) | ||||
| { | { | ||||
| _rand = new Random(); | _rand = new Random(); | ||||
| _api = new DiscordAPIClient(_config.LogLevel, _config.APITimeout); | |||||
| _api = new DiscordAPIClient(_config.LogLevel, _config.UserAgent, _config.APITimeout); | |||||
| if (_config.UseMessageQueue) | if (_config.UseMessageQueue) | ||||
| _pendingMessages = new ConcurrentQueue<Message>(); | _pendingMessages = new ConcurrentQueue<Message>(); | ||||
| if (_config.EnableVoiceMultiserver) | if (_config.EnableVoiceMultiserver) | ||||
| @@ -1,4 +1,5 @@ | |||||
| using System; | using System; | ||||
| using System.Reflection; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| @@ -68,6 +69,15 @@ namespace Discord | |||||
| internal uint VoiceClientId { get { return _voiceClientId; } set { SetValue(ref _voiceClientId, value); } } | internal uint VoiceClientId { get { return _voiceClientId; } set { SetValue(ref _voiceClientId, value); } } | ||||
| private uint _voiceClientId; | 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 | //Lock | ||||
| private bool _isLocked; | private bool _isLocked; | ||||
| internal void Lock() { _isLocked = true; } | internal void Lock() { _isLocked = true; } | ||||