diff --git a/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs b/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs index 7a8a009be..c3dd9c01d 100644 --- a/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs @@ -20,10 +20,10 @@ 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(); + //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.Core/TokenType.cs b/src/Discord.Net.Core/TokenType.cs index c351b1c19..62181420a 100644 --- a/src/Discord.Net.Core/TokenType.cs +++ b/src/Discord.Net.Core/TokenType.cs @@ -1,10 +1,10 @@ -using System; +using System; namespace Discord { public enum TokenType { - [Obsolete("User logins are being deprecated and may result in a ToS strike against your account - please see https://github.com/RogueException/Discord.Net/issues/827")] + [Obsolete("User logins are deprecated and may result in a ToS strike against your account - please see https://github.com/RogueException/Discord.Net/issues/827", error: true)] User, Bearer, Bot, diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 689cba9c3..d00c5d378 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -74,8 +74,8 @@ namespace Discord.API return $"Bot {token}"; case TokenType.Bearer: return $"Bearer {token}"; - case TokenType.User: - return token; + //case TokenType.User: + // return token; default: throw new ArgumentException("Unknown OAuth token type", nameof(tokenType)); } @@ -113,7 +113,7 @@ namespace Discord.API { _loginCancelToken = new CancellationTokenSource(); - AuthTokenType = TokenType.User; + //AuthTokenType = TokenType.User; AuthToken = null; await RequestQueue.SetCancelTokenAsync(_loginCancelToken.Token).ConfigureAwait(false); RestClient.SetCancelToken(_loginCancelToken.Token); @@ -172,8 +172,8 @@ 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 = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; + //options.IsClientBucket = AuthTokenType == TokenType.User; var request = new RestRequest(RestClient, method, endpoint, options); await SendInternalAsync(method, endpoint, request).ConfigureAwait(false); @@ -187,8 +187,8 @@ 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 = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; + //options.IsClientBucket = AuthTokenType == TokenType.User; string json = payload != null ? SerializeJson(payload) : null; var request = new JsonRestRequest(RestClient, method, endpoint, json, options); @@ -203,8 +203,8 @@ 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 = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; + //options.IsClientBucket = AuthTokenType == TokenType.User; var request = new MultipartRestRequest(RestClient, method, endpoint, multipartArgs, options); await SendInternalAsync(method, endpoint, request).ConfigureAwait(false); @@ -217,8 +217,8 @@ 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 = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; + //options.IsClientBucket = AuthTokenType == TokenType.User; var request = new RestRequest(RestClient, method, endpoint, options); return DeserializeJson(await SendInternalAsync(method, endpoint, request).ConfigureAwait(false)); @@ -231,8 +231,8 @@ 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 = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; + //options.IsClientBucket = AuthTokenType == TokenType.User; string json = payload != null ? SerializeJson(payload) : null; var request = new JsonRestRequest(RestClient, method, endpoint, json, options); @@ -246,8 +246,8 @@ 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 = /*AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id :*/ bucketId; + //options.IsClientBucket = AuthTokenType == TokenType.User; 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 142f24417..43b564a7e 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -446,7 +446,7 @@ namespace Discord.WebSocket { var model = data.Guilds[i]; var guild = AddGuild(model, state); - if (!guild.IsAvailable || ApiClient.AuthTokenType == TokenType.User) + if (!guild.IsAvailable /*|| ApiClient.AuthTokenType == TokenType.User*/) unavailableGuilds++; else await GuildAvailableAsync(guild).ConfigureAwait(false); @@ -465,8 +465,8 @@ namespace Discord.WebSocket return; } - if (ApiClient.AuthTokenType == TokenType.User) - await SyncGuildsAsync().ConfigureAwait(false); + //if (ApiClient.AuthTokenType == TokenType.User) + // await SyncGuildsAsync().ConfigureAwait(false); _lastGuildAvailableTime = Environment.TickCount; _guildDownloadTask = WaitForGuildsAsync(_connection.CancelToken, _gatewayLogger) @@ -542,8 +542,8 @@ namespace Discord.WebSocket var guild = AddGuild(data, State); if (guild != null) { - if (ApiClient.AuthTokenType == TokenType.User) - await SyncGuildsAsync().ConfigureAwait(false); + //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 e70df8ce8..858fbc8e3 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS0618 +#pragma warning disable CS0618 using Discord.Audio; using Discord.Rest; using System; @@ -192,12 +192,12 @@ namespace Discord.WebSocket _syncPromise = new TaskCompletionSource(); _downloaderPromise = new TaskCompletionSource(); - if (Discord.ApiClient.AuthTokenType != TokenType.User) - { + //if (Discord.ApiClient.AuthTokenType != TokenType.User) + //{ var _ = _syncPromise.TrySetResultAsync(true); /*if (!model.Large) _ = _downloaderPromise.TrySetResultAsync(true);*/ - } + //} } internal void Update(ClientState state, Model model) {