| @@ -8,6 +8,8 @@ namespace Discord.Rest | |||||
| { | { | ||||
| public class DiscordRestClient : BaseDiscordClient, IDiscordClient | public class DiscordRestClient : BaseDiscordClient, IDiscordClient | ||||
| { | { | ||||
| private RestApplication _applicationInfo; | |||||
| public new RestSelfUser CurrentUser => base.CurrentUser as RestSelfUser; | public new RestSelfUser CurrentUser => base.CurrentUser as RestSelfUser; | ||||
| public DiscordRestClient() : this(new DiscordRestConfig()) { } | public DiscordRestClient() : this(new DiscordRestConfig()) { } | ||||
| @@ -21,10 +23,17 @@ namespace Discord.Rest | |||||
| base.CurrentUser = RestSelfUser.Create(this, ApiClient.CurrentUser); | base.CurrentUser = RestSelfUser.Create(this, ApiClient.CurrentUser); | ||||
| return Task.CompletedTask; | return Task.CompletedTask; | ||||
| } | } | ||||
| protected override Task OnLogoutAsync() | |||||
| { | |||||
| _applicationInfo = null; | |||||
| return Task.CompletedTask; | |||||
| } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<RestApplication> GetApplicationInfoAsync() | |||||
| => ClientHelper.GetApplicationInfoAsync(this); | |||||
| public async Task<RestApplication> GetApplicationInfoAsync() | |||||
| { | |||||
| return _applicationInfo ?? (_applicationInfo = await ClientHelper.GetApplicationInfoAsync(this)); | |||||
| } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<RestChannel> GetChannelAsync(ulong id) | public Task<RestChannel> GetChannelAsync(ulong id) | ||||
| @@ -14,7 +14,7 @@ using System.Threading.Tasks; | |||||
| namespace Discord.Rpc | namespace Discord.Rpc | ||||
| { | { | ||||
| public partial class DiscordRpcClient : BaseDiscordClient | |||||
| public partial class DiscordRpcClient : BaseDiscordClient, IDiscordClient | |||||
| { | { | ||||
| private readonly Logger _rpcLogger; | private readonly Logger _rpcLogger; | ||||
| private readonly JsonSerializer _serializer; | private readonly JsonSerializer _serializer; | ||||
| @@ -33,7 +33,7 @@ namespace Discord.Rpc | |||||
| public new API.DiscordRpcApiClient ApiClient => base.ApiClient as API.DiscordRpcApiClient; | public new API.DiscordRpcApiClient ApiClient => base.ApiClient as API.DiscordRpcApiClient; | ||||
| public new RestSelfUser CurrentUser { get { return base.CurrentUser as RestSelfUser; } private set { base.CurrentUser = value; } } | public new RestSelfUser CurrentUser { get { return base.CurrentUser as RestSelfUser; } private set { base.CurrentUser = value; } } | ||||
| public RestApplication CurrentApplication { get; private set; } | |||||
| public RestApplication ApplicationInfo { get; private set; } | |||||
| /// <summary> Creates a new RPC discord client. </summary> | /// <summary> Creates a new RPC discord client. </summary> | ||||
| public DiscordRpcClient(string clientId, string origin) | public DiscordRpcClient(string clientId, string origin) | ||||
| @@ -393,7 +393,7 @@ namespace Discord.Rpc | |||||
| { | { | ||||
| var response = await ApiClient.SendAuthenticateAsync(options).ConfigureAwait(false); | var response = await ApiClient.SendAuthenticateAsync(options).ConfigureAwait(false); | ||||
| CurrentUser = RestSelfUser.Create(this, response.User); | CurrentUser = RestSelfUser.Create(this, response.User); | ||||
| CurrentApplication = RestApplication.Create(this, response.Application); | |||||
| ApplicationInfo = RestApplication.Create(this, response.Application); | |||||
| Scopes = response.Scopes; | Scopes = response.Scopes; | ||||
| TokenExpiresAt = response.Expires; | TokenExpiresAt = response.Expires; | ||||
| @@ -547,5 +547,8 @@ namespace Discord.Rpc | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| //IDiscordClient | |||||
| Task<IApplication> IDiscordClient.GetApplicationInfoAsync() => Task.FromResult<IApplication>(ApplicationInfo); | |||||
| } | } | ||||
| } | } | ||||
| @@ -38,7 +38,7 @@ namespace Discord.WebSocket | |||||
| private int _nextAudioId; | private int _nextAudioId; | ||||
| private bool _canReconnect; | private bool _canReconnect; | ||||
| private DateTimeOffset? _statusSince; | private DateTimeOffset? _statusSince; | ||||
| private RestApplication _application; | |||||
| private RestApplication _applicationInfo; | |||||
| /// <summary> Gets the shard of of this client. </summary> | /// <summary> Gets the shard of of this client. </summary> | ||||
| public int ShardId { get; } | public int ShardId { get; } | ||||
| @@ -124,6 +124,7 @@ namespace Discord.WebSocket | |||||
| if (ConnectionState != ConnectionState.Disconnected) | if (ConnectionState != ConnectionState.Disconnected) | ||||
| await DisconnectInternalAsync(null, false).ConfigureAwait(false); | await DisconnectInternalAsync(null, false).ConfigureAwait(false); | ||||
| _applicationInfo = null; | |||||
| _voiceRegions = ImmutableDictionary.Create<string, RestVoiceRegion>(); | _voiceRegions = ImmutableDictionary.Create<string, RestVoiceRegion>(); | ||||
| } | } | ||||
| @@ -336,7 +337,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task<RestApplication> GetApplicationInfoAsync() | public async Task<RestApplication> GetApplicationInfoAsync() | ||||
| { | { | ||||
| return _application ?? (_application = await ClientHelper.GetApplicationInfoAsync(this)); | |||||
| return _applicationInfo ?? (_applicationInfo = await ClientHelper.GetApplicationInfoAsync(this)); | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||