diff --git a/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs b/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs index c3dd9c01d..93e3cbe18 100644 --- a/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using System; using System.Threading.Tasks; @@ -20,10 +19,6 @@ namespace Discord.Commands if (context.User.Id != application.Owner.Id) return PreconditionResult.FromError("Command can only be run by the owner of the bot"); return PreconditionResult.FromSuccess(); - //case TokenType.User: - // if (context.User.Id != context.Client.CurrentUser.Id) - // return PreconditionResult.FromError("Command can only be run by the owner of the bot"); - // return PreconditionResult.FromSuccess(); default: return PreconditionResult.FromError($"{nameof(RequireOwnerAttribute)} is not supported by this {nameof(TokenType)}."); } diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index d00c5d378..c93ed628b 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -1,5 +1,4 @@ #pragma warning disable CS1591 -#pragma warning disable CS0618 using Discord.API.Rest; using Discord.Net; using Discord.Net.Converters; @@ -74,8 +73,6 @@ namespace Discord.API return $"Bot {token}"; case TokenType.Bearer: return $"Bearer {token}"; - //case TokenType.User: - // return token; default: throw new ArgumentException("Unknown OAuth token type", nameof(tokenType)); } @@ -113,7 +110,6 @@ namespace Discord.API { _loginCancelToken = new CancellationTokenSource(); - //AuthTokenType = TokenType.User; AuthToken = null; await RequestQueue.SetCancelTokenAsync(_loginCancelToken.Token).ConfigureAwait(false); RestClient.SetCancelToken(_loginCancelToken.Token); @@ -172,8 +168,7 @@ namespace Discord.API { options = options ?? new RequestOptions(); options.HeaderOnly = true; - options.BucketId = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; - //options.IsClientBucket = AuthTokenType == TokenType.User; + options.BucketId = bucketId; var request = new RestRequest(RestClient, method, endpoint, options); await SendInternalAsync(method, endpoint, request).ConfigureAwait(false); @@ -187,8 +182,7 @@ namespace Discord.API { options = options ?? new RequestOptions(); options.HeaderOnly = true; - options.BucketId = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; - //options.IsClientBucket = AuthTokenType == TokenType.User; + options.BucketId = bucketId; string json = payload != null ? SerializeJson(payload) : null; var request = new JsonRestRequest(RestClient, method, endpoint, json, options); @@ -203,8 +197,7 @@ namespace Discord.API { options = options ?? new RequestOptions(); options.HeaderOnly = true; - options.BucketId = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; - //options.IsClientBucket = AuthTokenType == TokenType.User; + options.BucketId = bucketId; var request = new MultipartRestRequest(RestClient, method, endpoint, multipartArgs, options); await SendInternalAsync(method, endpoint, request).ConfigureAwait(false); @@ -217,8 +210,7 @@ namespace Discord.API string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class { options = options ?? new RequestOptions(); - options.BucketId = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; - //options.IsClientBucket = AuthTokenType == TokenType.User; + options.BucketId = bucketId; var request = new RestRequest(RestClient, method, endpoint, options); return DeserializeJson(await SendInternalAsync(method, endpoint, request).ConfigureAwait(false)); @@ -231,8 +223,7 @@ namespace Discord.API string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class { options = options ?? new RequestOptions(); - options.BucketId = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; - //options.IsClientBucket = AuthTokenType == TokenType.User; + options.BucketId = bucketId; string json = payload != null ? SerializeJson(payload) : null; var request = new JsonRestRequest(RestClient, method, endpoint, json, options); @@ -246,8 +237,7 @@ namespace Discord.API string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) { options = options ?? new RequestOptions(); - options.BucketId = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; - //options.IsClientBucket = AuthTokenType == TokenType.User; + options.BucketId = bucketId; var request = new MultipartRestRequest(RestClient, method, endpoint, multipartArgs, options); return DeserializeJson(await SendInternalAsync(method, endpoint, request).ConfigureAwait(false)); diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 43b564a7e..593f796c2 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Discord.API; using Discord.API.Gateway; using Discord.Logging; @@ -446,7 +445,7 @@ namespace Discord.WebSocket { var model = data.Guilds[i]; var guild = AddGuild(model, state); - if (!guild.IsAvailable /*|| ApiClient.AuthTokenType == TokenType.User*/) + if (!guild.IsAvailable) unavailableGuilds++; else await GuildAvailableAsync(guild).ConfigureAwait(false); @@ -465,9 +464,6 @@ namespace Discord.WebSocket return; } - //if (ApiClient.AuthTokenType == TokenType.User) - // await SyncGuildsAsync().ConfigureAwait(false); - _lastGuildAvailableTime = Environment.TickCount; _guildDownloadTask = WaitForGuildsAsync(_connection.CancelToken, _gatewayLogger) .ContinueWith(async x => @@ -542,8 +538,6 @@ namespace Discord.WebSocket var guild = AddGuild(data, State); if (guild != null) { - //if (ApiClient.AuthTokenType == TokenType.User) - // await SyncGuildsAsync().ConfigureAwait(false); await TimedInvokeAsync(_joinedGuildEvent, nameof(JoinedGuild), guild).ConfigureAwait(false); } else diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index 858fbc8e3..259dae5a8 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Discord.Audio; using Discord.Rest; using System; @@ -64,7 +63,7 @@ namespace Discord.WebSocket public Task DownloaderPromise => _downloaderPromise.Task; public IAudioClient AudioClient => _audioClient; public SocketTextChannel DefaultChannel => TextChannels - .Where(c => CurrentUser.GetPermissions(c).ReadMessages) + .Where(c => CurrentUser.GetPermissions(c).ViewChannel) .OrderBy(c => c.Position) .FirstOrDefault(); public SocketVoiceChannel AFKChannel @@ -192,12 +191,9 @@ namespace Discord.WebSocket _syncPromise = new TaskCompletionSource(); _downloaderPromise = new TaskCompletionSource(); - //if (Discord.ApiClient.AuthTokenType != TokenType.User) - //{ - var _ = _syncPromise.TrySetResultAsync(true); - /*if (!model.Large) - _ = _downloaderPromise.TrySetResultAsync(true);*/ - //} + var _ = _syncPromise.TrySetResultAsync(true); + /*if (!model.Large) + _ = _downloaderPromise.TrySetResultAsync(true);*/ } internal void Update(ClientState state, Model model) {