diff --git a/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs b/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs index 54bc362e..4e47ca2b 100644 --- a/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs +++ b/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs @@ -48,8 +48,8 @@ namespace Discord { var result = new Override(); - using(var textReader = new StringReader(json)) - using(var reader = new JsonTextReader(textReader)) + using (var textReader = new StringReader(json)) + using (var reader = new JsonTextReader(textReader)) { var obj = JObject.ReadFrom(reader); result.Id = obj["id"].ToObject(); @@ -100,14 +100,14 @@ namespace Discord /// Gets a read-only dictionary containing the currently loaded overrides. /// public IReadOnlyDictionary> LoadedOverrides - => _loadedOverrides.Select(x => new KeyValuePair> (x.Key, x.Value)).ToDictionary(x => x.Key, x => x.Value); + => _loadedOverrides.Select(x => new KeyValuePair>(x.Key, x.Value)).ToDictionary(x => x.Key, x => x.Value); private static AssemblyLoadContext _overrideDomain; private static List> _logEvents = new(); private static ConcurrentDictionary> _loadedOverrides = new ConcurrentDictionary>(); private const string ApiUrl = "https://overrides.discordnet.dev"; - + static BuildOverrides() { _overrideDomain = new AssemblyLoadContext("Discord.Net.Overrides.Runtime"); @@ -258,14 +258,14 @@ namespace Discord private static async Task GetDependencyAsync(Guid id, string name) { - using(var client = new HttpClient()) + using (var client = new HttpClient()) { var result = await client.PostAsync($"{ApiUrl}/overrides/{id}/dependency", new StringContent($"{{ \"info\": \"{name}\"}}", Encoding.UTF8, "application/json")); if (!result.IsSuccessStatusCode) throw new Exception("Failed to get dependency"); - using(var ms = new MemoryStream()) + using (var ms = new MemoryStream()) { var innerStream = await result.Content.ReadAsStreamAsync(); await innerStream.CopyToAsync(ms); diff --git a/samples/BasicBot/Program.cs b/samples/BasicBot/Program.cs index a71de9fc..64c7a915 100644 --- a/samples/BasicBot/Program.cs +++ b/samples/BasicBot/Program.cs @@ -1,8 +1,8 @@ +using Discord; +using Discord.WebSocket; using System; using System.Threading; using System.Threading.Tasks; -using Discord; -using Discord.WebSocket; namespace BasicBot { @@ -112,7 +112,8 @@ namespace BasicBot if (component.Data.CustomId == "unique-id") await interaction.RespondAsync("Thank you for clicking my button!"); - else Console.WriteLine("An ID has been received that has no handler!"); + else + Console.WriteLine("An ID has been received that has no handler!"); } } } diff --git a/samples/InteractionFramework/Attributes/DoUserCheckAttribute.cs b/samples/InteractionFramework/Attributes/DoUserCheckAttribute.cs index 96266cdf..c83df6e2 100644 --- a/samples/InteractionFramework/Attributes/DoUserCheckAttribute.cs +++ b/samples/InteractionFramework/Attributes/DoUserCheckAttribute.cs @@ -30,7 +30,8 @@ namespace InteractionFramework.Attributes ? Task.FromResult(PreconditionResult.FromSuccess()) : Task.FromResult(PreconditionResult.FromError("User ID does not match component ID!")); - else return Task.FromResult(PreconditionResult.FromError("Parse cannot be done if no userID exists.")); + else + return Task.FromResult(PreconditionResult.FromError("Parse cannot be done if no userID exists.")); } } } diff --git a/samples/InteractionFramework/Attributes/RequireOwnerAttribute.cs b/samples/InteractionFramework/Attributes/RequireOwnerAttribute.cs index 7b0e57a4..d82918b5 100644 --- a/samples/InteractionFramework/Attributes/RequireOwnerAttribute.cs +++ b/samples/InteractionFramework/Attributes/RequireOwnerAttribute.cs @@ -10,7 +10,7 @@ namespace InteractionFramework.Attributes { public class RequireOwnerAttribute : PreconditionAttribute { - public override async Task CheckRequirementsAsync (IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services) + public override async Task CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services) { switch (context.Client.TokenType) { diff --git a/samples/InteractionFramework/Modules/ExampleModule.cs b/samples/InteractionFramework/Modules/ExampleModule.cs index 21064bbe..50156f10 100644 --- a/samples/InteractionFramework/Modules/ExampleModule.cs +++ b/samples/InteractionFramework/Modules/ExampleModule.cs @@ -26,7 +26,7 @@ namespace InteractionFramework.Modules // [Summary] lets you customize the name and the description of a parameter [SlashCommand("echo", "Repeat the input")] - public async Task Echo(string echo, [Summary(description: "mention the user")]bool mention = false) + public async Task Echo(string echo, [Summary(description: "mention the user")] bool mention = false) => await RespondAsync(echo + (mention ? Context.User.Mention : string.Empty)); [SlashCommand("ping", "Pings the bot and returns its latency.")] diff --git a/samples/InteractionFramework/Program.cs b/samples/InteractionFramework/Program.cs index b9c4697a..c6188e3a 100644 --- a/samples/InteractionFramework/Program.cs +++ b/samples/InteractionFramework/Program.cs @@ -64,11 +64,11 @@ namespace InteractionFramework public static bool IsDebug() { - #if DEBUG - return true; - #else - return false; - #endif +#if DEBUG + return true; +#else + return false; +#endif } } } diff --git a/src/Discord.Net.Analyzers/GuildAccessAnalyzer.cs b/src/Discord.Net.Analyzers/GuildAccessAnalyzer.cs index 38d3f39d..98d78560 100644 --- a/src/Discord.Net.Analyzers/GuildAccessAnalyzer.cs +++ b/src/Discord.Net.Analyzers/GuildAccessAnalyzer.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Immutable; -using System.Linq; +using Discord.Commands; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -using Discord.Commands; +using System; +using System.Collections.Immutable; +using System.Linq; namespace Discord.Analyzers { diff --git a/src/Discord.Net.Analyzers/SymbolExtensions.cs b/src/Discord.Net.Analyzers/SymbolExtensions.cs index 680de66b..cf9dd365 100644 --- a/src/Discord.Net.Analyzers/SymbolExtensions.cs +++ b/src/Discord.Net.Analyzers/SymbolExtensions.cs @@ -1,6 +1,6 @@ -using System; -using Microsoft.CodeAnalysis; using Discord.Commands; +using Microsoft.CodeAnalysis; +using System; namespace Discord.Analyzers { diff --git a/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs b/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs index a44dcb6e..92d043cc 100644 --- a/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs @@ -43,8 +43,8 @@ namespace Discord.Commands { if (!TypeReaderTypeInfo.IsAssignableFrom(overridenTypeReader.GetTypeInfo())) throw new ArgumentException($"{nameof(overridenTypeReader)} must inherit from {nameof(TypeReader)}."); - + TypeReader = overridenTypeReader; } - } + } } diff --git a/src/Discord.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs b/src/Discord.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs index 2908a18c..8e3091fa 100644 --- a/src/Discord.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs @@ -61,7 +61,7 @@ namespace Discord.Commands if (GuildPermission.HasValue) { if (guildUser == null) - return Task.FromResult(PreconditionResult.FromError(NotAGuildErrorMessage ?? "Command must be used in a guild channel.")); + return Task.FromResult(PreconditionResult.FromError(NotAGuildErrorMessage ?? "Command must be used in a guild channel.")); if (!guildUser.GuildPermissions.Has(GuildPermission.Value)) return Task.FromResult(PreconditionResult.FromError(ErrorMessage ?? $"User requires guild permission {GuildPermission.Value}.")); } diff --git a/src/Discord.Net.Commands/Builders/CommandBuilder.cs b/src/Discord.Net.Commands/Builders/CommandBuilder.cs index 1d946a33..80c71c2b 100644 --- a/src/Discord.Net.Commands/Builders/CommandBuilder.cs +++ b/src/Discord.Net.Commands/Builders/CommandBuilder.cs @@ -1,7 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using System.Collections.Generic; namespace Discord.Commands.Builders { diff --git a/src/Discord.Net.Commands/Builders/ModuleBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleBuilder.cs index f2a7eeb1..e8e15b1c 100644 --- a/src/Discord.Net.Commands/Builders/ModuleBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ModuleBuilder.cs @@ -20,7 +20,9 @@ namespace Discord.Commands.Builders public string Name { get; set; } public string Summary { get; set; } public string Remarks { get; set; } - public string Group { get => _group; + public string Group + { + get => _group; set { _aliases.Remove(_group); diff --git a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs index f98c81ab..9c4d5cc7 100644 --- a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs @@ -1,11 +1,10 @@ +using Discord.Commands.Builders; using System; -using System.Linq; using System.Collections.Generic; +using System.Linq; using System.Reflection; using System.Threading.Tasks; -using Discord.Commands.Builders; - namespace Discord.Commands { internal static class ModuleClassBuilder @@ -80,11 +79,11 @@ namespace Discord.Commands { if (!IsValidModuleDefinition(typeInfo)) continue; - + if (builtTypes.Contains(typeInfo)) continue; - - builder.AddModule((module) => + + builder.AddModule((module) => { BuildModule(module, typeInfo, service, services); BuildSubTypes(module, typeInfo.DeclaredNestedTypes, builtTypes, service, services); @@ -139,7 +138,7 @@ namespace Discord.Commands foreach (var method in validCommands) { - builder.AddCommand((command) => + builder.AddCommand((command) => { BuildCommand(command, typeInfo, method, service, services); }); @@ -149,7 +148,7 @@ namespace Discord.Commands private static void BuildCommand(CommandBuilder builder, TypeInfo typeInfo, MethodInfo method, CommandService service, IServiceProvider serviceprovider) { var attributes = method.GetCustomAttributes(); - + foreach (var attribute in attributes) { switch (attribute) @@ -191,7 +190,7 @@ namespace Discord.Commands int pos = 0, count = parameters.Length; foreach (var paramInfo in parameters) { - builder.AddParameter((parameter) => + builder.AddParameter((parameter) => { BuildParameter(parameter, paramInfo, pos++, count, service, serviceprovider); }); diff --git a/src/Discord.Net.Commands/Builders/ParameterBuilder.cs b/src/Discord.Net.Commands/Builders/ParameterBuilder.cs index afe3a5af..61cd01f0 100644 --- a/src/Discord.Net.Commands/Builders/ParameterBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ParameterBuilder.cs @@ -1,9 +1,8 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Collections.Generic; - namespace Discord.Commands.Builders { public class ParameterBuilder @@ -25,7 +24,7 @@ namespace Discord.Commands.Builders public IReadOnlyList Preconditions => _preconditions; public IReadOnlyList Attributes => _attributes; -#endregion + #endregion #region Automatic internal ParameterBuilder(CommandBuilder command) diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 29bf6a42..515c2343 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -1,3 +1,5 @@ +using Discord.Commands.Builders; +using Discord.Logging; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -6,8 +8,6 @@ using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; -using Discord.Commands.Builders; -using Discord.Logging; namespace Discord.Commands { @@ -653,7 +653,7 @@ namespace Discord.Commands var bestCandidate = preconditionResults .OrderByDescending(x => x.Key.Command.Priority) .FirstOrDefault(x => !x.Value.IsSuccess); - return MatchResult.FromSuccess(bestCandidate.Key,bestCandidate.Value); + return MatchResult.FromSuccess(bestCandidate.Key, bestCandidate.Value); } var parseResults = new Dictionary(); @@ -685,7 +685,7 @@ namespace Discord.Commands .Where(x => x.Value.IsSuccess) .ToArray(); - if(successfulParses.Length == 0) + if (successfulParses.Length == 0) { var bestMatch = parseResults .FirstOrDefault(x => !x.Value.IsSuccess); diff --git a/src/Discord.Net.Commands/CommandServiceConfig.cs b/src/Discord.Net.Commands/CommandServiceConfig.cs index 3c62063c..cbb5b8ff 100644 --- a/src/Discord.Net.Commands/CommandServiceConfig.cs +++ b/src/Discord.Net.Commands/CommandServiceConfig.cs @@ -17,7 +17,7 @@ namespace Discord.Commands /// Gets or sets the that separates an argument with another. /// public char SeparatorChar { get; set; } = ' '; - + /// /// Gets or sets whether commands should be case-sensitive. /// diff --git a/src/Discord.Net.Commands/EmptyServiceProvider.cs b/src/Discord.Net.Commands/EmptyServiceProvider.cs index 0bef3760..f9cda2a7 100644 --- a/src/Discord.Net.Commands/EmptyServiceProvider.cs +++ b/src/Discord.Net.Commands/EmptyServiceProvider.cs @@ -5,7 +5,7 @@ namespace Discord.Commands internal class EmptyServiceProvider : IServiceProvider { public static readonly EmptyServiceProvider Instance = new EmptyServiceProvider(); - + public object GetService(Type serviceType) => null; } } diff --git a/src/Discord.Net.Commands/Extensions/IEnumerableExtensions.cs b/src/Discord.Net.Commands/Extensions/IEnumerableExtensions.cs index b922dd90..49503107 100644 --- a/src/Discord.Net.Commands/Extensions/IEnumerableExtensions.cs +++ b/src/Discord.Net.Commands/Extensions/IEnumerableExtensions.cs @@ -19,4 +19,4 @@ namespace Discord.Commands } } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Commands/Extensions/MessageExtensions.cs b/src/Discord.Net.Commands/Extensions/MessageExtensions.cs index 9aa83d41..dd5defca 100644 --- a/src/Discord.Net.Commands/Extensions/MessageExtensions.cs +++ b/src/Discord.Net.Commands/Extensions/MessageExtensions.cs @@ -45,13 +45,17 @@ namespace Discord.Commands public static bool HasMentionPrefix(this IUserMessage msg, IUser user, ref int argPos) { var text = msg.Content; - if (string.IsNullOrEmpty(text) || text.Length <= 3 || text[0] != '<' || text[1] != '@') return false; + if (string.IsNullOrEmpty(text) || text.Length <= 3 || text[0] != '<' || text[1] != '@') + return false; int endPos = text.IndexOf('>'); - if (endPos == -1) return false; - if (text.Length < endPos + 2 || text[endPos + 1] != ' ') return false; //Must end in "> " + if (endPos == -1) + return false; + if (text.Length < endPos + 2 || text[endPos + 1] != ' ') + return false; //Must end in "> " - if (!MentionUtils.TryParseUser(text.Substring(0, endPos + 1), out ulong userId)) return false; + if (!MentionUtils.TryParseUser(text.Substring(0, endPos + 1), out ulong userId)) + return false; if (userId == user.Id) { argPos = endPos + 2; diff --git a/src/Discord.Net.Commands/Info/CommandInfo.cs b/src/Discord.Net.Commands/Info/CommandInfo.cs index 773c7c77..6a8b3f69 100644 --- a/src/Discord.Net.Commands/Info/CommandInfo.cs +++ b/src/Discord.Net.Commands/Info/CommandInfo.cs @@ -1,8 +1,8 @@ using Discord.Commands.Builders; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; -using System.Collections.Concurrent; using System.Diagnostics; using System.Linq; using System.Reflection; @@ -175,7 +175,7 @@ namespace Discord.Commands return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0, _commandService._quotationMarkAliasMap).ConfigureAwait(false); } - + public Task ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services) { if (!parseResult.IsSuccess) diff --git a/src/Discord.Net.Commands/Info/ModuleInfo.cs b/src/Discord.Net.Commands/Info/ModuleInfo.cs index 7b9959ef..68d9c735 100644 --- a/src/Discord.Net.Commands/Info/ModuleInfo.cs +++ b/src/Discord.Net.Commands/Info/ModuleInfo.cs @@ -1,8 +1,8 @@ +using Discord.Commands.Builders; using System; -using System.Linq; using System.Collections.Generic; using System.Collections.Immutable; -using Discord.Commands.Builders; +using System.Linq; namespace Discord.Commands { diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs index b2d6ba11..79ab1cc3 100644 --- a/src/Discord.Net.Commands/ModuleBase.cs +++ b/src/Discord.Net.Commands/ModuleBase.cs @@ -1,6 +1,6 @@ +using Discord.Commands.Builders; using System; using System.Threading.Tasks; -using Discord.Commands.Builders; namespace Discord.Commands { diff --git a/src/Discord.Net.Commands/Readers/EnumTypeReader.cs b/src/Discord.Net.Commands/Readers/EnumTypeReader.cs index 356d704c..ba843755 100644 --- a/src/Discord.Net.Commands/Readers/EnumTypeReader.cs +++ b/src/Discord.Net.Commands/Readers/EnumTypeReader.cs @@ -23,7 +23,7 @@ namespace Discord.Commands private readonly IReadOnlyDictionary _enumsByValue; private readonly Type _enumType; private readonly TryParseDelegate _tryParse; - + public EnumTypeReader(Type type, TryParseDelegate parser) { _enumType = type; @@ -33,7 +33,7 @@ namespace Discord.Commands var byValueBuilder = ImmutableDictionary.CreateBuilder(); foreach (var v in Enum.GetNames(_enumType)) - { + { var parsedValue = Enum.Parse(_enumType, v); byNameBuilder.Add(v.ToLower(), parsedValue); if (!byValueBuilder.ContainsKey((T)parsedValue)) diff --git a/src/Discord.Net.Commands/Readers/NamedArgumentTypeReader.cs b/src/Discord.Net.Commands/Readers/NamedArgumentTypeReader.cs index 0adf6104..65e8e279 100644 --- a/src/Discord.Net.Commands/Readers/NamedArgumentTypeReader.cs +++ b/src/Discord.Net.Commands/Readers/NamedArgumentTypeReader.cs @@ -116,7 +116,7 @@ namespace Discord.Commands argv = input.Substring(beginRead + 1, currentRead - beginRead - 1).Trim(); currentRead++; } - else + else argv = input.Substring(beginRead, currentRead - beginRead); return _tProps[currentParam]; diff --git a/src/Discord.Net.Commands/Readers/RoleTypeReader.cs b/src/Discord.Net.Commands/Readers/RoleTypeReader.cs index 4c9aaf4d..ebaa3666 100644 --- a/src/Discord.Net.Commands/Readers/RoleTypeReader.cs +++ b/src/Discord.Net.Commands/Readers/RoleTypeReader.cs @@ -27,7 +27,7 @@ namespace Discord.Commands //By Id (0.9) if (ulong.TryParse(input, NumberStyles.None, CultureInfo.InvariantCulture, out id)) - AddResult(results, context.Guild.GetRole(id) as T, 0.90f); + AddResult(results, context.Guild.GetRole(id) as T, 0.90f); //By Name (0.7-0.8) foreach (var role in roles.Where(x => string.Equals(input, x.Name, StringComparison.OrdinalIgnoreCase))) diff --git a/src/Discord.Net.Commands/Readers/UserTypeReader.cs b/src/Discord.Net.Commands/Readers/UserTypeReader.cs index c0104e34..8befa9d8 100644 --- a/src/Discord.Net.Commands/Readers/UserTypeReader.cs +++ b/src/Discord.Net.Commands/Readers/UserTypeReader.cs @@ -65,7 +65,7 @@ namespace Discord.Commands .Where(x => string.Equals(input, x.Username, StringComparison.OrdinalIgnoreCase)) .ForEachAsync(channelUser => AddResult(results, channelUser as T, channelUser.Username == input ? 0.65f : 0.55f)) .ConfigureAwait(false); - + foreach (var guildUser in guildUsers.Where(x => string.Equals(input, x.Username, StringComparison.OrdinalIgnoreCase))) AddResult(results, guildUser as T, guildUser.Username == input ? 0.60f : 0.50f); } diff --git a/src/Discord.Net.Commands/Results/MatchResult.cs b/src/Discord.Net.Commands/Results/MatchResult.cs index 5b9bfe72..45492f26 100644 --- a/src/Discord.Net.Commands/Results/MatchResult.cs +++ b/src/Discord.Net.Commands/Results/MatchResult.cs @@ -30,13 +30,13 @@ namespace Discord.Commands } public static MatchResult FromSuccess(CommandMatch match, IResult pipeline) - => new MatchResult(match,pipeline,null, null); + => new MatchResult(match, pipeline, null, null); public static MatchResult FromError(CommandError error, string reason) - => new MatchResult(null,null,error, reason); + => new MatchResult(null, null, error, reason); public static MatchResult FromError(Exception ex) => FromError(CommandError.Exception, ex.Message); public static MatchResult FromError(IResult result) - => new MatchResult(null, null,result.Error, result.ErrorReason); + => new MatchResult(null, null, result.Error, result.ErrorReason); public static MatchResult FromError(IResult pipeline, CommandError error, string reason) => new MatchResult(null, pipeline, error, reason); diff --git a/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs b/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs index 062af048..ec17be90 100644 --- a/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs +++ b/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs @@ -24,7 +24,7 @@ namespace Discord.Commands args[i] = GetMember(commands, services, parameters[i].ParameterType, typeInfo); var obj = InvokeConstructor(constructor, args, typeInfo); - foreach(var property in properties) + foreach (var property in properties) property.SetValue(obj, GetMember(commands, services, property.PropertyType, typeInfo)); return obj; }; diff --git a/src/Discord.Net.Core/Audio/AudioApplication.cs b/src/Discord.Net.Core/Audio/AudioApplication.cs index 276d934b..3d45966a 100644 --- a/src/Discord.Net.Core/Audio/AudioApplication.cs +++ b/src/Discord.Net.Core/Audio/AudioApplication.cs @@ -6,4 +6,4 @@ namespace Discord.Audio Music, Mixed } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Core/Audio/AudioInStream.cs b/src/Discord.Net.Core/Audio/AudioInStream.cs index 656c0bc4..b795097f 100644 --- a/src/Discord.Net.Core/Audio/AudioInStream.cs +++ b/src/Discord.Net.Core/Audio/AudioInStream.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; @@ -9,7 +9,7 @@ namespace Discord.Audio public abstract int AvailableFrames { get; } public override bool CanRead => true; - public override bool CanWrite => true; + public override bool CanWrite => true; public abstract Task ReadFrameAsync(CancellationToken cancelToken); public abstract bool TryReadFrame(CancellationToken cancelToken, out RTPFrame frame); diff --git a/src/Discord.Net.Core/Audio/AudioStream.cs b/src/Discord.Net.Core/Audio/AudioStream.cs index 2287d47f..ad2985fd 100644 --- a/src/Discord.Net.Core/Audio/AudioStream.cs +++ b/src/Discord.Net.Core/Audio/AudioStream.cs @@ -12,7 +12,7 @@ namespace Discord.Audio public override bool CanWrite => false; /// This stream does not accept headers. - public virtual void WriteHeader(ushort seq, uint timestamp, bool missed) => + public virtual void WriteHeader(ushort seq, uint timestamp, bool missed) => throw new InvalidOperationException("This stream does not accept headers."); public override void Write(byte[] buffer, int offset, int count) { @@ -31,7 +31,7 @@ namespace Discord.Audio /// /// Reading stream length is not supported. - public override long Length => + public override long Length => throw new NotSupportedException(); /// diff --git a/src/Discord.Net.Core/Audio/RTPFrame.cs b/src/Discord.Net.Core/Audio/RTPFrame.cs index 6254b717..3c5211a1 100644 --- a/src/Discord.Net.Core/Audio/RTPFrame.cs +++ b/src/Discord.Net.Core/Audio/RTPFrame.cs @@ -15,4 +15,4 @@ namespace Discord.Audio Missed = missed; } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Core/CDN.cs b/src/Discord.Net.Core/CDN.cs index c25b3583..b1ba99c4 100644 --- a/src/Discord.Net.Core/CDN.cs +++ b/src/Discord.Net.Core/CDN.cs @@ -146,10 +146,10 @@ namespace Discord /// public static string GetGuildBannerUrl(ulong guildId, string bannerId, ImageFormat format, ushort? size = null) { - if (string.IsNullOrEmpty(bannerId)) - return null; - string extension = FormatToExtension(format, bannerId); - return $"{DiscordConfig.CDNUrl}banners/{guildId}/{bannerId}.{extension}" + (size.HasValue ? $"?size={size}" : string.Empty); + if (string.IsNullOrEmpty(bannerId)) + return null; + string extension = FormatToExtension(format, bannerId); + return $"{DiscordConfig.CDNUrl}banners/{guildId}/{bannerId}.{extension}" + (size.HasValue ? $"?size={size}" : string.Empty); } /// /// Returns an emoji URL. diff --git a/src/Discord.Net.Core/DiscordConfig.cs b/src/Discord.Net.Core/DiscordConfig.cs index 09681daf..46ca1c50 100644 --- a/src/Discord.Net.Core/DiscordConfig.cs +++ b/src/Discord.Net.Core/DiscordConfig.cs @@ -175,23 +175,23 @@ namespace Discord /// internal bool DisplayInitialLog { get; set; } = true; - /// - /// Gets or sets whether or not rate-limits should use the system clock. - /// - /// - /// If set to false, we will use the X-RateLimit-Reset-After header - /// to determine when a rate-limit expires, rather than comparing the - /// X-RateLimit-Reset timestamp to the system time. - /// - /// This should only be changed to false if the system is known to have - /// a clock that is out of sync. Relying on the Reset-After header will - /// incur network lag. - /// - /// Regardless of this property, we still rely on the system's wall-clock - /// to determine if a bucket is rate-limited; we do not use any monotonic - /// clock. Your system will still need a stable clock. - /// - public bool UseSystemClock { get; set; } = true; + /// + /// Gets or sets whether or not rate-limits should use the system clock. + /// + /// + /// If set to false, we will use the X-RateLimit-Reset-After header + /// to determine when a rate-limit expires, rather than comparing the + /// X-RateLimit-Reset timestamp to the system time. + /// + /// This should only be changed to false if the system is known to have + /// a clock that is out of sync. Relying on the Reset-After header will + /// incur network lag. + /// + /// Regardless of this property, we still rely on the system's wall-clock + /// to determine if a bucket is rate-limited; we do not use any monotonic + /// clock. Your system will still need a stable clock. + /// + public bool UseSystemClock { get; set; } = true; /// /// Gets or sets whether or not the internal experation check uses the system date diff --git a/src/Discord.Net.Core/Entities/Activities/Game.cs b/src/Discord.Net.Core/Entities/Activities/Game.cs index 8891e142..eb8dc611 100644 --- a/src/Discord.Net.Core/Entities/Activities/Game.cs +++ b/src/Discord.Net.Core/Entities/Activities/Game.cs @@ -30,7 +30,7 @@ namespace Discord Flags = flags; Details = details; } - + /// Returns the name of the . public override string ToString() => Name; private string DebuggerDisplay => Name; diff --git a/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionMetadataProperties.cs b/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionMetadataProperties.cs index b88e57cc..e9ea5378 100644 --- a/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionMetadataProperties.cs +++ b/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionMetadataProperties.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using System; +using System.Collections.Generic; using System.Collections.Immutable; namespace Discord; diff --git a/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionProperties.cs b/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionProperties.cs index db68fada..667e5ec1 100644 --- a/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionProperties.cs +++ b/src/Discord.Net.Core/Entities/ApplicationRoleConnection/RoleConnectionProperties.cs @@ -38,7 +38,7 @@ public class RoleConnectionProperties get => _platformUsername; set { - if(value is not null) + if (value is not null) Preconditions.AtMost(value.Length, MaxPlatformUsernameLength, nameof(PlatformUsername), $"Platform username length must be less or equal to {MaxPlatformUsernameLength}"); _platformUsername = value; } @@ -103,7 +103,7 @@ public class RoleConnectionProperties internal RoleConnectionProperties AddMetadataRecord(string key, string value) { Metadata ??= new Dictionary(); - if(!Metadata.ContainsKey(key)) + if (!Metadata.ContainsKey(key)) Preconditions.AtMost(Metadata.Count + 1, MaxPlatformUsernameLength, nameof(Metadata), $"Metadata records count must be less or equal to {MaxMetadataRecords}"); _metadata[key] = value; @@ -126,7 +126,7 @@ public class RoleConnectionProperties /// /// Initializes a new instance of . /// - public RoleConnectionProperties() {} + public RoleConnectionProperties() { } /// /// Initializes a new with the data from provided . diff --git a/src/Discord.Net.Core/Entities/Channels/AudioChannelProperties.cs b/src/Discord.Net.Core/Entities/Channels/AudioChannelProperties.cs index 01d436f2..3b2cabcd 100644 --- a/src/Discord.Net.Core/Entities/Channels/AudioChannelProperties.cs +++ b/src/Discord.Net.Core/Entities/Channels/AudioChannelProperties.cs @@ -1,4 +1,4 @@ -namespace Discord +namespace Discord { /// /// Provides properties that are used to modify an with the specified changes. diff --git a/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs b/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs index 9de4b7b3..cd9c82d5 100644 --- a/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs @@ -172,7 +172,7 @@ namespace Discord public Task CreatePostWithFileAsync(string title, Stream stream, string filename, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageComponent components = null, - ISticker[] stickers = null, Embed[] embeds = null,MessageFlags flags = MessageFlags.None, ForumTag[] tags = null); + ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null); /// /// Creates a new post (thread) within the forum. diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs index 60a7c757..dc2441f6 100644 --- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs @@ -222,7 +222,7 @@ namespace Discord /// /// Paged collection of messages. /// - IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, + IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); /// /// Gets a collection of messages in this channel. @@ -263,7 +263,7 @@ namespace Discord /// /// Paged collection of messages. /// - IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, + IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); /// /// Gets a collection of messages in this channel. @@ -300,7 +300,7 @@ namespace Discord /// /// Paged collection of messages. /// - IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, + IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); /// /// Gets a collection of pinned messages in this channel. diff --git a/src/Discord.Net.Core/Entities/Emotes/Emote.cs b/src/Discord.Net.Core/Entities/Emotes/Emote.cs index 3a8cd745..71529732 100644 --- a/src/Discord.Net.Core/Entities/Emotes/Emote.cs +++ b/src/Discord.Net.Core/Entities/Emotes/Emote.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics; +using System.Globalization; namespace Discord { @@ -44,11 +44,14 @@ namespace Discord /// The object to compare with the current object. public override bool Equals(object other) { - if (other == null) return false; - if (other == this) return true; + if (other == null) + return false; + if (other == this) + return true; var otherEmote = other as Emote; - if (otherEmote == null) return false; + if (otherEmote == null) + return false; return Id == otherEmote.Id; } diff --git a/src/Discord.Net.Core/Entities/ForumTags/ForumTag.cs b/src/Discord.Net.Core/Entities/ForumTags/ForumTag.cs index afdb99bf..1527356a 100644 --- a/src/Discord.Net.Core/Entities/ForumTags/ForumTag.cs +++ b/src/Discord.Net.Core/Entities/ForumTags/ForumTag.cs @@ -45,7 +45,7 @@ namespace Discord } public override int GetHashCode() => (Id, Name, Emoji, IsModerated).GetHashCode(); - + public override bool Equals(object? obj) => obj is ForumTag tag && Equals(tag); diff --git a/src/Discord.Net.Core/Entities/ForumTags/ForumTagBuilder.cs b/src/Discord.Net.Core/Entities/ForumTags/ForumTagBuilder.cs index d8e88118..8ba3eff6 100644 --- a/src/Discord.Net.Core/Entities/ForumTags/ForumTagBuilder.cs +++ b/src/Discord.Net.Core/Entities/ForumTags/ForumTagBuilder.cs @@ -110,8 +110,8 @@ public class ForumTagBuilder public ForumTagBuilder(string name, ulong? id = null, bool isModerated = false, ulong? emoteId = null) { Name = name; - if(emoteId is not null) - Emoji = new Emote(emoteId.Value, null, false); + if (emoteId is not null) + Emoji = new Emote(emoteId.Value, null, false); IsModerated = isModerated; Id = id; } @@ -180,12 +180,12 @@ public class ForumTagBuilder => builder is not null && Id == builder.Id && Name == builder.Name && - (Emoji is Emoji emoji && builder.Emoji is Emoji otherEmoji && emoji.Equals(otherEmoji) || + (Emoji is Emoji emoji && builder.Emoji is Emoji otherEmoji && emoji.Equals(otherEmoji) || Emoji is Emote emote && builder.Emoji is Emote otherEmote && emote.Equals(otherEmote)) && IsModerated == builder.IsModerated; public static bool operator ==(ForumTagBuilder? left, ForumTagBuilder? right) - => left?.Equals(right) ?? right is null ; + => left?.Equals(right) ?? right is null; public static bool operator !=(ForumTagBuilder? left, ForumTagBuilder? right) => !(left == right); } diff --git a/src/Discord.Net.Core/Entities/Guilds/NsfwLevel.cs b/src/Discord.Net.Core/Entities/Guilds/NsfwLevel.cs index e3ac345d..7e7ce4f3 100644 --- a/src/Discord.Net.Core/Entities/Guilds/NsfwLevel.cs +++ b/src/Discord.Net.Core/Entities/Guilds/NsfwLevel.cs @@ -19,4 +19,4 @@ namespace Discord /// AgeRestricted = 3 } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannelProperties.cs b/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannelProperties.cs index c35470ef..e4931a9d 100644 --- a/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannelProperties.cs +++ b/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannelProperties.cs @@ -50,5 +50,5 @@ public class WelcomeScreenChannelProperties : ISnowflakeEntity /// A welcome screen channel to modify. /// A new instance of . public static WelcomeScreenChannelProperties FromWelcomeScreenChannel(WelcomeScreenChannel channel) - => new (channel.Id, channel.Description, channel.Emoji); + => new(channel.Id, channel.Description, channel.Emoji); } diff --git a/src/Discord.Net.Core/Entities/IApplication.cs b/src/Discord.Net.Core/Entities/IApplication.cs index d25e82c4..8027d8d3 100644 --- a/src/Discord.Net.Core/Entities/IApplication.cs +++ b/src/Discord.Net.Core/Entities/IApplication.cs @@ -34,7 +34,7 @@ namespace Discord /// /// Gets the icon URL of the application. /// - string IconUrl { get; } + string IconUrl { get; } /// /// Gets if the bot is public. /// diff --git a/src/Discord.Net.Core/Entities/Integrations/IIntegration.cs b/src/Discord.Net.Core/Entities/Integrations/IIntegration.cs index 304d5879..3fe83118 100644 --- a/src/Discord.Net.Core/Entities/Integrations/IIntegration.cs +++ b/src/Discord.Net.Core/Entities/Integrations/IIntegration.cs @@ -90,7 +90,7 @@ namespace Discord /// Gets the bot/OAuth2 application for a discord integration. /// IIntegrationApplication Application { get; } - + IGuild Guild { get; } ulong GuildId { get; } } diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs index 17e836e2..9ef18028 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs @@ -110,7 +110,7 @@ namespace Discord { foreach (var (locale, name) in value) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidOptionName(name); @@ -134,7 +134,7 @@ namespace Discord { foreach (var (locale, description) in value) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidOptionDescription(description); diff --git a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs index 0603a5a5..6b28a84f 100644 --- a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs +++ b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs @@ -45,7 +45,7 @@ namespace Discord public object Value { get => _value; - set + set { if (value is not string && !value.IsNumericType()) throw new ArgumentException($"{nameof(value)} must be a numeric type or a string!"); diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs index b7037cc6..406328ad 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs @@ -49,7 +49,7 @@ namespace Discord /// /// Gets or sets whether or not this command is age restricted. /// - public bool IsNsfw{ get; set; } = false; + public bool IsNsfw { get; set; } = false; /// /// Gets or sets the default permission required to use this slash command. @@ -118,7 +118,7 @@ namespace Discord foreach (var (locale, name) in nameLocalizations) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandName(name); @@ -159,7 +159,7 @@ namespace Discord /// Thrown if is an invalid locale string. public MessageCommandBuilder AddNameLocalization(string locale, string name) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandName(name); diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs index 85efc493..2fdfa7be 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs @@ -116,7 +116,7 @@ namespace Discord foreach (var (locale, name) in nameLocalizations) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandName(name); @@ -125,7 +125,7 @@ namespace Discord _nameLocalizations = new Dictionary(nameLocalizations); return this; } - + /// /// Sets whether or not this command can be used in dms. /// @@ -157,7 +157,7 @@ namespace Discord /// Thrown if is an invalid locale string. public UserCommandBuilder AddNameLocalization(string locale, string name) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandName(name); diff --git a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs index a2dbe0e5..833eec40 100644 --- a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs +++ b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs @@ -130,7 +130,7 @@ namespace Discord async Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null) { - using(var file = new FileAttachment(fileStream, fileName)) + using (var file = new FileAttachment(fileStream, fileName)) { await RespondWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); } @@ -249,7 +249,7 @@ namespace Discord async Task FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null) { - using(var file = new FileAttachment(fileStream, fileName)) + using (var file = new FileAttachment(fileStream, fileName)) { return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); } diff --git a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputComponent.cs b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputComponent.cs index d159df07..5a135220 100644 --- a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputComponent.cs +++ b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputComponent.cs @@ -46,7 +46,7 @@ namespace Discord /// public string Value { get; } - internal TextInputComponent(string customId, string label, string placeholder, int? minLength, int? maxLength, + internal TextInputComponent(string customId, string label, string placeholder, int? minLength, int? maxLength, TextInputStyle style, bool? required, string value) { CustomId = customId; diff --git a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputStyle.cs b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputStyle.cs index 72ea59b2..9bbcf687 100644 --- a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputStyle.cs +++ b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputStyle.cs @@ -1,4 +1,4 @@ -namespace Discord +namespace Discord { public enum TextInputStyle { diff --git a/src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs index 817f6941..963d4523 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs @@ -93,7 +93,7 @@ namespace Discord /// The input's maximum length. /// The input's style. /// The current builder. - public ModalBuilder AddTextInput(string label, string customId, TextInputStyle style = TextInputStyle.Short, + public ModalBuilder AddTextInput(string label, string customId, TextInputStyle style = TextInputStyle.Short, string placeholder = "", int? minLength = null, int? maxLength = null, bool? required = null, string value = null) => AddTextInput(new(label, customId, style, placeholder, minLength, maxLength, required, value)); @@ -204,7 +204,7 @@ namespace Discord /// The input's maximum length. /// The input's style. /// The current builder. - public ModalComponentBuilder WithTextInput(string label, string customId, TextInputStyle style = TextInputStyle.Short, + public ModalComponentBuilder WithTextInput(string label, string customId, TextInputStyle style = TextInputStyle.Short, string placeholder = null, int? minLength = null, int? maxLength = null, int row = 0, bool? required = null, string value = null) => WithTextInput(new(label, customId, style, placeholder, minLength, maxLength, required, value), row); @@ -263,6 +263,6 @@ namespace Discord /// /// A representing the builder. public ModalComponent Build() - => new (ActionRows?.Select(x => x.Build()).ToList()); + => new(ActionRows?.Select(x => x.Build()).ToList()); } } diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs index 295986bb..e9b78925 100644 --- a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs @@ -84,7 +84,7 @@ namespace Discord /// Gets or sets whether or not this command can be used in DMs. /// public bool IsDMEnabled { get; set; } = true; - + /// /// Gets or sets whether or not this command is age restricted. /// @@ -312,7 +312,7 @@ namespace Discord foreach (var (locale, name) in nameLocalizations) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandName(name); @@ -336,7 +336,7 @@ namespace Discord foreach (var (locale, description) in descriptionLocalizations) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandDescription(description); @@ -355,7 +355,7 @@ namespace Discord /// Thrown if is an invalid locale string. public SlashCommandBuilder AddNameLocalization(string locale, string name) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandName(name); @@ -375,7 +375,7 @@ namespace Discord /// Thrown if is an invalid locale string. public SlashCommandBuilder AddDescriptionLocalization(string locale, string description) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandDescription(description); @@ -549,7 +549,7 @@ namespace Discord if (isIntType && MaxValue != null && MaxValue % 1 != 0) throw new InvalidOperationException("MaxValue cannot have decimals on Integer command options."); - if(isStrType && MinLength is not null && MinLength < 0) + if (isStrType && MinLength is not null && MinLength < 0) throw new InvalidOperationException("MinLength cannot be smaller than 0."); if (isStrType && MaxLength is not null && MaxLength < 1) @@ -627,10 +627,10 @@ namespace Discord ChannelTypes = channelTypes, }; - if(nameLocalizations is not null) + if (nameLocalizations is not null) option.WithNameLocalizations(nameLocalizations); - if(descriptionLocalizations is not null) + if (descriptionLocalizations is not null) option.WithDescriptionLocalizations(descriptionLocalizations); return AddOption(option); @@ -749,7 +749,7 @@ namespace Discord Preconditions.AtLeast(name.Length, 1, nameof(name)); Preconditions.AtMost(name.Length, 100, nameof(name)); - if(value is string str) + if (value is string str) { Preconditions.AtLeast(str.Length, 1, nameof(value)); Preconditions.AtMost(str.Length, 100, nameof(value)); @@ -904,7 +904,7 @@ namespace Discord foreach (var (locale, name) in nameLocalizations) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandOptionName(name); @@ -928,7 +928,7 @@ namespace Discord foreach (var (locale, description) in descriptionLocalizations) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandOptionDescription(description); @@ -947,7 +947,7 @@ namespace Discord /// Thrown if is an invalid locale string. public SlashCommandOptionBuilder AddNameLocalization(string locale, string name) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandOptionName(name); @@ -967,7 +967,7 @@ namespace Discord /// Thrown if is an invalid locale string. public SlashCommandOptionBuilder AddDescriptionLocalization(string locale, string description) { - if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) + if (!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); EnsureValidCommandOptionDescription(description); diff --git a/src/Discord.Net.Core/Entities/Invites/InviteGuild.cs b/src/Discord.Net.Core/Entities/Invites/InviteGuild.cs index b290716e..3377e1ed 100644 --- a/src/Discord.Net.Core/Entities/Invites/InviteGuild.cs +++ b/src/Discord.Net.Core/Entities/Invites/InviteGuild.cs @@ -81,7 +81,7 @@ public class InviteGuild : ISnowflakeEntity /// A URL pointing to the guild's icon; if none is set. /// public string IconUrl => CDN.GetGuildIconUrl(Id, IconId); - + /// /// /// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild. @@ -127,17 +127,17 @@ public class InviteGuild : ISnowflakeEntity public WelcomeScreen WelcomeScreen { get; private set; } internal InviteGuild( - ulong id, - string name, - string description, - string splashId, - string bannerId, - GuildFeatures features, - string iconId, - VerificationLevel verificationLevel, - string vanityURLCode, - int premiumSubscriptionCount, - NsfwLevel nsfwLevel, + ulong id, + string name, + string description, + string splashId, + string bannerId, + GuildFeatures features, + string iconId, + VerificationLevel verificationLevel, + string vanityURLCode, + int premiumSubscriptionCount, + NsfwLevel nsfwLevel, WelcomeScreen welcomeScreen) { Id = id; diff --git a/src/Discord.Net.Core/Entities/Messages/AllowedMentionTypes.cs b/src/Discord.Net.Core/Entities/Messages/AllowedMentionTypes.cs index ecd872d8..7e8f05da 100644 --- a/src/Discord.Net.Core/Entities/Messages/AllowedMentionTypes.cs +++ b/src/Discord.Net.Core/Entities/Messages/AllowedMentionTypes.cs @@ -17,18 +17,18 @@ namespace Discord /// It will always be present and does not mean mentions will not be allowed. /// /// - None = 0, + None = 0, /// /// Controls role mentions. /// - Roles = 1, + Roles = 1, /// /// Controls user mentions. /// - Users = 2, + Users = 2, /// /// Controls @everyone and @here mentions. /// - Everyone = 4, + Everyone = 4, } } diff --git a/src/Discord.Net.Core/Entities/Messages/Embed.cs b/src/Discord.Net.Core/Entities/Messages/Embed.cs index c1478f56..bff33c7a 100644 --- a/src/Discord.Net.Core/Entities/Messages/Embed.cs +++ b/src/Discord.Net.Core/Entities/Messages/Embed.cs @@ -44,7 +44,7 @@ namespace Discord Type = type; Fields = ImmutableArray.Create(); } - internal Embed(EmbedType type, + internal Embed(EmbedType type, string title, string description, string url, @@ -52,10 +52,10 @@ namespace Discord Color? color, EmbedImage? image, EmbedVideo? video, - EmbedAuthor? author, - EmbedFooter? footer, - EmbedProvider? provider, - EmbedThumbnail? thumbnail, + EmbedAuthor? author, + EmbedFooter? footer, + EmbedProvider? provider, + EmbedThumbnail? thumbnail, ImmutableArray fields) { Type = type; @@ -128,7 +128,7 @@ namespace Discord { var hash = 17; hash = hash * 23 + (Type, Title, Description, Timestamp, Color, Image, Video, Author, Footer, Provider, Thumbnail).GetHashCode(); - foreach(var field in Fields) + foreach (var field in Fields) hash = hash * 23 + field.GetHashCode(); return hash; } diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs b/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs index 9b2a6adb..33d97654 100644 --- a/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs +++ b/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs @@ -1,9 +1,9 @@ +using Discord.Utils; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using Discord.Utils; -using Newtonsoft.Json; namespace Discord { @@ -50,7 +50,8 @@ namespace Discord get => _title; set { - if (value?.Length > MaxTitleLength) throw new ArgumentException(message: $"Title length must be less than or equal to {MaxTitleLength}.", paramName: nameof(Title)); + if (value?.Length > MaxTitleLength) + throw new ArgumentException(message: $"Title length must be less than or equal to {MaxTitleLength}.", paramName: nameof(Title)); _title = value; } } @@ -63,7 +64,8 @@ namespace Discord get => _description; set { - if (value?.Length > MaxDescriptionLength) throw new ArgumentException(message: $"Description length must be less than or equal to {MaxDescriptionLength}.", paramName: nameof(Description)); + if (value?.Length > MaxDescriptionLength) + throw new ArgumentException(message: $"Description length must be less than or equal to {MaxDescriptionLength}.", paramName: nameof(Description)); _description = value; } } @@ -100,8 +102,10 @@ namespace Discord get => _fields; set { - if (value == null) throw new ArgumentNullException(paramName: nameof(Fields), message: "Cannot set an embed builder's fields collection to null."); - if (value.Count > MaxFieldCount) throw new ArgumentException(message: $"Field count must be less than or equal to {MaxFieldCount}.", paramName: nameof(Fields)); + if (value == null) + throw new ArgumentNullException(paramName: nameof(Fields), message: "Cannot set an embed builder's fields collection to null."); + if (value.Count > MaxFieldCount) + throw new ArgumentException(message: $"Field count must be less than or equal to {MaxFieldCount}.", paramName: nameof(Fields)); _fields = value; } } @@ -470,7 +474,7 @@ namespace Discord if (!string.IsNullOrEmpty(Author.IconUrl)) UrlValidation.Validate(Author.IconUrl, true); } - if(Footer != null) + if (Footer != null) { if (!string.IsNullOrEmpty(Footer.IconUrl)) UrlValidation.Validate(Footer.IconUrl, true); @@ -564,8 +568,10 @@ namespace Discord get => _name; set { - if (string.IsNullOrWhiteSpace(value)) throw new ArgumentException(message: "Field name must not be null, empty or entirely whitespace.", paramName: nameof(Name)); - if (value.Length > MaxFieldNameLength) throw new ArgumentException(message: $"Field name length must be less than or equal to {MaxFieldNameLength}.", paramName: nameof(Name)); + if (string.IsNullOrWhiteSpace(value)) + throw new ArgumentException(message: "Field name must not be null, empty or entirely whitespace.", paramName: nameof(Name)); + if (value.Length > MaxFieldNameLength) + throw new ArgumentException(message: $"Field name length must be less than or equal to {MaxFieldNameLength}.", paramName: nameof(Name)); _name = value; } } @@ -587,8 +593,10 @@ namespace Discord set { var stringValue = value?.ToString(); - if (string.IsNullOrWhiteSpace(stringValue)) throw new ArgumentException(message: "Field value must not be null or empty.", paramName: nameof(Value)); - if (stringValue.Length > MaxFieldValueLength) throw new ArgumentException(message: $"Field value length must be less than or equal to {MaxFieldValueLength}.", paramName: nameof(Value)); + if (string.IsNullOrWhiteSpace(stringValue)) + throw new ArgumentException(message: "Field value must not be null or empty.", paramName: nameof(Value)); + if (stringValue.Length > MaxFieldValueLength) + throw new ArgumentException(message: $"Field value length must be less than or equal to {MaxFieldValueLength}.", paramName: nameof(Value)); _value = stringValue; } } @@ -704,7 +712,8 @@ namespace Discord get => _name; set { - if (value?.Length > MaxAuthorNameLength) throw new ArgumentException(message: $"Author name length must be less than or equal to {MaxAuthorNameLength}.", paramName: nameof(Name)); + if (value?.Length > MaxAuthorNameLength) + throw new ArgumentException(message: $"Author name length must be less than or equal to {MaxAuthorNameLength}.", paramName: nameof(Name)); _name = value; } } @@ -836,7 +845,8 @@ namespace Discord get => _text; set { - if (value?.Length > MaxFooterTextLength) throw new ArgumentException(message: $"Footer text length must be less than or equal to {MaxFooterTextLength}.", paramName: nameof(Text)); + if (value?.Length > MaxFooterTextLength) + throw new ArgumentException(message: $"Footer text length must be less than or equal to {MaxFooterTextLength}.", paramName: nameof(Text)); _text = value; } } diff --git a/src/Discord.Net.Core/Entities/Messages/IMessage.cs b/src/Discord.Net.Core/Entities/Messages/IMessage.cs index 8d5b24c5..c50f873a 100644 --- a/src/Discord.Net.Core/Entities/Messages/IMessage.cs +++ b/src/Discord.Net.Core/Entities/Messages/IMessage.cs @@ -79,7 +79,7 @@ namespace Discord /// Time of when the message was last edited; null if the message is never edited. /// DateTimeOffset? EditedTimestamp { get; } - + /// /// Gets the source channel of the message. /// @@ -197,7 +197,7 @@ namespace Discord /// A read-only collection of sticker item objects. /// IReadOnlyCollection Stickers { get; } - + /// /// Gets the flags related to this message. /// diff --git a/src/Discord.Net.Core/Entities/Messages/ITag.cs b/src/Discord.Net.Core/Entities/Messages/ITag.cs index 27824e6d..5d361698 100644 --- a/src/Discord.Net.Core/Entities/Messages/ITag.cs +++ b/src/Discord.Net.Core/Entities/Messages/ITag.cs @@ -1,4 +1,4 @@ -namespace Discord +namespace Discord { public interface ITag { diff --git a/src/Discord.Net.Core/Entities/Messages/Tag.cs b/src/Discord.Net.Core/Entities/Messages/Tag.cs index 06d995e7..9053480c 100644 --- a/src/Discord.Net.Core/Entities/Messages/Tag.cs +++ b/src/Discord.Net.Core/Entities/Messages/Tag.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; namespace Discord { diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs index 45e24b7f..8674399e 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs @@ -10,105 +10,105 @@ namespace Discord /// /// Allows creation of instant invites. /// - CreateInstantInvite = 0x00_00_00_00_01, + CreateInstantInvite = 0x00_00_00_00_01, /// /// Allows management and editing of channels. /// - ManageChannels = 0x00_00_00_00_10, + ManageChannels = 0x00_00_00_00_10, // Text /// /// Allows for the addition of reactions to messages. /// - AddReactions = 0x00_00_00_00_40, + AddReactions = 0x00_00_00_00_40, /// /// Allows guild members to view a channel, which includes reading messages in text channels. /// - ViewChannel = 0x00_00_00_04_00, + ViewChannel = 0x00_00_00_04_00, /// /// Allows for sending messages in a channel. /// - SendMessages = 0x00_00_00_08_00, + SendMessages = 0x00_00_00_08_00, /// /// Allows for sending of text-to-speech messages. /// - SendTTSMessages = 0x00_00_00_10_00, + SendTTSMessages = 0x00_00_00_10_00, /// /// Allows for deletion of other users messages. /// - ManageMessages = 0x00_00_00_20_00, + ManageMessages = 0x00_00_00_20_00, /// /// Allows links sent by users with this permission will be auto-embedded. /// - EmbedLinks = 0x00_00_00_40_00, + EmbedLinks = 0x00_00_00_40_00, /// /// Allows for uploading images and files. /// - AttachFiles = 0x00_00_00_80_00, + AttachFiles = 0x00_00_00_80_00, /// /// Allows for reading of message history. /// - ReadMessageHistory = 0x00_00_01_00_00, + ReadMessageHistory = 0x00_00_01_00_00, /// /// Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all /// online users in a channel. /// - MentionEveryone = 0x00_00_02_00_00, + MentionEveryone = 0x00_00_02_00_00, /// /// Allows the usage of custom emojis from other servers. /// - UseExternalEmojis = 0x00_00_04_00_00, + UseExternalEmojis = 0x00_00_04_00_00, // Voice /// /// Allows for joining of a voice channel. /// - Connect = 0x00_00_10_00_00, + Connect = 0x00_00_10_00_00, /// /// Allows for speaking in a voice channel. /// - Speak = 0x00_00_20_00_00, + Speak = 0x00_00_20_00_00, /// /// Allows for muting members in a voice channel. /// - MuteMembers = 0x00_00_40_00_00, + MuteMembers = 0x00_00_40_00_00, /// /// Allows for deafening of members in a voice channel. /// - DeafenMembers = 0x00_00_80_00_00, + DeafenMembers = 0x00_00_80_00_00, /// /// Allows for moving of members between voice channels. /// - MoveMembers = 0x00_01_00_00_00, + MoveMembers = 0x00_01_00_00_00, /// /// Allows for using voice-activity-detection in a voice channel. /// - UseVAD = 0x00_02_00_00_00, + UseVAD = 0x00_02_00_00_00, /// /// Allows for using priority speaker in a voice channel. /// - PrioritySpeaker = 0x00_00_00_01_00, + PrioritySpeaker = 0x00_00_00_01_00, /// /// Allows video streaming in a voice channel. /// - Stream = 0x00_00_00_02_00, + Stream = 0x00_00_00_02_00, // More General /// /// Allows management and editing of roles. /// - ManageRoles = 0x00_10_00_00_00, + ManageRoles = 0x00_10_00_00_00, /// /// Allows management and editing of webhooks. /// - ManageWebhooks = 0x00_20_00_00_00, + ManageWebhooks = 0x00_20_00_00_00, /// /// Allows management and editing of emojis. /// - ManageEmojis = 0x00_40_00_00_00, + ManageEmojis = 0x00_40_00_00_00, /// /// Allows members to use slash commands in text channels. @@ -118,12 +118,12 @@ namespace Discord /// /// Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) /// - RequestToSpeak = 0x01_00_00_00_00, + RequestToSpeak = 0x01_00_00_00_00, /// /// Allows for deleting and archiving threads, and viewing all private threads /// - ManageThreads = 0x04_00_00_00_00, + ManageThreads = 0x04_00_00_00_00, /// /// Allows for creating public threads. diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs index 299ff3bd..39d4f801 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs @@ -10,7 +10,7 @@ namespace Discord /// /// Allows creation of instant invites. /// - CreateInstantInvite = 0x00_00_00_01, + CreateInstantInvite = 0x00_00_00_01, /// /// Allows kicking members. /// @@ -18,7 +18,7 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - KickMembers = 0x00_00_00_02, + KickMembers = 0x00_00_00_02, /// /// Allows banning members. /// @@ -26,7 +26,7 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - BanMembers = 0x00_00_00_04, + BanMembers = 0x00_00_00_04, /// /// Allows all permissions and bypasses channel permission overwrites. /// @@ -34,7 +34,7 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - Administrator = 0x00_00_00_08, + Administrator = 0x00_00_00_08, /// /// Allows management and editing of channels. /// @@ -42,7 +42,7 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageChannels = 0x00_00_00_10, + ManageChannels = 0x00_00_00_10, /// /// Allows management and editing of the guild. /// @@ -50,33 +50,33 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageGuild = 0x00_00_00_20, + ManageGuild = 0x00_00_00_20, /// /// Allows for viewing of guild insights /// - ViewGuildInsights = 0x00_08_00_00, + ViewGuildInsights = 0x00_08_00_00, // Text - /// - /// Allows for the addition of reactions to messages. - /// - AddReactions = 0x00_00_00_40, - /// - /// Allows for viewing of audit logs. - /// - ViewAuditLog = 0x00_00_00_80, + /// + /// Allows for the addition of reactions to messages. + /// + AddReactions = 0x00_00_00_40, + /// + /// Allows for viewing of audit logs. + /// + ViewAuditLog = 0x00_00_00_80, /// /// Allows guild members to view a channel, which includes reading messages in text channels. /// - ViewChannel = 0x00_00_04_00, + ViewChannel = 0x00_00_04_00, /// /// Allows for sending messages in a channel /// - SendMessages = 0x00_00_08_00, - /// - /// Allows for sending of text-to-speech messages. - /// - SendTTSMessages = 0x00_00_10_00, + SendMessages = 0x00_00_08_00, + /// + /// Allows for sending of text-to-speech messages. + /// + SendTTSMessages = 0x00_00_10_00, /// /// Allows for deletion of other users messages. /// @@ -84,55 +84,55 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageMessages = 0x00_00_20_00, + ManageMessages = 0x00_00_20_00, /// /// Allows links sent by users with this permission will be auto-embedded. /// - EmbedLinks = 0x00_00_40_00, + EmbedLinks = 0x00_00_40_00, /// /// Allows for uploading images and files. /// - AttachFiles = 0x00_00_80_00, + AttachFiles = 0x00_00_80_00, /// /// Allows for reading of message history. /// - ReadMessageHistory = 0x00_01_00_00, + ReadMessageHistory = 0x00_01_00_00, /// /// Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all /// online users in a channel. /// - MentionEveryone = 0x00_02_00_00, + MentionEveryone = 0x00_02_00_00, /// /// Allows the usage of custom emojis from other servers. /// - UseExternalEmojis = 0x00_04_00_00, + UseExternalEmojis = 0x00_04_00_00, // Voice /// /// Allows for joining of a voice channel. /// - Connect = 0x00_10_00_00, + Connect = 0x00_10_00_00, /// /// Allows for speaking in a voice channel. /// - Speak = 0x00_20_00_00, + Speak = 0x00_20_00_00, /// /// Allows for muting members in a voice channel. /// - MuteMembers = 0x00_40_00_00, + MuteMembers = 0x00_40_00_00, /// /// Allows for deafening of members in a voice channel. /// - DeafenMembers = 0x00_80_00_00, + DeafenMembers = 0x00_80_00_00, /// /// Allows for moving of members between voice channels. /// - MoveMembers = 0x01_00_00_00, + MoveMembers = 0x01_00_00_00, /// /// Allows for using voice-activity-detection in a voice channel. /// - UseVAD = 0x02_00_00_00, + UseVAD = 0x02_00_00_00, /// /// Allows for using priority speaker in a voice channel. /// @@ -140,17 +140,17 @@ namespace Discord /// /// Allows video streaming in a voice channel. /// - Stream = 0x00_00_02_00, + Stream = 0x00_00_02_00, // General 2 /// /// Allows for modification of own nickname. /// - ChangeNickname = 0x04_00_00_00, + ChangeNickname = 0x04_00_00_00, /// /// Allows for modification of other users nicknames. /// - ManageNicknames = 0x08_00_00_00, + ManageNicknames = 0x08_00_00_00, /// /// Allows management and editing of roles. /// @@ -158,7 +158,7 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageRoles = 0x10_00_00_00, + ManageRoles = 0x10_00_00_00, /// /// Allows management and editing of webhooks. /// @@ -166,7 +166,7 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageWebhooks = 0x20_00_00_00, + ManageWebhooks = 0x20_00_00_00, /// /// Allows management and editing of emojis and stickers. /// @@ -182,7 +182,7 @@ namespace Discord /// /// Allows for requesting to speak in stage channels. /// - RequestToSpeak = 0x01_00_00_00_00, + RequestToSpeak = 0x01_00_00_00_00, /// /// Allows for creating, editing, and deleting guild scheduled events. /// @@ -194,7 +194,7 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageThreads = 0x04_00_00_00_00, + ManageThreads = 0x04_00_00_00_00, /// /// Allows for creating public threads. /// @@ -206,7 +206,7 @@ namespace Discord /// /// Allows the usage of custom stickers from other servers. /// - UseExternalStickers = 0x20_00_00_00_00, + UseExternalStickers = 0x20_00_00_00_00, /// /// Allows for sending messages in threads. /// diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs index 4c312590..93edab77 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs @@ -281,7 +281,7 @@ namespace Discord manageThreads: manageThreads, createPublicThreads: createPublicThreads, createPrivateThreads: createPrivateThreads, - useExternalStickers: useExternalStickers, + useExternalStickers: useExternalStickers, sendMessagesInThreads: sendMessagesInThreads, startEmbeddedActivities: startEmbeddedActivities, moderateMembers: moderateMembers) diff --git a/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs b/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs index 0e634ad1..d095e78e 100644 --- a/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs @@ -19,7 +19,7 @@ namespace Discord /// Gets a that grants all permissions for the given channel. /// /// Unknown channel type. - public static OverwritePermissions AllowAll(IChannel channel) + public static OverwritePermissions AllowAll(IChannel channel) => new OverwritePermissions(ChannelPermissions.All(channel).RawValue, 0); /// /// Gets a that denies all permissions for the given channel. @@ -116,24 +116,24 @@ namespace Discord private OverwritePermissions(ulong allowValue, ulong denyValue, PermValue? createInstantInvite = null, - PermValue? manageChannel = null, + PermValue? manageChannel = null, PermValue? addReactions = null, PermValue? viewChannel = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, - PermValue? manageMessages = null, + PermValue? manageMessages = null, PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, - PermValue? mentionEveryone = null, + PermValue? mentionEveryone = null, PermValue? useExternalEmojis = null, PermValue? connect = null, PermValue? speak = null, - PermValue? muteMembers = null, + PermValue? muteMembers = null, PermValue? deafenMembers = null, PermValue? moveMembers = null, PermValue? useVoiceActivation = null, - PermValue? manageRoles = null, + PermValue? manageRoles = null, PermValue? manageWebhooks = null, PermValue? prioritySpeaker = null, PermValue? stream = null, @@ -194,7 +194,7 @@ namespace Discord PermValue viewChannel = PermValue.Inherit, PermValue sendMessages = PermValue.Inherit, PermValue sendTTSMessages = PermValue.Inherit, - PermValue manageMessages = PermValue.Inherit, + PermValue manageMessages = PermValue.Inherit, PermValue embedLinks = PermValue.Inherit, PermValue attachFiles = PermValue.Inherit, PermValue readMessageHistory = PermValue.Inherit, @@ -221,11 +221,12 @@ namespace Discord PermValue useExternalStickers = PermValue.Inherit, PermValue sendMessagesInThreads = PermValue.Inherit, PermValue startEmbeddedActivities = PermValue.Inherit) - : this(0, 0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, - embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, + : this(0, 0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, + embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream, useSlashCommands, useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, - sendMessagesInThreads, startEmbeddedActivities) { } + sendMessagesInThreads, startEmbeddedActivities) + { } /// /// Initializes a new from the current one, changing the provided @@ -238,11 +239,11 @@ namespace Discord PermValue? viewChannel = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, - PermValue? manageMessages = null, + PermValue? manageMessages = null, PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, - PermValue? mentionEveryone = null, + PermValue? mentionEveryone = null, PermValue? useExternalEmojis = null, PermValue? connect = null, PermValue? speak = null, @@ -265,8 +266,8 @@ namespace Discord PermValue? useExternalStickers = null, PermValue? sendMessagesInThreads = null, PermValue? startEmbeddedActivities = null) - => new OverwritePermissions(AllowValue, DenyValue, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, - embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, + => new OverwritePermissions(AllowValue, DenyValue, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, + embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream, useSlashCommands, useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, sendMessagesInThreads, startEmbeddedActivities); @@ -305,7 +306,7 @@ namespace Discord } public override string ToString() => $"Allow {AllowValue}, Deny {DenyValue}"; - private string DebuggerDisplay => + private string DebuggerDisplay => $"Allow {string.Join(", ", ToAllowList())}, " + $"Deny {string.Join(", ", ToDenyList())}"; } diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs index 2f79450f..d260abf7 100644 --- a/src/Discord.Net.Core/Entities/Users/IUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IUser.cs @@ -10,7 +10,7 @@ namespace Discord /// /// Gets the identifier of this user's avatar. /// - string AvatarId { get; } + string AvatarId { get; } /// /// Gets the avatar URL for this user. /// diff --git a/src/Discord.Net.Core/Extensions/TaskCompletionSourceExtensions.cs b/src/Discord.Net.Core/Extensions/TaskCompletionSourceExtensions.cs index a5a715b4..d0247c85 100644 --- a/src/Discord.Net.Core/Extensions/TaskCompletionSourceExtensions.cs +++ b/src/Discord.Net.Core/Extensions/TaskCompletionSourceExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading.Tasks; namespace Discord diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs index 469957c4..f28c4790 100644 --- a/src/Discord.Net.Core/Extensions/UserExtensions.cs +++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs @@ -1,7 +1,7 @@ using System; -using System.Threading.Tasks; using System.Collections.Generic; using System.IO; +using System.Threading.Tasks; namespace Discord { diff --git a/src/Discord.Net.Core/Format.cs b/src/Discord.Net.Core/Format.cs index d9ad43f0..38998fc1 100644 --- a/src/Discord.Net.Core/Format.cs +++ b/src/Discord.Net.Core/Format.cs @@ -80,7 +80,7 @@ namespace Discord return result.ToString(); } - + /// /// Formats a string as a block quote. /// diff --git a/src/Discord.Net.Core/Logging/LogManager.cs b/src/Discord.Net.Core/Logging/LogManager.cs index a99c45b3..42be8fb8 100644 --- a/src/Discord.Net.Core/Logging/LogManager.cs +++ b/src/Discord.Net.Core/Logging/LogManager.cs @@ -34,7 +34,7 @@ namespace Discord.Logging try { if (severity <= Level) - await _messageEvent.InvokeAsync(new LogMessage(severity, source, message, ex)).ConfigureAwait(false); + await _messageEvent.InvokeAsync(new LogMessage(severity, source, message, ex)).ConfigureAwait(false); } catch { diff --git a/src/Discord.Net.Core/Logging/LogMessage.cs b/src/Discord.Net.Core/Logging/LogMessage.cs index 28d131a7..7f8e12d0 100644 --- a/src/Discord.Net.Core/Logging/LogMessage.cs +++ b/src/Discord.Net.Core/Logging/LogMessage.cs @@ -52,7 +52,7 @@ namespace Discord Message = message; Exception = exception; } - + public override string ToString() => ToString(); public string ToString(StringBuilder builder = null, bool fullException = true, bool prependTimestamp = true, DateTimeKind timestampKind = DateTimeKind.Local, int? padSource = 11) { @@ -60,9 +60,9 @@ namespace Discord string message = Message; string exMessage = fullException ? Exception?.ToString() : Exception?.Message; - int maxLength = 1 + + int maxLength = 1 + (prependTimestamp ? 8 : 0) + 1 + - (padSource.HasValue ? padSource.Value : sourceName?.Length ?? 0) + 1 + + (padSource.HasValue ? padSource.Value : sourceName?.Length ?? 0) + 1 + (message?.Length ?? 0) + (exMessage?.Length ?? 0) + 3; diff --git a/src/Discord.Net.Core/Net/ApplicationCommandException.cs b/src/Discord.Net.Core/Net/ApplicationCommandException.cs index 4b4890d1..acc075f4 100644 --- a/src/Discord.Net.Core/Net/ApplicationCommandException.cs +++ b/src/Discord.Net.Core/Net/ApplicationCommandException.cs @@ -9,7 +9,7 @@ namespace Discord.Net public ApplicationCommandException(HttpException httpError) : base(httpError.HttpCode, httpError.Request, httpError.DiscordCode, httpError.Reason, httpError.Errors.ToArray()) { - + } } } diff --git a/src/Discord.Net.Core/Net/BucketId.cs b/src/Discord.Net.Core/Net/BucketId.cs index 96281a0e..16e25730 100644 --- a/src/Discord.Net.Core/Net/BucketId.cs +++ b/src/Discord.Net.Core/Net/BucketId.cs @@ -99,7 +99,7 @@ namespace Discord.Net => Equals(obj as BucketId); public override int GetHashCode() - => IsHashBucket ? (BucketHash, string.Join("/", MajorParameters.Select(x => x.Value))).GetHashCode() : (HttpMethod, Endpoint).GetHashCode(); + => IsHashBucket ? (BucketHash, string.Join("/", MajorParameters.Select(x => x.Value))).GetHashCode() : (HttpMethod, Endpoint).GetHashCode(); public override string ToString() => GetBucketHash() ?? GetUniqueEndpoint(); @@ -113,6 +113,6 @@ namespace Discord.Net if (GetType() != other.GetType()) return false; return ToString() == other.ToString(); - } + } } } diff --git a/src/Discord.Net.Core/Net/Rest/RestClientProvider.cs b/src/Discord.Net.Core/Net/Rest/RestClientProvider.cs index 51a7eb61..719f429f 100644 --- a/src/Discord.Net.Core/Net/Rest/RestClientProvider.cs +++ b/src/Discord.Net.Core/Net/Rest/RestClientProvider.cs @@ -1,4 +1,4 @@ -namespace Discord.Net.Rest +namespace Discord.Net.Rest { public delegate IRestClient RestClientProvider(string baseUrl); } diff --git a/src/Discord.Net.Core/Net/Rest/RestResponse.cs b/src/Discord.Net.Core/Net/Rest/RestResponse.cs index 412ff4dc..f338fc78 100644 --- a/src/Discord.Net.Core/Net/Rest/RestResponse.cs +++ b/src/Discord.Net.Core/Net/Rest/RestResponse.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Net; diff --git a/src/Discord.Net.Core/Net/Udp/IUdpSocket.cs b/src/Discord.Net.Core/Net/Udp/IUdpSocket.cs index ed2881d1..b8276250 100644 --- a/src/Discord.Net.Core/Net/Udp/IUdpSocket.cs +++ b/src/Discord.Net.Core/Net/Udp/IUdpSocket.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; diff --git a/src/Discord.Net.Core/Net/Udp/UdpSocketProvider.cs b/src/Discord.Net.Core/Net/Udp/UdpSocketProvider.cs index 07fbd4f5..c6c2babc 100644 --- a/src/Discord.Net.Core/Net/Udp/UdpSocketProvider.cs +++ b/src/Discord.Net.Core/Net/Udp/UdpSocketProvider.cs @@ -1,4 +1,4 @@ -namespace Discord.Net.Udp +namespace Discord.Net.Udp { public delegate IUdpSocket UdpSocketProvider(); } diff --git a/src/Discord.Net.Core/Net/WebSockets/IWebSocketClient.cs b/src/Discord.Net.Core/Net/WebSockets/IWebSocketClient.cs index 6791af35..bc5e8ddc 100644 --- a/src/Discord.Net.Core/Net/WebSockets/IWebSocketClient.cs +++ b/src/Discord.Net.Core/Net/WebSockets/IWebSocketClient.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; diff --git a/src/Discord.Net.Core/Net/WebSockets/WebSocketProvider.cs b/src/Discord.Net.Core/Net/WebSockets/WebSocketProvider.cs index 88f46722..b0976dc4 100644 --- a/src/Discord.Net.Core/Net/WebSockets/WebSocketProvider.cs +++ b/src/Discord.Net.Core/Net/WebSockets/WebSocketProvider.cs @@ -1,4 +1,4 @@ -namespace Discord.Net.WebSockets +namespace Discord.Net.WebSockets { public delegate IWebSocketClient WebSocketProvider(); } diff --git a/src/Discord.Net.Core/RequestOptions.cs b/src/Discord.Net.Core/RequestOptions.cs index ef8dbf75..7db5b943 100644 --- a/src/Discord.Net.Core/RequestOptions.cs +++ b/src/Discord.Net.Core/RequestOptions.cs @@ -48,17 +48,17 @@ namespace Discord /// to all actions. /// public string AuditLogReason { get; set; } - /// - /// Gets or sets whether or not this request should use the system - /// clock for rate-limiting. Defaults to true. - /// - /// - /// This property can also be set in . - /// On a per-request basis, the system clock should only be disabled - /// when millisecond precision is especially important, and the - /// hosting system is known to have a desynced clock. - /// - public bool? UseSystemClock { get; set; } + /// + /// Gets or sets whether or not this request should use the system + /// clock for rate-limiting. Defaults to true. + /// + /// + /// This property can also be set in . + /// On a per-request basis, the system clock should only be disabled + /// when millisecond precision is especially important, and the + /// hosting system is known to have a desynced clock. + /// + public bool? UseSystemClock { get; set; } /// /// Gets or sets the callback to execute regarding ratelimits for this request. diff --git a/src/Discord.Net.Core/Utils/AsyncEvent.cs b/src/Discord.Net.Core/Utils/AsyncEvent.cs index 731489de..3a67a9f6 100644 --- a/src/Discord.Net.Core/Utils/AsyncEvent.cs +++ b/src/Discord.Net.Core/Utils/AsyncEvent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Threading.Tasks; @@ -34,7 +34,7 @@ namespace Discord } internal static class EventExtensions - { + { public static async Task InvokeAsync(this AsyncEvent> eventHandler) { var subscribers = eventHandler.Subscriptions; diff --git a/src/Discord.Net.Core/Utils/Cacheable.cs b/src/Discord.Net.Core/Utils/Cacheable.cs index 4aa76829..8e26ebd4 100644 --- a/src/Discord.Net.Core/Utils/Cacheable.cs +++ b/src/Discord.Net.Core/Utils/Cacheable.cs @@ -30,7 +30,7 @@ namespace Discord public TEntity Value { get; } private Func> DownloadFunc { get; } - internal Cacheable(TEntity value, TId id, bool hasValue , Func> downloadFunc) + internal Cacheable(TEntity value, TId id, bool hasValue, Func> downloadFunc) { Value = value; Id = id; diff --git a/src/Discord.Net.Core/Utils/Comparers.cs b/src/Discord.Net.Core/Utils/Comparers.cs index 59ee3e91..23753966 100644 --- a/src/Discord.Net.Core/Utils/Comparers.cs +++ b/src/Discord.Net.Core/Utils/Comparers.cs @@ -38,9 +38,9 @@ namespace Discord return (x, y) switch { (null, null) => true, - (null, _) => false, - (_, null) => false, - _ => x.Id.Equals(y.Id) + (null, _) => false, + (_, null) => false, + _ => x.Id.Equals(y.Id) }; } diff --git a/src/Discord.Net.Core/Utils/ConcurrentHashSet.cs b/src/Discord.Net.Core/Utils/ConcurrentHashSet.cs index 308f0846..b41d64ac 100644 --- a/src/Discord.Net.Core/Utils/ConcurrentHashSet.cs +++ b/src/Discord.Net.Core/Utils/ConcurrentHashSet.cs @@ -79,9 +79,9 @@ namespace Discord private static int DefaultConcurrencyLevel => ConcurrentHashSet.DefaultConcurrencyLevel; private volatile Tables _tables; - private readonly IEqualityComparer _comparer; + private readonly IEqualityComparer _comparer; private readonly bool _growLockArray; - private int _budget; + private int _budget; public int Count { @@ -149,19 +149,20 @@ namespace Discord } } - public ConcurrentHashSet() + public ConcurrentHashSet() : this(DefaultConcurrencyLevel, DefaultCapacity, true, EqualityComparer.Default) { } - public ConcurrentHashSet(int concurrencyLevel, int capacity) + public ConcurrentHashSet(int concurrencyLevel, int capacity) : this(concurrencyLevel, capacity, false, EqualityComparer.Default) { } - public ConcurrentHashSet(IEnumerable collection) + public ConcurrentHashSet(IEnumerable collection) : this(collection, EqualityComparer.Default) { } - public ConcurrentHashSet(IEqualityComparer comparer) + public ConcurrentHashSet(IEqualityComparer comparer) : this(DefaultConcurrencyLevel, DefaultCapacity, true, comparer) { } /// is null - public ConcurrentHashSet(IEnumerable collection, IEqualityComparer comparer) + public ConcurrentHashSet(IEnumerable collection, IEqualityComparer comparer) : this(comparer) { - if (collection == null) throw new ArgumentNullException(paramName: nameof(collection)); + if (collection == null) + throw new ArgumentNullException(paramName: nameof(collection)); InitializeFromCollection(collection); } /// @@ -170,18 +171,23 @@ namespace Discord public ConcurrentHashSet(int concurrencyLevel, IEnumerable collection, IEqualityComparer comparer) : this(concurrencyLevel, DefaultCapacity, false, comparer) { - if (collection == null) throw new ArgumentNullException(paramName: nameof(collection)); - if (comparer == null) throw new ArgumentNullException(paramName: nameof(comparer)); + if (collection == null) + throw new ArgumentNullException(paramName: nameof(collection)); + if (comparer == null) + throw new ArgumentNullException(paramName: nameof(comparer)); InitializeFromCollection(collection); - } + } public ConcurrentHashSet(int concurrencyLevel, int capacity, IEqualityComparer comparer) : this(concurrencyLevel, capacity, false, comparer) { } internal ConcurrentHashSet(int concurrencyLevel, int capacity, bool growLockArray, IEqualityComparer comparer) { - if (concurrencyLevel < 1) throw new ArgumentOutOfRangeException(paramName: nameof(concurrencyLevel)); - if (capacity < 0) throw new ArgumentOutOfRangeException(paramName: nameof(capacity)); - if (comparer == null) throw new ArgumentNullException(paramName: nameof(comparer)); - + if (concurrencyLevel < 1) + throw new ArgumentOutOfRangeException(paramName: nameof(concurrencyLevel)); + if (capacity < 0) + throw new ArgumentOutOfRangeException(paramName: nameof(capacity)); + if (comparer == null) + throw new ArgumentNullException(paramName: nameof(comparer)); + if (capacity < concurrencyLevel) capacity = concurrencyLevel; @@ -201,7 +207,8 @@ namespace Discord { foreach (var value in collection) { - if (value == null) throw new ArgumentNullException(paramName: "key"); + if (value == null) + throw new ArgumentNullException(paramName: "key"); if (!TryAddInternal(value, _comparer.GetHashCode(value), false)) throw new ArgumentException(); @@ -213,7 +220,8 @@ namespace Discord /// is null public bool ContainsKey(T value) { - if (value == null) throw new ArgumentNullException(paramName: "key"); + if (value == null) + throw new ArgumentNullException(paramName: "key"); return ContainsKeyInternal(value, _comparer.GetHashCode(value)); } private bool ContainsKeyInternal(T value, int hashcode) @@ -221,7 +229,7 @@ namespace Discord Tables tables = _tables; int bucketNo = GetBucket(hashcode, tables._buckets.Length); - + Node n = Volatile.Read(ref tables._buckets[bucketNo]); while (n != null) @@ -230,14 +238,15 @@ namespace Discord return true; n = n._next; } - + return false; } /// is null public bool TryAdd(T value) { - if (value == null) throw new ArgumentNullException(paramName: "key"); + if (value == null) + throw new ArgumentNullException(paramName: "key"); return TryAddInternal(value, _comparer.GetHashCode(value), true); } private bool TryAddInternal(T value, int hashcode, bool acquireLock) @@ -266,7 +275,8 @@ namespace Discord } Volatile.Write(ref tables._buckets[bucketNo], new Node(value, hashcode, tables._buckets[bucketNo])); - checked { tables._countPerLock[lockNo]++; } + checked + { tables._countPerLock[lockNo]++; } if (tables._countPerLock[lockNo] > _budget) resizeDesired = true; @@ -279,7 +289,7 @@ namespace Discord if (resizeDesired) GrowTable(tables); - + return true; } } @@ -287,9 +297,10 @@ namespace Discord /// is null public bool TryRemove(T value) { - if (value == null) throw new ArgumentNullException(paramName: "key"); + if (value == null) + throw new ArgumentNullException(paramName: "key"); return TryRemoveInternal(value); - } + } private bool TryRemoveInternal(T value) { int hashcode = _comparer.GetHashCode(value); @@ -325,7 +336,7 @@ namespace Discord return false; } } - + public void Clear() { int locksAcquired = 0; @@ -342,7 +353,7 @@ namespace Discord ReleaseLocks(0, locksAcquired); } } - + public IEnumerator GetEnumerator() { Node[] buckets = _tables._buckets; @@ -432,7 +443,8 @@ namespace Discord newBuckets[newBucketNo] = new Node(current._value, current._hashcode, newBuckets[newBucketNo]); - checked { newCountPerLock[newLockNo]++; } + checked + { newCountPerLock[newLockNo]++; } current = next; } @@ -471,6 +483,6 @@ namespace Discord { for (int i = fromInclusive; i < toExclusive; i++) Monitor.Exit(_tables._locks[i]); - } + } } } diff --git a/src/Discord.Net.Core/Utils/MentionUtils.cs b/src/Discord.Net.Core/Utils/MentionUtils.cs index 059df6b5..b17f9c33 100644 --- a/src/Discord.Net.Core/Utils/MentionUtils.cs +++ b/src/Discord.Net.Core/Utils/MentionUtils.cs @@ -61,7 +61,7 @@ namespace Discord text = text.Substring(3, text.Length - 4); //<@!123> else text = text.Substring(2, text.Length - 3); //<@123> - + if (ulong.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out userId)) return true; } @@ -87,7 +87,7 @@ namespace Discord if (text.Length >= 3 && text[0] == '<' && text[1] == '#' && text[text.Length - 1] == '>') { text = text.Substring(2, text.Length - 3); //<#123> - + if (ulong.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out channelId)) return true; } @@ -113,7 +113,7 @@ namespace Discord if (text.Length >= 4 && text[0] == '<' && text[1] == '@' && text[2] == '&' && text[text.Length - 1] == '>') { text = text.Substring(3, text.Length - 4); //<@&123> - + if (ulong.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out roleId)) return true; } @@ -136,27 +136,33 @@ namespace Discord switch (tag.Type) { case TagType.UserMention: - if (userHandling == TagHandling.Ignore) continue; + if (userHandling == TagHandling.Ignore) + continue; newText = ResolveUserMention(tag, userHandling); break; case TagType.ChannelMention: - if (channelHandling == TagHandling.Ignore) continue; + if (channelHandling == TagHandling.Ignore) + continue; newText = ResolveChannelMention(tag, channelHandling); break; case TagType.RoleMention: - if (roleHandling == TagHandling.Ignore) continue; + if (roleHandling == TagHandling.Ignore) + continue; newText = ResolveRoleMention(tag, roleHandling); break; case TagType.EveryoneMention: - if (everyoneHandling == TagHandling.Ignore) continue; + if (everyoneHandling == TagHandling.Ignore) + continue; newText = ResolveEveryoneMention(tag, everyoneHandling); break; case TagType.HereMention: - if (everyoneHandling == TagHandling.Ignore) continue; + if (everyoneHandling == TagHandling.Ignore) + continue; newText = ResolveHereMention(tag, everyoneHandling); break; case TagType.Emoji: - if (emojiHandling == TagHandling.Ignore) continue; + if (emojiHandling == TagHandling.Ignore) + continue; newText = ResolveEmoji(tag, emojiHandling); break; } diff --git a/src/Discord.Net.Core/Utils/Optional.cs b/src/Discord.Net.Core/Utils/Optional.cs index 985be924..0885e492 100644 --- a/src/Discord.Net.Core/Utils/Optional.cs +++ b/src/Discord.Net.Core/Utils/Optional.cs @@ -36,8 +36,10 @@ namespace Discord public override bool Equals(object other) { - if (!IsSpecified) return other == null; - if (other == null) return false; + if (!IsSpecified) + return other == null; + if (other == null) + return false; return _value.Equals(other); } public override int GetHashCode() => IsSpecified ? _value.GetHashCode() : 0; diff --git a/src/Discord.Net.Core/Utils/Paging/Page.cs b/src/Discord.Net.Core/Utils/Paging/Page.cs index 996d0ac6..d94e1d54 100644 --- a/src/Discord.Net.Core/Utils/Paging/Page.cs +++ b/src/Discord.Net.Core/Utils/Paging/Page.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Discord.Net.Core/Utils/Paging/PageInfo.cs b/src/Discord.Net.Core/Utils/Paging/PageInfo.cs index 3b49225f..65813df9 100644 --- a/src/Discord.Net.Core/Utils/Paging/PageInfo.cs +++ b/src/Discord.Net.Core/Utils/Paging/PageInfo.cs @@ -1,4 +1,4 @@ -namespace Discord +namespace Discord { internal class PageInfo { diff --git a/src/Discord.Net.Core/Utils/Paging/PagedEnumerator.cs b/src/Discord.Net.Core/Utils/Paging/PagedEnumerator.cs index 84209902..2b85735b 100644 --- a/src/Discord.Net.Core/Utils/Paging/PagedEnumerator.cs +++ b/src/Discord.Net.Core/Utils/Paging/PagedEnumerator.cs @@ -72,7 +72,7 @@ namespace Discord return true; } - + public ValueTask DisposeAsync() { Current = null; diff --git a/src/Discord.Net.Core/Utils/Permissions.cs b/src/Discord.Net.Core/Utils/Permissions.cs index fd0fe091..1bc3bf65 100644 --- a/src/Discord.Net.Core/Utils/Permissions.cs +++ b/src/Discord.Net.Core/Utils/Permissions.cs @@ -147,7 +147,7 @@ namespace Discord //Give/Take User permissions perms = channel.GetPermissionOverwrite(user); if (perms != null) - resolvedPermissions = (resolvedPermissions & ~perms.Value.DenyValue) | perms.Value.AllowValue; + resolvedPermissions = (resolvedPermissions & ~perms.Value.DenyValue) | perms.Value.AllowValue; if (channel is ITextChannel) { diff --git a/src/Discord.Net.Core/Utils/Preconditions.cs b/src/Discord.Net.Core/Utils/Preconditions.cs index fb855f92..37bd82df 100644 --- a/src/Discord.Net.Core/Utils/Preconditions.cs +++ b/src/Discord.Net.Core/Utils/Preconditions.cs @@ -12,8 +12,10 @@ namespace Discord private static ArgumentNullException CreateNotNullException(string name, string msg) { - if (msg == null) return new ArgumentNullException(paramName: name); - else return new ArgumentNullException(paramName: name, message: msg); + if (msg == null) + return new ArgumentNullException(paramName: name); + else + return new ArgumentNullException(paramName: name, message: msg); } #endregion @@ -26,8 +28,10 @@ namespace Discord /// must not be . public static void NotNullOrEmpty(string obj, string name, string msg = null) { - if (obj == null) throw CreateNotNullException(name, msg); - if (obj.Length == 0) throw CreateNotEmptyException(name, msg); + if (obj == null) + throw CreateNotNullException(name, msg); + if (obj.Length == 0) + throw CreateNotEmptyException(name, msg); } /// cannot be blank. /// must not be . @@ -35,16 +39,20 @@ namespace Discord { if (obj.IsSpecified) { - if (obj.Value == null) throw CreateNotNullException(name, msg); - if (obj.Value.Length == 0) throw CreateNotEmptyException(name, msg); + if (obj.Value == null) + throw CreateNotNullException(name, msg); + if (obj.Value.Length == 0) + throw CreateNotEmptyException(name, msg); } } /// cannot be blank. /// must not be . public static void NotNullOrWhitespace(string obj, string name, string msg = null) { - if (obj == null) throw CreateNotNullException(name, msg); - if (obj.Trim().Length == 0) throw CreateNotEmptyException(name, msg); + if (obj == null) + throw CreateNotNullException(name, msg); + if (obj.Trim().Length == 0) + throw CreateNotEmptyException(name, msg); } /// cannot be blank. /// must not be . @@ -52,8 +60,10 @@ namespace Discord { if (obj.IsSpecified) { - if (obj.Value == null) throw CreateNotNullException(name, msg); - if (obj.Value.Trim().Length == 0) throw CreateNotEmptyException(name, msg); + if (obj.Value == null) + throw CreateNotNullException(name, msg); + if (obj.Value.Trim().Length == 0) + throw CreateNotEmptyException(name, msg); } } @@ -282,7 +292,8 @@ namespace Discord var minimum = SnowflakeUtils.ToSnowflake(DateTimeOffset.UtcNow.Subtract(TimeSpan.FromDays(14))); for (var i = 0; i < collection.Length; i++) { - if (collection[i] == 0) continue; + if (collection[i] == 0) + continue; if (collection[i] <= minimum) throw new ArgumentOutOfRangeException(name, "Messages must be younger than two weeks old."); } diff --git a/src/Discord.Net.Interactions/Attributes/ChannelTypesAttribute.cs b/src/Discord.Net.Interactions/Attributes/ChannelTypesAttribute.cs index 01364137..1f498e34 100644 --- a/src/Discord.Net.Interactions/Attributes/ChannelTypesAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/ChannelTypesAttribute.cs @@ -19,7 +19,7 @@ namespace Discord.Interactions /// Specify the target channel types for a option. /// /// The allowed channel types for this option. - public ChannelTypesAttribute (params ChannelType[] channelTypes) + public ChannelTypesAttribute(params ChannelType[] channelTypes) { if (channelTypes is null) throw new ArgumentNullException(nameof(channelTypes)); diff --git a/src/Discord.Net.Interactions/Attributes/ChoiceAttribute.cs b/src/Discord.Net.Interactions/Attributes/ChoiceAttribute.cs index 200c75f9..b20c575d 100644 --- a/src/Discord.Net.Interactions/Attributes/ChoiceAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/ChoiceAttribute.cs @@ -23,7 +23,7 @@ namespace Discord.Interactions /// public object Value { get; } - private ChoiceAttribute (string name) + private ChoiceAttribute(string name) { Name = name; } @@ -33,7 +33,7 @@ namespace Discord.Interactions /// /// Name of the choice. /// Predefined value of the choice. - public ChoiceAttribute (string name, string value) : this(name) + public ChoiceAttribute(string name, string value) : this(name) { Type = SlashCommandChoiceType.String; Value = value; @@ -44,7 +44,7 @@ namespace Discord.Interactions /// /// Name of the choice. /// Predefined value of the choice. - public ChoiceAttribute (string name, int value) : this(name) + public ChoiceAttribute(string name, int value) : this(name) { Type = SlashCommandChoiceType.Integer; Value = value; @@ -55,7 +55,7 @@ namespace Discord.Interactions /// /// Name of the choice. /// Predefined value of the choice. - public ChoiceAttribute (string name, double value) : this(name) + public ChoiceAttribute(string name, double value) : this(name) { Type = SlashCommandChoiceType.Number; Value = value; diff --git a/src/Discord.Net.Interactions/Attributes/Commands/ComponentInteractionAttribute.cs b/src/Discord.Net.Interactions/Attributes/Commands/ComponentInteractionAttribute.cs index a6b8d2c2..e615a9be 100644 --- a/src/Discord.Net.Interactions/Attributes/Commands/ComponentInteractionAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/Commands/ComponentInteractionAttribute.cs @@ -43,7 +43,7 @@ namespace Discord.Interactions /// String to compare the Message Component CustomIDs with. /// If s will be ignored while creating this command and this method will be treated as a top level command. /// Set the run mode of the command. - public ComponentInteractionAttribute (string customId, bool ignoreGroupNames = false, RunMode runMode = RunMode.Default) + public ComponentInteractionAttribute(string customId, bool ignoreGroupNames = false, RunMode runMode = RunMode.Default) { CustomId = customId; IgnoreGroupNames = ignoreGroupNames; diff --git a/src/Discord.Net.Interactions/Attributes/Commands/ContextCommandAttribute.cs b/src/Discord.Net.Interactions/Attributes/Commands/ContextCommandAttribute.cs index fd303a45..71442067 100644 --- a/src/Discord.Net.Interactions/Attributes/Commands/ContextCommandAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/Commands/ContextCommandAttribute.cs @@ -24,13 +24,13 @@ namespace Discord.Interactions /// public RunMode RunMode { get; } - internal ContextCommandAttribute (string name, ApplicationCommandType commandType, RunMode runMode = RunMode.Default) + internal ContextCommandAttribute(string name, ApplicationCommandType commandType, RunMode runMode = RunMode.Default) { Name = name; CommandType = commandType; RunMode = runMode; } - internal virtual void CheckMethodDefinition (MethodInfo methodInfo) { } + internal virtual void CheckMethodDefinition(MethodInfo methodInfo) { } } } diff --git a/src/Discord.Net.Interactions/Attributes/Commands/MessageCommandAttribute.cs b/src/Discord.Net.Interactions/Attributes/Commands/MessageCommandAttribute.cs index 93d010c8..d8f4b9b4 100644 --- a/src/Discord.Net.Interactions/Attributes/Commands/MessageCommandAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/Commands/MessageCommandAttribute.cs @@ -16,9 +16,9 @@ namespace Discord.Interactions /// Register a method as a Message Context Command. /// /// Name of the context command. - public MessageCommandAttribute (string name) : base(name, ApplicationCommandType.Message) { } + public MessageCommandAttribute(string name) : base(name, ApplicationCommandType.Message) { } - internal override void CheckMethodDefinition (MethodInfo methodInfo) + internal override void CheckMethodDefinition(MethodInfo methodInfo) { var parameters = methodInfo.GetParameters(); diff --git a/src/Discord.Net.Interactions/Attributes/Commands/ModalInteractionAttribute.cs b/src/Discord.Net.Interactions/Attributes/Commands/ModalInteractionAttribute.cs index 0e79952f..c88ed7ab 100644 --- a/src/Discord.Net.Interactions/Attributes/Commands/ModalInteractionAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/Commands/ModalInteractionAttribute.cs @@ -17,7 +17,7 @@ namespace Discord.Interactions /// Gets the string to compare the Modal CustomIDs with. /// public string CustomId { get; } - + /// /// Gets if s will be ignored while creating this command and this method will be treated as a top level command. /// diff --git a/src/Discord.Net.Interactions/Attributes/Commands/SlashCommandAttribute.cs b/src/Discord.Net.Interactions/Attributes/Commands/SlashCommandAttribute.cs index aebc366a..4e2f2012 100644 --- a/src/Discord.Net.Interactions/Attributes/Commands/SlashCommandAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/Commands/SlashCommandAttribute.cs @@ -38,7 +38,7 @@ namespace Discord.Interactions /// Description of the command. /// If , s will be ignored while creating this command and this method will be treated as a top level command. /// Set the run mode of the command. - public SlashCommandAttribute (string name, string description, bool ignoreGroupNames = false, RunMode runMode = RunMode.Default) + public SlashCommandAttribute(string name, string description, bool ignoreGroupNames = false, RunMode runMode = RunMode.Default) { Name = name; Description = description; diff --git a/src/Discord.Net.Interactions/Attributes/Commands/UserCommandAttribute.cs b/src/Discord.Net.Interactions/Attributes/Commands/UserCommandAttribute.cs index 592dcf5c..60a493fd 100644 --- a/src/Discord.Net.Interactions/Attributes/Commands/UserCommandAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/Commands/UserCommandAttribute.cs @@ -16,9 +16,9 @@ namespace Discord.Interactions /// Register a command as a User Context Command. /// /// Name of this User Context Command. - public UserCommandAttribute (string name) : base(name, ApplicationCommandType.User) { } + public UserCommandAttribute(string name) : base(name, ApplicationCommandType.User) { } - internal override void CheckMethodDefinition (MethodInfo methodInfo) + internal override void CheckMethodDefinition(MethodInfo methodInfo) { var parameters = methodInfo.GetParameters(); diff --git a/src/Discord.Net.Interactions/Attributes/DefaultPermissionAttribute.cs b/src/Discord.Net.Interactions/Attributes/DefaultPermissionAttribute.cs index 2e03dfac..99d73ea7 100644 --- a/src/Discord.Net.Interactions/Attributes/DefaultPermissionAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/DefaultPermissionAttribute.cs @@ -18,7 +18,7 @@ namespace Discord.Interactions /// Set the default permission of a Slash Command. /// /// if the users are allowed to use this command. - public DefaultPermissionAttribute (bool isDefaultPermission) + public DefaultPermissionAttribute(bool isDefaultPermission) { IsDefaultPermission = isDefaultPermission; } diff --git a/src/Discord.Net.Interactions/Attributes/GroupAttribute.cs b/src/Discord.Net.Interactions/Attributes/GroupAttribute.cs index 7014c35a..e3d892c6 100644 --- a/src/Discord.Net.Interactions/Attributes/GroupAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/GroupAttribute.cs @@ -26,7 +26,7 @@ namespace Discord.Interactions /// /// Name of the group. /// Description of the group. - public GroupAttribute (string name, string description) + public GroupAttribute(string name, string description) { Name = name; Description = description; diff --git a/src/Discord.Net.Interactions/Attributes/ParameterPreconditionAttribute.cs b/src/Discord.Net.Interactions/Attributes/ParameterPreconditionAttribute.cs index 22b9dc42..2687aa9d 100644 --- a/src/Discord.Net.Interactions/Attributes/ParameterPreconditionAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/ParameterPreconditionAttribute.cs @@ -28,7 +28,7 @@ namespace Discord.Interactions /// The parameter of the command being checked against. /// The raw value of the parameter. /// The service collection used for dependency injection. - public abstract Task CheckRequirementsAsync (IInteractionContext context, IParameterInfo parameterInfo, object value, + public abstract Task CheckRequirementsAsync(IInteractionContext context, IParameterInfo parameterInfo, object value, IServiceProvider services); } } diff --git a/src/Discord.Net.Interactions/Attributes/PreconditionAttribute.cs b/src/Discord.Net.Interactions/Attributes/PreconditionAttribute.cs index 37c9de2c..917538fb 100644 --- a/src/Discord.Net.Interactions/Attributes/PreconditionAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/PreconditionAttribute.cs @@ -37,6 +37,6 @@ namespace Discord.Interactions /// The context of the command. /// The command being executed. /// The service collection used for dependency injection. - public abstract Task CheckRequirementsAsync (IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services); + public abstract Task CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services); } } diff --git a/src/Discord.Net.Interactions/Attributes/SummaryAttribute.cs b/src/Discord.Net.Interactions/Attributes/SummaryAttribute.cs index 69456925..4bbc9f44 100644 --- a/src/Discord.Net.Interactions/Attributes/SummaryAttribute.cs +++ b/src/Discord.Net.Interactions/Attributes/SummaryAttribute.cs @@ -23,7 +23,7 @@ namespace Discord.Interactions /// /// Name of the parameter. /// Description of the parameter. - public SummaryAttribute (string name = null, string description = null) + public SummaryAttribute(string name = null, string description = null) { Name = name; Description = description; diff --git a/src/Discord.Net.Interactions/Builders/Commands/CommandBuilder.cs b/src/Discord.Net.Interactions/Builders/Commands/CommandBuilder.cs index d7f90678..2826f967 100644 --- a/src/Discord.Net.Interactions/Builders/Commands/CommandBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Commands/CommandBuilder.cs @@ -53,7 +53,7 @@ namespace Discord.Interactions.Builders /// IReadOnlyList ICommandBuilder.Parameters => Parameters; - internal CommandBuilder (ModuleBuilder module) + internal CommandBuilder(ModuleBuilder module) { _attributes = new List(); _preconditions = new List(); @@ -62,7 +62,7 @@ namespace Discord.Interactions.Builders Module = module; } - protected CommandBuilder (ModuleBuilder module, string name, ExecuteCallback callback) : this(module) + protected CommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback) : this(module) { Name = name; Callback = callback; @@ -75,7 +75,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public TBuilder WithName (string name) + public TBuilder WithName(string name) { Name = name; return Instance; @@ -88,7 +88,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public TBuilder WithMethodName (string name) + public TBuilder WithMethodName(string name) { MethodName = name; return Instance; @@ -101,7 +101,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public TBuilder WithAttributes (params Attribute[] attributes) + public TBuilder WithAttributes(params Attribute[] attributes) { _attributes.AddRange(attributes); return Instance; @@ -114,7 +114,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public TBuilder SetRunMode (RunMode runMode) + public TBuilder SetRunMode(RunMode runMode) { RunMode = runMode; return Instance; @@ -127,7 +127,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public TBuilder WithNameAsRegex (bool value) + public TBuilder WithNameAsRegex(bool value) { TreatNameAsRegex = value; return Instance; @@ -140,7 +140,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public TBuilder AddParameters (params TParamBuilder[] parameters) + public TBuilder AddParameters(params TParamBuilder[] parameters) { _parameters.AddRange(parameters); return Instance; @@ -153,30 +153,30 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public TBuilder WithPreconditions (params PreconditionAttribute[] preconditions) + public TBuilder WithPreconditions(params PreconditionAttribute[] preconditions) { _preconditions.AddRange(preconditions); return Instance; } /// - public abstract TBuilder AddParameter (Action configure); + public abstract TBuilder AddParameter(Action configure); - internal abstract TInfo Build (ModuleInfo module, InteractionService commandService); + internal abstract TInfo Build(ModuleInfo module, InteractionService commandService); //ICommandBuilder /// - ICommandBuilder ICommandBuilder.WithName (string name) => + ICommandBuilder ICommandBuilder.WithName(string name) => WithName(name); /// - ICommandBuilder ICommandBuilder.WithMethodName (string name) => + ICommandBuilder ICommandBuilder.WithMethodName(string name) => WithMethodName(name); - ICommandBuilder ICommandBuilder.WithAttributes (params Attribute[] attributes) => + ICommandBuilder ICommandBuilder.WithAttributes(params Attribute[] attributes) => WithAttributes(attributes); /// - ICommandBuilder ICommandBuilder.SetRunMode (RunMode runMode) => + ICommandBuilder ICommandBuilder.SetRunMode(RunMode runMode) => SetRunMode(runMode); /// @@ -184,11 +184,11 @@ namespace Discord.Interactions.Builders WithNameAsRegex(value); /// - ICommandBuilder ICommandBuilder.AddParameters (params IParameterBuilder[] parameters) => + ICommandBuilder ICommandBuilder.AddParameters(params IParameterBuilder[] parameters) => AddParameters(parameters as TParamBuilder); /// - ICommandBuilder ICommandBuilder.WithPreconditions (params PreconditionAttribute[] preconditions) => + ICommandBuilder ICommandBuilder.WithPreconditions(params PreconditionAttribute[] preconditions) => WithPreconditions(preconditions); } } diff --git a/src/Discord.Net.Interactions/Builders/Commands/ComponentCommandBuilder.cs b/src/Discord.Net.Interactions/Builders/Commands/ComponentCommandBuilder.cs index dd857498..f53e2f35 100644 --- a/src/Discord.Net.Interactions/Builders/Commands/ComponentCommandBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Commands/ComponentCommandBuilder.cs @@ -9,7 +9,7 @@ namespace Discord.Interactions.Builders { protected override ComponentCommandBuilder Instance => this; - internal ComponentCommandBuilder (ModuleBuilder module) : base(module) { } + internal ComponentCommandBuilder(ModuleBuilder module) : base(module) { } /// /// Initializes a new . @@ -17,7 +17,7 @@ namespace Discord.Interactions.Builders /// Parent module of this command. /// Name of this command. /// Execution callback of this command. - public ComponentCommandBuilder (ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback) { } + public ComponentCommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback) { } /// /// Adds a command parameter to the parameters collection. @@ -26,7 +26,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public override ComponentCommandBuilder AddParameter (Action configure) + public override ComponentCommandBuilder AddParameter(Action configure) { var parameter = new ComponentCommandParameterBuilder(this); configure(parameter); @@ -34,7 +34,7 @@ namespace Discord.Interactions.Builders return this; } - internal override ComponentCommandInfo Build (ModuleInfo module, InteractionService commandService) => + internal override ComponentCommandInfo Build(ModuleInfo module, InteractionService commandService) => new ComponentCommandInfo(this, module, commandService); } } diff --git a/src/Discord.Net.Interactions/Builders/Commands/ContextCommandBuilder.cs b/src/Discord.Net.Interactions/Builders/Commands/ContextCommandBuilder.cs index ce6d8b50..ee08d879 100644 --- a/src/Discord.Net.Interactions/Builders/Commands/ContextCommandBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Commands/ContextCommandBuilder.cs @@ -35,7 +35,7 @@ namespace Discord.Interactions.Builders /// public GuildPermission? DefaultMemberPermissions { get; set; } = null; - internal ContextCommandBuilder (ModuleBuilder module) : base(module) { } + internal ContextCommandBuilder(ModuleBuilder module) : base(module) { } /// /// Initializes a new . @@ -43,7 +43,7 @@ namespace Discord.Interactions.Builders /// Parent module of this command. /// Name of this command. /// Execution callback of this command. - public ContextCommandBuilder (ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback) { } + public ContextCommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback) { } /// /// Sets . @@ -52,7 +52,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ContextCommandBuilder SetType (ApplicationCommandType commandType) + public ContextCommandBuilder SetType(ApplicationCommandType commandType) { CommandType = commandType; return this; @@ -66,7 +66,7 @@ namespace Discord.Interactions.Builders /// The builder instance. /// [Obsolete($"To be deprecated soon, use {nameof(SetEnabledInDm)} and {nameof(WithDefaultMemberPermissions)} instead.")] - public ContextCommandBuilder SetDefaultPermission (bool defaultPermision) + public ContextCommandBuilder SetDefaultPermission(bool defaultPermision) { DefaultPermission = defaultPermision; return this; @@ -79,7 +79,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public override ContextCommandBuilder AddParameter (Action configure) + public override ContextCommandBuilder AddParameter(Action configure) { var parameter = new CommandParameterBuilder(this); configure(parameter); @@ -126,7 +126,7 @@ namespace Discord.Interactions.Builders return this; } - internal override ContextCommandInfo Build (ModuleInfo module, InteractionService commandService) => + internal override ContextCommandInfo Build(ModuleInfo module, InteractionService commandService) => ContextCommandInfo.Create(this, module, commandService); } } diff --git a/src/Discord.Net.Interactions/Builders/Commands/ICommandBuilder.cs b/src/Discord.Net.Interactions/Builders/Commands/ICommandBuilder.cs index 97bc1e8e..a8036e60 100644 --- a/src/Discord.Net.Interactions/Builders/Commands/ICommandBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Commands/ICommandBuilder.cs @@ -66,7 +66,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - ICommandBuilder WithName (string name); + ICommandBuilder WithName(string name); /// /// Sets . @@ -75,7 +75,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - ICommandBuilder WithMethodName (string name); + ICommandBuilder WithMethodName(string name); /// /// Adds attributes to . @@ -84,7 +84,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - ICommandBuilder WithAttributes (params Attribute[] attributes); + ICommandBuilder WithAttributes(params Attribute[] attributes); /// /// Sets . @@ -93,7 +93,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - ICommandBuilder SetRunMode (RunMode runMode); + ICommandBuilder SetRunMode(RunMode runMode); /// /// Sets . @@ -111,7 +111,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - ICommandBuilder AddParameters (params IParameterBuilder[] parameters); + ICommandBuilder AddParameters(params IParameterBuilder[] parameters); /// /// Adds preconditions to . @@ -120,6 +120,6 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - ICommandBuilder WithPreconditions (params PreconditionAttribute[] preconditions); + ICommandBuilder WithPreconditions(params PreconditionAttribute[] preconditions); } } diff --git a/src/Discord.Net.Interactions/Builders/Commands/SlashCommandBuilder.cs b/src/Discord.Net.Interactions/Builders/Commands/SlashCommandBuilder.cs index ead6db3c..fa1c1de2 100644 --- a/src/Discord.Net.Interactions/Builders/Commands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Commands/SlashCommandBuilder.cs @@ -35,7 +35,7 @@ namespace Discord.Interactions.Builders /// public GuildPermission? DefaultMemberPermissions { get; set; } = null; - internal SlashCommandBuilder (ModuleBuilder module) : base(module) { } + internal SlashCommandBuilder(ModuleBuilder module) : base(module) { } /// /// Initializes a new . @@ -43,7 +43,7 @@ namespace Discord.Interactions.Builders /// Parent module of this command. /// Name of this command. /// Execution callback of this command. - public SlashCommandBuilder (ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback) { } + public SlashCommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback) { } /// /// Sets . @@ -52,7 +52,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public SlashCommandBuilder WithDescription (string description) + public SlashCommandBuilder WithDescription(string description) { Description = description; return this; @@ -66,7 +66,7 @@ namespace Discord.Interactions.Builders /// The builder instance. /// [Obsolete($"To be deprecated soon, use {nameof(SetEnabledInDm)} and {nameof(WithDefaultMemberPermissions)} instead.")] - public SlashCommandBuilder WithDefaultPermission (bool permission) + public SlashCommandBuilder WithDefaultPermission(bool permission) { DefaultPermission = permission; return Instance; @@ -79,7 +79,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public override SlashCommandBuilder AddParameter (Action configure) + public override SlashCommandBuilder AddParameter(Action configure) { var parameter = new SlashCommandParameterBuilder(this); configure(parameter); @@ -126,7 +126,7 @@ namespace Discord.Interactions.Builders return this; } - internal override SlashCommandInfo Build (ModuleInfo module, InteractionService commandService) => + internal override SlashCommandInfo Build(ModuleInfo module, InteractionService commandService) => new SlashCommandInfo(this, module, commandService); } } diff --git a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs index 7da7624c..e3ac0140 100644 --- a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs @@ -116,7 +116,7 @@ namespace Discord.Interactions.Builders internal TypeInfo TypeInfo { get; set; } - internal ModuleBuilder (InteractionService interactionService, ModuleBuilder parent = null) + internal ModuleBuilder(InteractionService interactionService, ModuleBuilder parent = null) { InteractionService = interactionService; Parent = parent; @@ -127,7 +127,7 @@ namespace Discord.Interactions.Builders _contextCommands = new List(); _componentCommands = new List(); _autocompleteCommands = new List(); - _modalCommands = new List (); + _modalCommands = new List(); _preconditions = new List(); } @@ -137,7 +137,7 @@ namespace Discord.Interactions.Builders /// The underlying Interaction Service. /// Name of this module. /// Parent module of this sub-module. - public ModuleBuilder (InteractionService interactionService, string name, ModuleBuilder parent = null) : this(interactionService, parent) + public ModuleBuilder(InteractionService interactionService, string name, ModuleBuilder parent = null) : this(interactionService, parent) { Name = name; } @@ -149,7 +149,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder WithGroupName (string name) + public ModuleBuilder WithGroupName(string name) { SlashGroupName = name; return this; @@ -162,7 +162,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder WithDescription (string description) + public ModuleBuilder WithDescription(string description) { Description = description; return this; @@ -176,7 +176,7 @@ namespace Discord.Interactions.Builders /// The builder instance. /// [Obsolete($"To be deprecated soon, use {nameof(SetEnabledInDm)} and {nameof(WithDefaultMemberPermissions)} instead.")] - public ModuleBuilder WithDefaultPermission (bool permission) + public ModuleBuilder WithDefaultPermission(bool permission) { DefaultPermission = permission; return this; @@ -228,7 +228,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder AddAttributes (params Attribute[] attributes) + public ModuleBuilder AddAttributes(params Attribute[] attributes) { _attributes.AddRange(attributes); return this; @@ -241,7 +241,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder AddPreconditions (params PreconditionAttribute[] preconditions) + public ModuleBuilder AddPreconditions(params PreconditionAttribute[] preconditions) { _preconditions.AddRange(preconditions); return this; @@ -254,7 +254,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder AddSlashCommand (Action configure) + public ModuleBuilder AddSlashCommand(Action configure) { var command = new SlashCommandBuilder(this); configure(command); @@ -286,7 +286,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder AddContextCommand (Action configure) + public ModuleBuilder AddContextCommand(Action configure) { var command = new ContextCommandBuilder(this); configure(command); @@ -318,7 +318,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder AddComponentCommand (Action configure) + public ModuleBuilder AddComponentCommand(Action configure) { var command = new ComponentCommandBuilder(this); configure(command); @@ -398,7 +398,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public ModuleBuilder AddModule (Action configure) + public ModuleBuilder AddModule(Action configure) { var subModule = new ModuleBuilder(InteractionService, this); configure(subModule); @@ -406,7 +406,7 @@ namespace Discord.Interactions.Builders return this; } - internal ModuleInfo Build (InteractionService interactionService, IServiceProvider services, ModuleInfo parent = null) + internal ModuleInfo Build(InteractionService interactionService, IServiceProvider services, ModuleInfo parent = null) { if (TypeInfo is not null && ModuleClassBuilder.IsValidModuleDefinition(TypeInfo)) { diff --git a/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs b/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs index ea1875b6..358bc44f 100644 --- a/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs @@ -13,9 +13,9 @@ namespace Discord.Interactions.Builders public const int MaxCommandDepth = 3; - public static async Task> SearchAsync (Assembly assembly, InteractionService commandService) + public static async Task> SearchAsync(Assembly assembly, InteractionService commandService) { - static bool IsLoadableModule (TypeInfo info) + static bool IsLoadableModule(TypeInfo info) { return info.DeclaredMethods.Any(x => x.GetCustomAttribute() != null); } @@ -24,7 +24,7 @@ namespace Discord.Interactions.Builders foreach (var type in assembly.DefinedTypes) { - if (( type.IsPublic || type.IsNestedPublic ) && IsValidModuleDefinition(type)) + if ((type.IsPublic || type.IsNestedPublic) && IsValidModuleDefinition(type)) { result.Add(type); } @@ -36,7 +36,7 @@ namespace Discord.Interactions.Builders return result; } - public static async Task> BuildAsync (IEnumerable validTypes, InteractionService commandService, + public static async Task> BuildAsync(IEnumerable validTypes, InteractionService commandService, IServiceProvider services) { var topLevelGroups = validTypes.Where(x => x.DeclaringType == null || !IsValidModuleDefinition(x.DeclaringType.GetTypeInfo())); @@ -62,7 +62,7 @@ namespace Discord.Interactions.Builders return result; } - private static void BuildModule (ModuleBuilder builder, TypeInfo typeInfo, InteractionService commandService, + private static void BuildModule(ModuleBuilder builder, TypeInfo typeInfo, InteractionService commandService, IServiceProvider services) { var attributes = typeInfo.GetCustomAttributes(); @@ -130,14 +130,14 @@ namespace Discord.Interactions.Builders foreach (var method in validInteractions) builder.AddComponentCommand(x => BuildComponentCommand(x, createInstance, method, commandService, services)); - foreach(var method in validAutocompleteCommands) + foreach (var method in validAutocompleteCommands) builder.AddAutocompleteCommand(x => BuildAutocompleteCommand(x, createInstance, method, commandService, services)); - foreach(var method in validModalCommands) + foreach (var method in validModalCommands) builder.AddModalCommand(x => BuildModalCommand(x, createInstance, method, commandService, services)); } - private static void BuildSubModules (ModuleBuilder parent, IEnumerable subModules, IList builtTypes, InteractionService commandService, + private static void BuildSubModules(ModuleBuilder parent, IEnumerable subModules, IList builtTypes, InteractionService commandService, IServiceProvider services, int slashGroupDepth = 0) { foreach (var submodule in subModules.Where(IsValidModuleDefinition)) @@ -158,7 +158,7 @@ namespace Discord.Interactions.Builders } } - private static void BuildSlashCommand (SlashCommandBuilder builder, Func createInstance, MethodInfo methodInfo, + private static void BuildSlashCommand(SlashCommandBuilder builder, Func createInstance, MethodInfo methodInfo, InteractionService commandService, IServiceProvider services) { var attributes = methodInfo.GetCustomAttributes(); @@ -212,7 +212,7 @@ namespace Discord.Interactions.Builders builder.Callback = CreateCallback(createInstance, methodInfo, commandService); } - private static void BuildContextCommand (ContextCommandBuilder builder, Func createInstance, MethodInfo methodInfo, + private static void BuildContextCommand(ContextCommandBuilder builder, Func createInstance, MethodInfo methodInfo, InteractionService commandService, IServiceProvider services) { var attributes = methodInfo.GetCustomAttributes(); @@ -267,7 +267,7 @@ namespace Discord.Interactions.Builders builder.Callback = CreateCallback(createInstance, methodInfo, commandService); } - private static void BuildComponentCommand (ComponentCommandBuilder builder, Func createInstance, MethodInfo methodInfo, + private static void BuildComponentCommand(ComponentCommandBuilder builder, Func createInstance, MethodInfo methodInfo, InteractionService commandService, IServiceProvider services) { var attributes = methodInfo.GetCustomAttributes(); @@ -312,7 +312,7 @@ namespace Discord.Interactions.Builders builder.MethodName = methodInfo.Name; - foreach(var attribute in attributes) + foreach (var attribute in attributes) { switch (attribute) { @@ -383,13 +383,13 @@ namespace Discord.Interactions.Builders builder.Callback = CreateCallback(createInstance, methodInfo, commandService); } - private static ExecuteCallback CreateCallback (Func createInstance, + private static ExecuteCallback CreateCallback(Func createInstance, MethodInfo methodInfo, InteractionService commandService) { Func commandInvoker = commandService._useCompiledLambda ? ReflectionUtils.CreateMethodInvoker(methodInfo) : (module, args) => methodInfo.Invoke(module, args) as Task; - async Task ExecuteCallback (IInteractionContext context, object[] args, IServiceProvider serviceProvider, ICommandInfo commandInfo) + async Task ExecuteCallback(IInteractionContext context, object[] args, IServiceProvider serviceProvider, ICommandInfo commandInfo) { var instance = createInstance(serviceProvider); instance.SetContext(context); @@ -420,7 +420,7 @@ namespace Discord.Interactions.Builders { await instance.AfterExecuteAsync(commandInfo).ConfigureAwait(false); instance.AfterExecute(commandInfo); - ( instance as IDisposable )?.Dispose(); + (instance as IDisposable)?.Dispose(); } } @@ -428,7 +428,7 @@ namespace Discord.Interactions.Builders } #region Parameters - private static void BuildSlashParameter (SlashCommandParameterBuilder builder, ParameterInfo paramInfo, IServiceProvider services) + private static void BuildSlashParameter(SlashCommandParameterBuilder builder, ParameterInfo paramInfo, IServiceProvider services) { var attributes = paramInfo.GetCustomAttributes(); var paramType = paramInfo.ParameterType; @@ -465,7 +465,7 @@ namespace Discord.Interactions.Builders break; case AutocompleteAttribute autocomplete: builder.Autocomplete = true; - if(autocomplete.AutocompleteHandlerType is not null) + if (autocomplete.AutocompleteHandlerType is not null) builder.WithAutocompleteHandler(autocomplete.AutocompleteHandlerType, services); break; case MaxValueAttribute maxValue: @@ -516,7 +516,7 @@ namespace Discord.Interactions.Builders BuildParameter(builder, paramInfo); } - private static void BuildParameter (ParameterBuilder builder, ParameterInfo paramInfo) + private static void BuildParameter(ParameterBuilder builder, ParameterInfo paramInfo) where TInfo : class, IParameterInfo where TBuilder : ParameterBuilder { @@ -598,7 +598,7 @@ namespace Discord.Interactions.Builders builder.WithType(propertyInfo.PropertyType); builder.PropertyInfo = propertyInfo; - foreach(var attribute in attributes) + foreach (var attribute in attributes) { switch (attribute) { @@ -625,30 +625,30 @@ namespace Discord.Interactions.Builders } #endregion - internal static bool IsValidModuleDefinition (TypeInfo typeInfo) + internal static bool IsValidModuleDefinition(TypeInfo typeInfo) { return ModuleTypeInfo.IsAssignableFrom(typeInfo) && !typeInfo.IsAbstract && !typeInfo.ContainsGenericParameters; } - private static bool IsValidSlashCommandDefinition (MethodInfo methodInfo) + private static bool IsValidSlashCommandDefinition(MethodInfo methodInfo) { return methodInfo.IsDefined(typeof(SlashCommandAttribute)) && - ( methodInfo.ReturnType == typeof(Task) || methodInfo.ReturnType == typeof(Task) ) && + (methodInfo.ReturnType == typeof(Task) || methodInfo.ReturnType == typeof(Task)) && !methodInfo.IsStatic && !methodInfo.IsGenericMethod; } - private static bool IsValidContextCommandDefinition (MethodInfo methodInfo) + private static bool IsValidContextCommandDefinition(MethodInfo methodInfo) { return methodInfo.IsDefined(typeof(ContextCommandAttribute)) && - ( methodInfo.ReturnType == typeof(Task) || methodInfo.ReturnType == typeof(Task) ) && + (methodInfo.ReturnType == typeof(Task) || methodInfo.ReturnType == typeof(Task)) && !methodInfo.IsStatic && !methodInfo.IsGenericMethod; } - private static bool IsValidComponentCommandDefinition (MethodInfo methodInfo) + private static bool IsValidComponentCommandDefinition(MethodInfo methodInfo) { return methodInfo.IsDefined(typeof(ComponentInteractionAttribute)) && (methodInfo.ReturnType == typeof(Task) || methodInfo.ReturnType == typeof(Task)) && @@ -656,7 +656,7 @@ namespace Discord.Interactions.Builders !methodInfo.IsGenericMethod; } - private static bool IsValidAutocompleteCommandDefinition (MethodInfo methodInfo) + private static bool IsValidAutocompleteCommandDefinition(MethodInfo methodInfo) { return methodInfo.IsDefined(typeof(AutocompleteCommandAttribute)) && (methodInfo.ReturnType == typeof(Task) || methodInfo.ReturnType == typeof(Task)) && @@ -680,7 +680,7 @@ namespace Discord.Interactions.Builders propertyInfo.SetMethod?.IsStatic == false && propertyInfo.IsDefined(typeof(ModalInputAttribute)); } - + private static ConstructorInfo GetComplexParameterConstructor(TypeInfo typeInfo, ComplexParameterAttribute complexParameter) { var ctors = typeInfo.GetConstructors(); diff --git a/src/Discord.Net.Interactions/Builders/Parameters/CommandParameterBuilder.cs b/src/Discord.Net.Interactions/Builders/Parameters/CommandParameterBuilder.cs index 0aada983..d3aa85c4 100644 --- a/src/Discord.Net.Interactions/Builders/Parameters/CommandParameterBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Parameters/CommandParameterBuilder.cs @@ -9,7 +9,7 @@ namespace Discord.Interactions.Builders { protected override CommandParameterBuilder Instance => this; - internal CommandParameterBuilder (ICommandBuilder command) : base(command) { } + internal CommandParameterBuilder(ICommandBuilder command) : base(command) { } /// /// Initializes a new . @@ -17,9 +17,9 @@ namespace Discord.Interactions.Builders /// Parent command of this parameter. /// Name of this command. /// Type of this parameter. - public CommandParameterBuilder (ICommandBuilder command, string name, Type type) : base(command, name, type) { } + public CommandParameterBuilder(ICommandBuilder command, string name, Type type) : base(command, name, type) { } - internal override CommandParameterInfo Build (ICommandInfo command) => + internal override CommandParameterInfo Build(ICommandInfo command) => new CommandParameterInfo(this, command); } } diff --git a/src/Discord.Net.Interactions/Builders/Parameters/IParameterBuilder.cs b/src/Discord.Net.Interactions/Builders/Parameters/IParameterBuilder.cs index 6dd5ad3a..46f5cefc 100644 --- a/src/Discord.Net.Interactions/Builders/Parameters/IParameterBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Parameters/IParameterBuilder.cs @@ -55,7 +55,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - IParameterBuilder WithName (string name); + IParameterBuilder WithName(string name); /// /// Sets . @@ -64,7 +64,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - IParameterBuilder SetParameterType (Type type); + IParameterBuilder SetParameterType(Type type); /// /// Sets . @@ -73,7 +73,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - IParameterBuilder SetRequired (bool isRequired); + IParameterBuilder SetRequired(bool isRequired); /// /// Sets . @@ -82,7 +82,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - IParameterBuilder SetDefaultValue (object defaultValue); + IParameterBuilder SetDefaultValue(object defaultValue); /// /// Adds attributes to . @@ -91,7 +91,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - IParameterBuilder AddAttributes (params Attribute[] attributes); + IParameterBuilder AddAttributes(params Attribute[] attributes); /// /// Adds preconditions to . @@ -100,6 +100,6 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - IParameterBuilder AddPreconditions (params ParameterPreconditionAttribute[] preconditions); + IParameterBuilder AddPreconditions(params ParameterPreconditionAttribute[] preconditions); } } diff --git a/src/Discord.Net.Interactions/Builders/Parameters/ParameterBuilder.cs b/src/Discord.Net.Interactions/Builders/Parameters/ParameterBuilder.cs index fec1a6ce..bf27a45f 100644 --- a/src/Discord.Net.Interactions/Builders/Parameters/ParameterBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Parameters/ParameterBuilder.cs @@ -40,7 +40,7 @@ namespace Discord.Interactions.Builders public IReadOnlyCollection Preconditions => _preconditions; protected abstract TBuilder Instance { get; } - internal ParameterBuilder (ICommandBuilder command) + internal ParameterBuilder(ICommandBuilder command) { _attributes = new List(); _preconditions = new List(); @@ -48,7 +48,7 @@ namespace Discord.Interactions.Builders Command = command; } - protected ParameterBuilder (ICommandBuilder command, string name, Type type) : this(command) + protected ParameterBuilder(ICommandBuilder command, string name, Type type) : this(command) { Name = name; SetParameterType(type); @@ -61,7 +61,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public virtual TBuilder WithName (string name) + public virtual TBuilder WithName(string name) { Name = name; return Instance; @@ -74,7 +74,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public virtual TBuilder SetParameterType (Type type) + public virtual TBuilder SetParameterType(Type type) { ParameterType = type; return Instance; @@ -87,7 +87,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public virtual TBuilder SetRequired (bool isRequired) + public virtual TBuilder SetRequired(bool isRequired) { IsRequired = isRequired; return Instance; @@ -100,7 +100,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public virtual TBuilder SetDefaultValue (object defaultValue) + public virtual TBuilder SetDefaultValue(object defaultValue) { DefaultValue = defaultValue; return Instance; @@ -113,7 +113,7 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public virtual TBuilder AddAttributes (params Attribute[] attributes) + public virtual TBuilder AddAttributes(params Attribute[] attributes) { _attributes.AddRange(attributes); return Instance; @@ -126,37 +126,37 @@ namespace Discord.Interactions.Builders /// /// The builder instance. /// - public virtual TBuilder AddPreconditions (params ParameterPreconditionAttribute[] attributes) + public virtual TBuilder AddPreconditions(params ParameterPreconditionAttribute[] attributes) { _preconditions.AddRange(attributes); return Instance; } - internal abstract TInfo Build (ICommandInfo command); + internal abstract TInfo Build(ICommandInfo command); //IParameterBuilder /// - IParameterBuilder IParameterBuilder.WithName (string name) => + IParameterBuilder IParameterBuilder.WithName(string name) => WithName(name); /// - IParameterBuilder IParameterBuilder.SetParameterType (Type type) => + IParameterBuilder IParameterBuilder.SetParameterType(Type type) => SetParameterType(type); /// - IParameterBuilder IParameterBuilder.SetRequired (bool isRequired) => + IParameterBuilder IParameterBuilder.SetRequired(bool isRequired) => SetRequired(isRequired); /// - IParameterBuilder IParameterBuilder.SetDefaultValue (object defaultValue) => + IParameterBuilder IParameterBuilder.SetDefaultValue(object defaultValue) => SetDefaultValue(defaultValue); /// - IParameterBuilder IParameterBuilder.AddAttributes (params Attribute[] attributes) => + IParameterBuilder IParameterBuilder.AddAttributes(params Attribute[] attributes) => AddAttributes(attributes); /// - IParameterBuilder IParameterBuilder.AddPreconditions (params ParameterPreconditionAttribute[] preconditions) => + IParameterBuilder IParameterBuilder.AddPreconditions(params ParameterPreconditionAttribute[] preconditions) => AddPreconditions(preconditions); } } diff --git a/src/Discord.Net.Interactions/Builders/Parameters/SlashCommandParameterBuilder.cs b/src/Discord.Net.Interactions/Builders/Parameters/SlashCommandParameterBuilder.cs index 6f8038ce..c3e104e4 100644 --- a/src/Discord.Net.Interactions/Builders/Parameters/SlashCommandParameterBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/Parameters/SlashCommandParameterBuilder.cs @@ -229,7 +229,7 @@ namespace Discord.Interactions.Builders { base.SetParameterType(type); - if(!IsComplexParameter) + if (!IsComplexParameter) TypeConverter = Command.Module.InteractionService.GetTypeConverter(ParameterType, services); return this; @@ -248,7 +248,7 @@ namespace Discord.Interactions.Builders SlashCommandParameterBuilder builder = new(Command); configure(builder); - if(builder.IsComplexParameter) + if (builder.IsComplexParameter) throw new InvalidOperationException("You cannot create nested complex parameters."); _complexParameterFields.Add(builder); @@ -265,7 +265,7 @@ namespace Discord.Interactions.Builders /// Thrown if the added field has a . public SlashCommandParameterBuilder AddComplexParameterFields(params SlashCommandParameterBuilder[] fields) { - if(fields.Any(x => x.IsComplexParameter)) + if (fields.Any(x => x.IsComplexParameter)) throw new InvalidOperationException("You cannot create nested complex parameters."); _complexParameterFields.AddRange(fields); diff --git a/src/Discord.Net.Interactions/Entities/ParameterChoice.cs b/src/Discord.Net.Interactions/Entities/ParameterChoice.cs index 30f10785..b1299635 100644 --- a/src/Discord.Net.Interactions/Entities/ParameterChoice.cs +++ b/src/Discord.Net.Interactions/Entities/ParameterChoice.cs @@ -15,7 +15,7 @@ namespace Discord.Interactions /// public object Value { get; } - internal ParameterChoice (string name, object value) + internal ParameterChoice(string name, object value) { Name = name; Value = value; diff --git a/src/Discord.Net.Interactions/IInteractionModuleBase.cs b/src/Discord.Net.Interactions/IInteractionModuleBase.cs index cc944a55..33aba04c 100644 --- a/src/Discord.Net.Interactions/IInteractionModuleBase.cs +++ b/src/Discord.Net.Interactions/IInteractionModuleBase.cs @@ -11,7 +11,7 @@ namespace Discord.Interactions /// Sets the context of this module. /// /// - void SetContext (IInteractionContext context); + void SetContext(IInteractionContext context); /// /// Method body to be executed asynchronously before executing an application command. @@ -35,14 +35,14 @@ namespace Discord.Interactions /// Method body to be executed after an application command execution. /// /// Command information related to the Discord Application Command. - void AfterExecute (ICommandInfo command); + void AfterExecute(ICommandInfo command); /// /// Method body to be executed when is called. /// /// Command Service instance that built this module. /// Info class of this module. - void OnModuleBuilding (InteractionService commandService, ModuleInfo module); + void OnModuleBuilding(InteractionService commandService, ModuleInfo module); /// /// Method body to be executed after the automated module creation is completed and before is called. diff --git a/src/Discord.Net.Interactions/Info/Commands/AutocompleteCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/AutocompleteCommandInfo.cs index b8940f42..1016e532 100644 --- a/src/Discord.Net.Interactions/Info/Commands/AutocompleteCommandInfo.cs +++ b/src/Discord.Net.Interactions/Info/Commands/AutocompleteCommandInfo.cs @@ -64,7 +64,7 @@ namespace Discord.Interactions { var keywords = new List() { ParameterName, CommandName }; - if(!IgnoreGroupNames) + if (!IgnoreGroupNames) { var currentParent = Module; diff --git a/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs index 92e2f30b..1545ba1a 100644 --- a/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs +++ b/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs @@ -20,7 +20,7 @@ namespace Discord.Interactions /// /// A task representing the execution operation. /// - public delegate Task ExecuteCallback (IInteractionContext context, object[] args, IServiceProvider serviceProvider, ICommandInfo commandInfo); + public delegate Task ExecuteCallback(IInteractionContext context, object[] args, IServiceProvider serviceProvider, ICommandInfo commandInfo); /// /// The base information class for commands. @@ -114,7 +114,7 @@ namespace Discord.Interactions await CommandService._cmdLogger.DebugAsync($"Executing {GetLogString(context)}").ConfigureAwait(false); using var scope = services?.CreateScope(); - + if (CommandService._autoServiceScopes) services = scope?.ServiceProvider ?? EmptyServiceProvider.Instance; @@ -129,7 +129,7 @@ namespace Discord.Interactions if (!argsResult.IsSuccess) return await InvokeEventAndReturn(context, argsResult).ConfigureAwait(false); - if(argsResult is not ParseResult parseResult) + if (argsResult is not ParseResult parseResult) return ExecuteResult.FromError(InteractionCommandError.BadArgs, "Complex command parsing failed for an unknown reason."); var args = parseResult.Args; diff --git a/src/Discord.Net.Interactions/Info/Commands/ComponentCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/ComponentCommandInfo.cs index 5877eaea..aac8e5fb 100644 --- a/src/Discord.Net.Interactions/Info/Commands/ComponentCommandInfo.cs +++ b/src/Discord.Net.Interactions/Info/Commands/ComponentCommandInfo.cs @@ -42,7 +42,7 @@ namespace Discord.Interactions var data = (context.Interaction as IComponentInteraction).Data; var args = new object[Parameters.Count]; - for(var i = 0; i < Parameters.Count; i++) + for (var i = 0; i < Parameters.Count; i++) { var parameter = Parameters[i]; var isCapture = i < captureCount; diff --git a/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs index 61f79453..2635fe7c 100644 --- a/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs +++ b/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs @@ -35,7 +35,7 @@ namespace Discord.Interactions /// public override bool IgnoreGroupNames => true; - internal ContextCommandInfo (Builders.ContextCommandBuilder builder, ModuleInfo module, InteractionService commandService) + internal ContextCommandInfo(Builders.ContextCommandBuilder builder, ModuleInfo module, InteractionService commandService) : base(builder, module, commandService) { CommandType = builder.CommandType; @@ -46,7 +46,7 @@ namespace Discord.Interactions Parameters = builder.Parameters.Select(x => x.Build(this)).ToImmutableArray(); } - internal static ContextCommandInfo Create (Builders.ContextCommandBuilder builder, ModuleInfo module, InteractionService commandService) + internal static ContextCommandInfo Create(Builders.ContextCommandBuilder builder, ModuleInfo module, InteractionService commandService) { return builder.CommandType switch { @@ -57,7 +57,7 @@ namespace Discord.Interactions } /// - protected override Task InvokeModuleEvent (IInteractionContext context, IResult result) + protected override Task InvokeModuleEvent(IInteractionContext context, IResult result) => CommandService._contextCommandExecutedEvent.InvokeAsync(this, context, result); } } diff --git a/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs index ee393970..720d03ad 100644 --- a/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs +++ b/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs @@ -86,7 +86,7 @@ namespace Discord.Interactions var options = GetOptions(); var args = new object[Parameters.Count]; - for(var i = 0; i < Parameters.Count; i++) + for (var i = 0; i < Parameters.Count; i++) { var parameter = Parameters[i]; var result = await ParseArgumentAsync(parameter, context, options, services).ConfigureAwait(false); @@ -136,10 +136,10 @@ namespace Discord.Interactions return readResult; } - protected override Task InvokeModuleEvent (IInteractionContext context, IResult result) + protected override Task InvokeModuleEvent(IInteractionContext context, IResult result) => CommandService._slashCommandExecutedEvent.InvokeAsync(this, context, result); - protected override string GetLogString (IInteractionContext context) + protected override string GetLogString(IInteractionContext context) { if (context.Guild != null) return $"Slash Command: \"{base.ToString()}\" for {context.User} in {context.Guild}/{context.Channel}"; @@ -153,7 +153,7 @@ namespace Discord.Interactions if (!parameter.IsComplexParameter) yield return parameter; else - foreach(var complexParameterField in parameter.ComplexParameterFields) + foreach (var complexParameterField in parameter.ComplexParameterFields) yield return complexParameterField; } } diff --git a/src/Discord.Net.Interactions/Info/ICommandInfo.cs b/src/Discord.Net.Interactions/Info/ICommandInfo.cs index 1de6e0df..fd5c7421 100644 --- a/src/Discord.Net.Interactions/Info/ICommandInfo.cs +++ b/src/Discord.Net.Interactions/Info/ICommandInfo.cs @@ -75,11 +75,11 @@ namespace Discord.Interactions /// /// A task representing the execution process. The task result contains the execution result. /// - Task ExecuteAsync (IInteractionContext context, IServiceProvider services); + Task ExecuteAsync(IInteractionContext context, IServiceProvider services); /// /// Check if an execution context meets the command precondition requirements. /// - Task CheckPreconditionsAsync (IInteractionContext context, IServiceProvider services); + Task CheckPreconditionsAsync(IInteractionContext context, IServiceProvider services); } } diff --git a/src/Discord.Net.Interactions/Info/IParameterInfo.cs b/src/Discord.Net.Interactions/Info/IParameterInfo.cs index 8244476e..654d623f 100644 --- a/src/Discord.Net.Interactions/Info/IParameterInfo.cs +++ b/src/Discord.Net.Interactions/Info/IParameterInfo.cs @@ -52,6 +52,6 @@ namespace Discord.Interactions /// /// Check if an execution context meets the parameter precondition requirements. /// - Task CheckPreconditionsAsync (IInteractionContext context, object value, IServiceProvider services); + Task CheckPreconditionsAsync(IInteractionContext context, object value, IServiceProvider services); } } diff --git a/src/Discord.Net.Interactions/Info/ModuleInfo.cs b/src/Discord.Net.Interactions/Info/ModuleInfo.cs index 5c4cac58..991da135 100644 --- a/src/Discord.Net.Interactions/Info/ModuleInfo.cs +++ b/src/Discord.Net.Interactions/Info/ModuleInfo.cs @@ -117,7 +117,7 @@ namespace Discord.Interactions /// public bool DontAutoRegister { get; } - internal ModuleInfo (ModuleBuilder builder, InteractionService commandService, IServiceProvider services, ModuleInfo parent = null) + internal ModuleInfo(ModuleBuilder builder, InteractionService commandService, IServiceProvider services, ModuleInfo parent = null) { CommandService = commandService; @@ -143,7 +143,7 @@ namespace Discord.Interactions GroupedPreconditions = Preconditions.ToLookup(x => x.Group, x => x, StringComparer.Ordinal); } - private IEnumerable BuildSubModules (ModuleBuilder builder, InteractionService commandService, IServiceProvider services) + private IEnumerable BuildSubModules(ModuleBuilder builder, InteractionService commandService, IServiceProvider services) { var result = new List(); @@ -153,7 +153,7 @@ namespace Discord.Interactions return result; } - private IEnumerable BuildSlashCommands (ModuleBuilder builder) + private IEnumerable BuildSlashCommands(ModuleBuilder builder) { var result = new List(); @@ -163,7 +163,7 @@ namespace Discord.Interactions return result; } - private IEnumerable BuildContextCommands (ModuleBuilder builder) + private IEnumerable BuildContextCommands(ModuleBuilder builder) { var result = new List(); @@ -173,7 +173,7 @@ namespace Discord.Interactions return result; } - private IEnumerable BuildComponentCommands (ModuleBuilder builder) + private IEnumerable BuildComponentCommands(ModuleBuilder builder) { var result = new List(); @@ -183,7 +183,7 @@ namespace Discord.Interactions return result; } - private IEnumerable BuildAutocompleteCommands( ModuleBuilder builder) + private IEnumerable BuildAutocompleteCommands(ModuleBuilder builder) { var result = new List(); @@ -203,7 +203,7 @@ namespace Discord.Interactions return result; } - private IEnumerable BuildAttributes (ModuleBuilder builder) + private IEnumerable BuildAttributes(ModuleBuilder builder) { var result = new List(); var currentParent = builder; @@ -217,7 +217,7 @@ namespace Discord.Interactions return result; } - private static IEnumerable BuildPreconditions (ModuleBuilder builder) + private static IEnumerable BuildPreconditions(ModuleBuilder builder) { var preconditions = new List(); @@ -232,7 +232,7 @@ namespace Discord.Interactions return preconditions; } - private static bool CheckTopLevel (ModuleInfo parent) + private static bool CheckTopLevel(ModuleInfo parent) { var currentParent = parent; diff --git a/src/Discord.Net.Interactions/Info/Parameters/CommandParameterInfo.cs b/src/Discord.Net.Interactions/Info/Parameters/CommandParameterInfo.cs index 050cf423..f1e76cec 100644 --- a/src/Discord.Net.Interactions/Info/Parameters/CommandParameterInfo.cs +++ b/src/Discord.Net.Interactions/Info/Parameters/CommandParameterInfo.cs @@ -34,7 +34,7 @@ namespace Discord.Interactions /// public IReadOnlyCollection Preconditions { get; } - internal CommandParameterInfo (Builders.IParameterBuilder builder, ICommandInfo command) + internal CommandParameterInfo(Builders.IParameterBuilder builder, ICommandInfo command) { Command = command; Name = builder.Name; @@ -47,7 +47,7 @@ namespace Discord.Interactions } /// - public async Task CheckPreconditionsAsync (IInteractionContext context, object value, IServiceProvider services) + public async Task CheckPreconditionsAsync(IInteractionContext context, object value, IServiceProvider services) { foreach (var precondition in Preconditions) { diff --git a/src/Discord.Net.Interactions/InteractionModuleBase.cs b/src/Discord.Net.Interactions/InteractionModuleBase.cs index a14779db..d3336f5e 100644 --- a/src/Discord.Net.Interactions/InteractionModuleBase.cs +++ b/src/Discord.Net.Interactions/InteractionModuleBase.cs @@ -18,10 +18,10 @@ namespace Discord.Interactions public T Context { get; private set; } /// - public virtual void AfterExecute (ICommandInfo command) { } + public virtual void AfterExecute(ICommandInfo command) { } /// - public virtual void BeforeExecute (ICommandInfo command) { } + public virtual void BeforeExecute(ICommandInfo command) { } /// public virtual Task BeforeExecuteAsync(ICommandInfo command) => Task.CompletedTask; @@ -30,12 +30,12 @@ namespace Discord.Interactions public virtual Task AfterExecuteAsync(ICommandInfo command) => Task.CompletedTask; /// - public virtual void OnModuleBuilding (InteractionService commandService, ModuleInfo module) { } + public virtual void OnModuleBuilding(InteractionService commandService, ModuleInfo module) { } /// - public virtual void Construct (Builders.ModuleBuilder builder, InteractionService commandService) { } + public virtual void Construct(Builders.ModuleBuilder builder, InteractionService commandService) { } - internal void SetContext (IInteractionContext context) + internal void SetContext(IInteractionContext context) { var newValue = context as T; Context = newValue ?? throw new InvalidOperationException($"Invalid context type. Expected {typeof(T).Name}, got {context.GetType().Name}."); @@ -46,7 +46,7 @@ namespace Discord.Interactions await Context.Interaction.DeferAsync(ephemeral, options).ConfigureAwait(false); /// - protected virtual async Task RespondAsync (string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, + protected virtual async Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null) => await Context.Interaction.RespondAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); @@ -71,7 +71,7 @@ namespace Discord.Interactions => Context.Interaction.RespondWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options); /// - protected virtual async Task FollowupAsync (string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, + protected virtual async Task FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null) => await Context.Interaction.FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); @@ -96,7 +96,7 @@ namespace Discord.Interactions => Context.Interaction.FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options); /// - protected virtual async Task ReplyAsync (string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, + protected virtual async Task ReplyAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null) => await Context.Channel.SendMessageAsync(text, false, embed, options, allowedMentions, messageReference, components).ConfigureAwait(false); @@ -114,10 +114,10 @@ namespace Discord.Interactions var response = await Context.Interaction.GetOriginalResponseAsync().ConfigureAwait(false); await response.DeleteAsync().ConfigureAwait(false); } - + /// protected virtual async Task RespondWithModalAsync(Modal modal, RequestOptions options = null) => await Context.Interaction.RespondWithModalAsync(modal); - + /// protected virtual async Task RespondWithModalAsync(string customId, RequestOptions options = null) where TModal : class, IModal => await Context.Interaction.RespondWithModalAsync(customId, options); @@ -125,7 +125,7 @@ namespace Discord.Interactions //IInteractionModuleBase /// - void IInteractionModuleBase.SetContext (IInteractionContext context) => SetContext(context); + void IInteractionModuleBase.SetContext(IInteractionContext context) => SetContext(context); } /// diff --git a/src/Discord.Net.Interactions/InteractionService.cs b/src/Discord.Net.Interactions/InteractionService.cs index 502860cd..ae78564b 100644 --- a/src/Discord.Net.Interactions/InteractionService.cs +++ b/src/Discord.Net.Interactions/InteractionService.cs @@ -22,7 +22,7 @@ namespace Discord.Interactions /// Occurs when a Slash Command related information is recieved. /// public event Func Log { add { _logEvent.Add(value); } remove { _logEvent.Remove(value); } } - internal readonly AsyncEvent> _logEvent = new (); + internal readonly AsyncEvent> _logEvent = new(); /// /// Occurs when any type of interaction is executed. @@ -51,19 +51,19 @@ namespace Discord.Interactions /// Occurs when a Slash Command is executed. /// public event Func SlashCommandExecuted { add { _slashCommandExecutedEvent.Add(value); } remove { _slashCommandExecutedEvent.Remove(value); } } - internal readonly AsyncEvent> _slashCommandExecutedEvent = new (); + internal readonly AsyncEvent> _slashCommandExecutedEvent = new(); /// /// Occurs when a Context Command is executed. /// public event Func ContextCommandExecuted { add { _contextCommandExecutedEvent.Add(value); } remove { _contextCommandExecutedEvent.Remove(value); } } - internal readonly AsyncEvent> _contextCommandExecutedEvent = new (); + internal readonly AsyncEvent> _contextCommandExecutedEvent = new(); /// /// Occurs when a Message Component command is executed. /// public event Func ComponentCommandExecuted { add { _componentCommandExecutedEvent.Add(value); } remove { _componentCommandExecutedEvent.Remove(value); } } - internal readonly AsyncEvent> _componentCommandExecutedEvent = new (); + internal readonly AsyncEvent> _componentCommandExecutedEvent = new(); /// /// Occurs when a Autocomplete command is executed. @@ -150,7 +150,7 @@ namespace Discord.Interactions /// /// The discord client. /// The configuration class. - public InteractionService (DiscordSocketClient discord, InteractionServiceConfig config = null) + public InteractionService(DiscordSocketClient discord, InteractionServiceConfig config = null) : this(() => discord.Rest, config ?? new InteractionServiceConfig()) { } /// @@ -158,7 +158,7 @@ namespace Discord.Interactions /// /// The discord client. /// The configuration class. - public InteractionService (DiscordShardedClient discord, InteractionServiceConfig config = null) + public InteractionService(DiscordShardedClient discord, InteractionServiceConfig config = null) : this(() => discord.Rest, config ?? new InteractionServiceConfig()) { } /// @@ -166,18 +166,18 @@ namespace Discord.Interactions /// /// The discord client. /// The configuration class. - public InteractionService (BaseSocketClient discord, InteractionServiceConfig config = null) - :this(() => discord.Rest, config ?? new InteractionServiceConfig()) { } + public InteractionService(BaseSocketClient discord, InteractionServiceConfig config = null) + : this(() => discord.Rest, config ?? new InteractionServiceConfig()) { } /// /// Initialize a with provided configurations. /// /// The discord client. /// The configuration class. - public InteractionService (DiscordRestClient discord, InteractionServiceConfig config = null) - :this(() => discord, config ?? new InteractionServiceConfig()) { } + public InteractionService(DiscordRestClient discord, InteractionServiceConfig config = null) + : this(() => discord, config ?? new InteractionServiceConfig()) { } - private InteractionService (Func getRestClient, InteractionServiceConfig config = null) + private InteractionService(Func getRestClient, InteractionServiceConfig config = null) { config ??= new InteractionServiceConfig(); @@ -211,19 +211,19 @@ namespace Discord.Interactions LocalizationManager = config.LocalizationManager; _typeConverterMap = new TypeMap(this, new ConcurrentDictionary - { - [typeof(TimeSpan)] = new TimeSpanConverter() - }, new ConcurrentDictionary - { - [typeof(IChannel)] = typeof(DefaultChannelConverter<>), - [typeof(IRole)] = typeof(DefaultRoleConverter<>), - [typeof(IAttachment)] = typeof(DefaultAttachmentConverter<>), - [typeof(IUser)] = typeof(DefaultUserConverter<>), - [typeof(IMentionable)] = typeof(DefaultMentionableConverter<>), - [typeof(IConvertible)] = typeof(DefaultValueConverter<>), - [typeof(Enum)] = typeof(EnumConverter<>), - [typeof(Nullable<>)] = typeof(NullableConverter<>) - }); + { + [typeof(TimeSpan)] = new TimeSpanConverter() + }, new ConcurrentDictionary + { + [typeof(IChannel)] = typeof(DefaultChannelConverter<>), + [typeof(IRole)] = typeof(DefaultRoleConverter<>), + [typeof(IAttachment)] = typeof(DefaultAttachmentConverter<>), + [typeof(IUser)] = typeof(DefaultUserConverter<>), + [typeof(IMentionable)] = typeof(DefaultMentionableConverter<>), + [typeof(IConvertible)] = typeof(DefaultValueConverter<>), + [typeof(Enum)] = typeof(EnumConverter<>), + [typeof(Nullable<>)] = typeof(NullableConverter<>) + }); _compTypeConverterMap = new TypeMap(this, new ConcurrentDictionary(), new ConcurrentDictionary @@ -284,7 +284,7 @@ namespace Discord.Interactions /// /// A task representing the operation for adding modules. The task result contains a collection of the modules added. /// - public async Task> AddModulesAsync (Assembly assembly, IServiceProvider services) + public async Task> AddModulesAsync(Assembly assembly, IServiceProvider services) { services ??= EmptyServiceProvider.Instance; @@ -322,7 +322,7 @@ namespace Discord.Interactions /// /// Thrown when the is not a valid module definition. /// - public Task AddModuleAsync (IServiceProvider services) where T : class => + public Task AddModuleAsync(IServiceProvider services) where T : class => AddModuleAsync(typeof(T), services); /// @@ -339,7 +339,7 @@ namespace Discord.Interactions /// /// Thrown when the is not a valid module definition. /// - public async Task AddModuleAsync (Type type, IServiceProvider services) + public async Task AddModuleAsync(Type type, IServiceProvider services) { if (!typeof(IInteractionModuleBase).IsAssignableFrom(type)) throw new ArgumentException("Type parameter must be a type of Slash Module", nameof(type)); @@ -355,7 +355,7 @@ namespace Discord.Interactions if (_typedModuleDefs.ContainsKey(typeInfo)) throw new ArgumentException("Module definition for this type already exists."); - var moduleDef = ( await ModuleClassBuilder.BuildAsync(new List { typeInfo }, this, services).ConfigureAwait(false) ).FirstOrDefault(); + var moduleDef = (await ModuleClassBuilder.BuildAsync(new List { typeInfo }, this, services).ConfigureAwait(false)).FirstOrDefault(); if (moduleDef.Value == default) throw new InvalidOperationException($"Could not build the module {typeInfo.FullName}, did you pass an invalid type?"); @@ -382,7 +382,7 @@ namespace Discord.Interactions /// /// A task representing the command registration process. The task result contains the active application commands of the target guild. /// - public async Task> RegisterCommandsToGuildAsync (ulong guildId, bool deleteMissing = true) + public async Task> RegisterCommandsToGuildAsync(ulong guildId, bool deleteMissing = true) { EnsureClientReady(); @@ -407,7 +407,7 @@ namespace Discord.Interactions /// /// A task representing the command registration process. The task result contains the active global application commands of bot. /// - public async Task> RegisterCommandsGloballyAsync (bool deleteMissing = true) + public async Task> RegisterCommandsGloballyAsync(bool deleteMissing = true) { EnsureClientReady(); @@ -598,7 +598,7 @@ namespace Discord.Interactions return await RestClient.BulkOverwriteGlobalCommands(props.ToArray()).ConfigureAwait(false); } - private void LoadModuleInternal (ModuleInfo module) + private void LoadModuleInternal(ModuleInfo module) { _moduleDefs.Add(module); @@ -629,7 +629,7 @@ namespace Discord.Interactions /// A task that represents the asynchronous removal operation. The task result contains a value that /// indicates whether the module is successfully removed. /// - public Task RemoveModuleAsync ( ) => + public Task RemoveModuleAsync() => RemoveModuleAsync(typeof(T)); /// @@ -640,7 +640,7 @@ namespace Discord.Interactions /// A task that represents the asynchronous removal operation. The task result contains a value that /// indicates whether the module is successfully removed. /// - public async Task RemoveModuleAsync (Type type) + public async Task RemoveModuleAsync(Type type) { await _lock.WaitAsync().ConfigureAwait(false); @@ -720,7 +720,7 @@ namespace Discord.Interactions return await RestClient.BulkOverwriteGuildCommands(props.ToArray(), guildId).ConfigureAwait(false); } - private bool RemoveModuleInternal (ModuleInfo moduleInfo) + private bool RemoveModuleInternal(ModuleInfo moduleInfo) { if (!_moduleDefs.Remove(moduleInfo)) return false; @@ -795,7 +795,7 @@ namespace Discord.Interactions /// /// A task representing the command execution process. The task result contains the result of the execution. /// - public async Task ExecuteCommandAsync (IInteractionContext context, IServiceProvider services) + public async Task ExecuteCommandAsync(IInteractionContext context, IServiceProvider services) { var interaction = context.Interaction; @@ -811,7 +811,7 @@ namespace Discord.Interactions }; } - private async Task ExecuteSlashCommandAsync (IInteractionContext context, ISlashCommandInteraction interaction, IServiceProvider services) + private async Task ExecuteSlashCommandAsync(IInteractionContext context, ISlashCommandInteraction interaction, IServiceProvider services) { var keywords = interaction.Data.GetCommandKeywords(); @@ -827,7 +827,7 @@ namespace Discord.Interactions return await result.Command.ExecuteAsync(context, services).ConfigureAwait(false); } - private async Task ExecuteContextCommandAsync (IInteractionContext context, string input, ApplicationCommandType commandType, IServiceProvider services) + private async Task ExecuteContextCommandAsync(IInteractionContext context, string input, ApplicationCommandType commandType, IServiceProvider services) { if (!_contextCommandMaps.TryGetValue(commandType, out var map)) return SearchResult.FromError(input, InteractionCommandError.UnknownCommand, $"No {commandType} command found."); @@ -844,7 +844,7 @@ namespace Discord.Interactions return await result.Command.ExecuteAsync(context, services).ConfigureAwait(false); } - private async Task ExecuteComponentCommandAsync (IInteractionContext context, string input, IServiceProvider services) + private async Task ExecuteComponentCommandAsync(IInteractionContext context, string input, IServiceProvider services) { var result = _componentCommandMap.GetCommand(input); @@ -861,15 +861,15 @@ namespace Discord.Interactions return await result.Command.ExecuteAsync(context, services).ConfigureAwait(false); } - private async Task ExecuteAutocompleteAsync (IInteractionContext context, IAutocompleteInteraction interaction, IServiceProvider services ) + private async Task ExecuteAutocompleteAsync(IInteractionContext context, IAutocompleteInteraction interaction, IServiceProvider services) { var keywords = interaction.Data.GetCommandKeywords(); - if(_enableAutocompleteHandlers) + if (_enableAutocompleteHandlers) { var autocompleteHandlerResult = _slashCommandMap.GetCommand(keywords); - if(autocompleteHandlerResult.IsSuccess) + if (autocompleteHandlerResult.IsSuccess) { if (autocompleteHandlerResult.Command._flattenedParameterDictionary.TryGetValue(interaction.Data.Current.Name, out var parameter) && parameter?.AutocompleteHandler is not null) return await parameter.AutocompleteHandler.ExecuteAsync(context, interaction, parameter, services).ConfigureAwait(false); @@ -880,7 +880,7 @@ namespace Discord.Interactions var commandResult = _autocompleteCommandMap.GetCommand(keywords); - if(!commandResult.IsSuccess) + if (!commandResult.IsSuccess) { await _cmdLogger.DebugAsync($"Unknown command name, skipping autocomplete process ({interaction.Data.CommandName.ToUpper()})"); @@ -1109,7 +1109,7 @@ namespace Discord.Interactions { var serializedValues = new string[args.Length]; - for(var i = 0; i < args.Length; i++) + for (var i = 0; i < args.Length; i++) { var arg = args[i]; var typeReader = _typeReaderMap.Get(arg.GetType(), null); @@ -1269,7 +1269,7 @@ namespace Discord.Interactions public async Task ModifyContextCommandPermissionsAsync(ContextCommandInfo command, ulong guildId, params ApplicationCommandPermission[] permissions) => await ModifyApplicationCommandPermissionsAsync(command, guildId, permissions).ConfigureAwait(false); - private async Task ModifyApplicationCommandPermissionsAsync (T command, ulong guildId, + private async Task ModifyApplicationCommandPermissionsAsync(T command, ulong guildId, params ApplicationCommandPermission[] permissions) where T : class, IApplicationCommandInfo, ICommandInfo { if (command is null) @@ -1279,7 +1279,7 @@ namespace Discord.Interactions throw new InvalidOperationException("This command is not a top level application command. You cannot change its permissions"); var commands = await RestClient.GetGuildApplicationCommands(guildId).ConfigureAwait(false); - var appCommand = commands.First(x => x.Name == ( command as IApplicationCommandInfo ).Name); + var appCommand = commands.First(x => x.Name == (command as IApplicationCommandInfo).Name); return await appCommand.ModifyCommandPermissions(permissions).ConfigureAwait(false); } @@ -1293,7 +1293,7 @@ namespace Discord.Interactions /// instance for this command. /// /// Module or Slash Command couldn't be found. - public SlashCommandInfo GetSlashCommandInfo (string methodName) where TModule : class + public SlashCommandInfo GetSlashCommandInfo(string methodName) where TModule : class { var module = GetModuleInfo(); @@ -1309,7 +1309,7 @@ namespace Discord.Interactions /// instance for this command. /// /// Module or Context Command couldn't be found. - public ContextCommandInfo GetContextCommandInfo (string methodName) where TModule : class + public ContextCommandInfo GetContextCommandInfo(string methodName) where TModule : class { var module = GetModuleInfo(); @@ -1325,7 +1325,7 @@ namespace Discord.Interactions /// instance for this command. /// /// Module or Component Command couldn't be found. - public ComponentCommandInfo GetComponentCommandInfo (string methodName) where TModule : class + public ComponentCommandInfo GetComponentCommandInfo(string methodName) where TModule : class { var module = GetModuleInfo(); @@ -1339,7 +1339,7 @@ namespace Discord.Interactions /// /// instance for this module. /// - public ModuleInfo GetModuleInfo ( ) where TModule : class + public ModuleInfo GetModuleInfo() where TModule : class { if (!typeof(IInteractionModuleBase).IsAssignableFrom(typeof(TModule))) throw new ArgumentException("Type parameter must be a type of Slash Module", nameof(TModule)); @@ -1353,7 +1353,7 @@ namespace Discord.Interactions } /// - public void Dispose ( ) + public void Dispose() { _lock.Dispose(); } diff --git a/src/Discord.Net.Interactions/Map/CommandMap.cs b/src/Discord.Net.Interactions/Map/CommandMap.cs index 336e2b1e..17cde1c6 100644 --- a/src/Discord.Net.Interactions/Map/CommandMap.cs +++ b/src/Discord.Net.Interactions/Map/CommandMap.cs @@ -49,7 +49,7 @@ namespace Discord.Interactions public SearchResult GetCommand(string input) { - if(_seperators.Any()) + if (_seperators.Any()) return GetCommand(input.Split(_seperators)); else return GetCommand(new string[] { input }); diff --git a/src/Discord.Net.Interactions/Map/CommandMapNode.cs b/src/Discord.Net.Interactions/Map/CommandMapNode.cs index 3dec30f4..79278ea6 100644 --- a/src/Discord.Net.Interactions/Map/CommandMapNode.cs +++ b/src/Discord.Net.Interactions/Map/CommandMapNode.cs @@ -8,7 +8,7 @@ using System.Text.RegularExpressions; namespace Discord.Interactions { internal class CommandMapNode where T : class, ICommandInfo - { + { private readonly string _wildCardStr = "*"; private readonly ConcurrentDictionary> _nodes; private readonly ConcurrentDictionary _commands; @@ -19,7 +19,7 @@ namespace Discord.Interactions public IReadOnlyDictionary WildCardCommands => _wildCardCommands; public string Name { get; } - public CommandMapNode (string name, string wildCardExp = null) + public CommandMapNode(string name, string wildCardExp = null) { Name = name; _nodes = new ConcurrentDictionary>(); @@ -30,7 +30,7 @@ namespace Discord.Interactions _wildCardStr = wildCardExp; } - public void AddCommand (IList keywords, int index, T commandInfo) + public void AddCommand(IList keywords, int index, T commandInfo) { if (keywords.Count == index + 1) { @@ -54,7 +54,7 @@ namespace Discord.Interactions } } - public bool RemoveCommand (IList keywords, int index) + public bool RemoveCommand(IList keywords, int index) { if (keywords.Count == index + 1) return _commands.TryRemove(keywords[index], out var _); @@ -67,7 +67,7 @@ namespace Discord.Interactions } } - public SearchResult GetCommand (IList keywords, int index) + public SearchResult GetCommand(IList keywords, int index) { string name = string.Join(" ", keywords); @@ -101,7 +101,7 @@ namespace Discord.Interactions return SearchResult.FromError(name, InteractionCommandError.UnknownCommand, $"No {typeof(T).FullName} found for {name}"); } - public SearchResult GetCommand (string text, int index, char[] seperators) + public SearchResult GetCommand(string text, int index, char[] seperators) { var keywords = text.Split(seperators); return GetCommand(keywords, index); diff --git a/src/Discord.Net.Interactions/Results/ExecuteResult.cs b/src/Discord.Net.Interactions/Results/ExecuteResult.cs index ad2ccd1d..91486471 100644 --- a/src/Discord.Net.Interactions/Results/ExecuteResult.cs +++ b/src/Discord.Net.Interactions/Results/ExecuteResult.cs @@ -21,7 +21,7 @@ namespace Discord.Interactions /// public bool IsSuccess => !Error.HasValue; - private ExecuteResult (Exception exception, InteractionCommandError? commandError, string errorReason) + private ExecuteResult(Exception exception, InteractionCommandError? commandError, string errorReason) { Exception = exception; Error = commandError; @@ -34,7 +34,7 @@ namespace Discord.Interactions /// /// A that does not contain any errors. /// - public static ExecuteResult FromSuccess ( ) => + public static ExecuteResult FromSuccess() => new ExecuteResult(null, null, null); /// @@ -46,7 +46,7 @@ namespace Discord.Interactions /// /// A that contains a and reason. /// - public static ExecuteResult FromError (InteractionCommandError commandError, string reason) => + public static ExecuteResult FromError(InteractionCommandError commandError, string reason) => new ExecuteResult(null, commandError, reason); /// @@ -59,7 +59,7 @@ namespace Discord.Interactions /// with a of type Exception as well as the exception message as the /// reason. /// - public static ExecuteResult FromError (Exception exception) => + public static ExecuteResult FromError(Exception exception) => new ExecuteResult(exception, InteractionCommandError.Exception, exception.Message); /// @@ -71,7 +71,7 @@ namespace Discord.Interactions /// /// A that inherits the error type and reason. /// - public static ExecuteResult FromError (IResult result) => + public static ExecuteResult FromError(IResult result) => new ExecuteResult(null, result.Error, result.ErrorReason); /// @@ -81,6 +81,6 @@ namespace Discord.Interactions /// Success if is ; otherwise ": /// ". /// - public override string ToString ( ) => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; + public override string ToString() => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; } } diff --git a/src/Discord.Net.Interactions/Results/PreconditionGroupResult.cs b/src/Discord.Net.Interactions/Results/PreconditionGroupResult.cs index 40acb609..8ee03c80 100644 --- a/src/Discord.Net.Interactions/Results/PreconditionGroupResult.cs +++ b/src/Discord.Net.Interactions/Results/PreconditionGroupResult.cs @@ -14,7 +14,7 @@ namespace Discord.Interactions /// public IReadOnlyCollection Results { get; } - private PreconditionGroupResult (InteractionCommandError? error, string reason, IEnumerable results) : base(error, reason) + private PreconditionGroupResult(InteractionCommandError? error, string reason, IEnumerable results) : base(error, reason) { Results = results?.ToImmutableArray(); } @@ -22,21 +22,21 @@ namespace Discord.Interactions /// /// Returns a with no errors. /// - public static new PreconditionGroupResult FromSuccess ( ) => + public static new PreconditionGroupResult FromSuccess() => new PreconditionGroupResult(null, null, null); /// /// Returns a with and the . /// /// The exception that caused the precondition check to fail. - public static new PreconditionGroupResult FromError (Exception exception) => + public static new PreconditionGroupResult FromError(Exception exception) => new PreconditionGroupResult(InteractionCommandError.Exception, exception.Message, null); /// /// Returns a with the specified type. /// /// The result of failure. - public static new PreconditionGroupResult FromError (IResult result) => + public static new PreconditionGroupResult FromError(IResult result) => new PreconditionGroupResult(result.Error, result.ErrorReason, null); /// @@ -45,7 +45,7 @@ namespace Discord.Interactions /// /// The reason of failure. /// Precondition results of this group - public static PreconditionGroupResult FromError (string reason, IEnumerable results) => + public static PreconditionGroupResult FromError(string reason, IEnumerable results) => new PreconditionGroupResult(InteractionCommandError.UnmetPrecondition, reason, results); } } diff --git a/src/Discord.Net.Interactions/Results/PreconditionResult.cs b/src/Discord.Net.Interactions/Results/PreconditionResult.cs index 3d80f976..52d327ec 100644 --- a/src/Discord.Net.Interactions/Results/PreconditionResult.cs +++ b/src/Discord.Net.Interactions/Results/PreconditionResult.cs @@ -22,7 +22,7 @@ namespace Discord.Interactions /// /// The type of failure. /// The reason of failure. - protected PreconditionResult (InteractionCommandError? error, string reason) + protected PreconditionResult(InteractionCommandError? error, string reason) { Error = error; ErrorReason = reason; @@ -31,21 +31,21 @@ namespace Discord.Interactions /// /// Returns a with no errors. /// - public static PreconditionResult FromSuccess ( ) => + public static PreconditionResult FromSuccess() => new PreconditionResult(null, null); /// /// Returns a with and the . /// /// The exception that caused the precondition check to fail. - public static PreconditionResult FromError (Exception exception) => + public static PreconditionResult FromError(Exception exception) => new PreconditionResult(InteractionCommandError.Exception, exception.Message); /// /// Returns a with the specified type. /// /// The result of failure. - public static PreconditionResult FromError (IResult result) => + public static PreconditionResult FromError(IResult result) => new PreconditionResult(result.Error, result.ErrorReason); /// @@ -53,7 +53,7 @@ namespace Discord.Interactions /// specified reason. /// /// The reason of failure. - public static PreconditionResult FromError (string reason) => + public static PreconditionResult FromError(string reason) => new PreconditionResult(InteractionCommandError.UnmetPrecondition, reason); } } diff --git a/src/Discord.Net.Interactions/Results/RuntimeResult.cs b/src/Discord.Net.Interactions/Results/RuntimeResult.cs index a29b2925..81083a67 100644 --- a/src/Discord.Net.Interactions/Results/RuntimeResult.cs +++ b/src/Discord.Net.Interactions/Results/RuntimeResult.cs @@ -19,7 +19,7 @@ namespace Discord.Interactions /// /// The type of failure, or null if none. /// The reason of failure. - protected RuntimeResult (InteractionCommandError? error, string reason) + protected RuntimeResult(InteractionCommandError? error, string reason) { Error = error; ErrorReason = reason; @@ -32,6 +32,6 @@ namespace Discord.Interactions /// Success if is true; otherwise ": /// ". /// - public override string ToString ( ) => ErrorReason ?? ( IsSuccess ? "Successful" : "Unsuccessful" ); + public override string ToString() => ErrorReason ?? (IsSuccess ? "Successful" : "Unsuccessful"); } } diff --git a/src/Discord.Net.Interactions/Results/SearchResult.cs b/src/Discord.Net.Interactions/Results/SearchResult.cs index 8555e9e5..9b06a54b 100644 --- a/src/Discord.Net.Interactions/Results/SearchResult.cs +++ b/src/Discord.Net.Interactions/Results/SearchResult.cs @@ -32,7 +32,7 @@ namespace Discord.Interactions /// public bool IsSuccess => !Error.HasValue; - private SearchResult (string text, T commandInfo, string[] captureGroups, InteractionCommandError? error, string reason) + private SearchResult(string text, T commandInfo, string[] captureGroups, InteractionCommandError? error, string reason) { Text = text; Error = error; @@ -47,7 +47,7 @@ namespace Discord.Interactions /// /// A that does not contain any errors. /// - public static SearchResult FromSuccess (string text, T commandInfo, string[] wildCardMatch = null) => + public static SearchResult FromSuccess(string text, T commandInfo, string[] wildCardMatch = null) => new SearchResult(text, commandInfo, wildCardMatch, null, null); /// @@ -59,7 +59,7 @@ namespace Discord.Interactions /// /// A that contains a and reason. /// - public static SearchResult FromError (string text, InteractionCommandError error, string reason) => + public static SearchResult FromError(string text, InteractionCommandError error, string reason) => new SearchResult(text, null, null, error, reason); /// @@ -72,7 +72,7 @@ namespace Discord.Interactions /// with a of type Exception as well as the exception message as the /// reason. /// - public static SearchResult FromError (Exception ex) => + public static SearchResult FromError(Exception ex) => new SearchResult(null, null, null, InteractionCommandError.Exception, ex.Message); /// @@ -84,10 +84,10 @@ namespace Discord.Interactions /// /// A that inherits the error type and reason. /// - public static SearchResult FromError (IResult result) => + public static SearchResult FromError(IResult result) => new SearchResult(null, null, null, result.Error, result.ErrorReason); /// - public override string ToString ( ) => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; + public override string ToString() => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; } } diff --git a/src/Discord.Net.Interactions/Results/TypeConverterResult.cs b/src/Discord.Net.Interactions/Results/TypeConverterResult.cs index a9a12ee3..c97e44c4 100644 --- a/src/Discord.Net.Interactions/Results/TypeConverterResult.cs +++ b/src/Discord.Net.Interactions/Results/TypeConverterResult.cs @@ -21,7 +21,7 @@ namespace Discord.Interactions /// public bool IsSuccess => !Error.HasValue; - private TypeConverterResult (object value, InteractionCommandError? error, string reason) + private TypeConverterResult(object value, InteractionCommandError? error, string reason) { Value = value; Error = error; @@ -31,14 +31,14 @@ namespace Discord.Interactions /// /// Returns a with no errors. /// - public static TypeConverterResult FromSuccess (object value) => + public static TypeConverterResult FromSuccess(object value) => new TypeConverterResult(value, null, null); /// /// Returns a with and the . /// /// The exception that caused the type convertion to fail. - public static TypeConverterResult FromError (Exception exception) => + public static TypeConverterResult FromError(Exception exception) => new TypeConverterResult(null, InteractionCommandError.Exception, exception.Message); /// @@ -46,16 +46,16 @@ namespace Discord.Interactions /// /// The type of error. /// The reason of failure. - public static TypeConverterResult FromError (InteractionCommandError error, string reason) => + public static TypeConverterResult FromError(InteractionCommandError error, string reason) => new TypeConverterResult(null, error, reason); /// /// Returns a with the specified type. /// /// The result of failure. - public static TypeConverterResult FromError (IResult result) => + public static TypeConverterResult FromError(IResult result) => new TypeConverterResult(null, result.Error, result.ErrorReason); - public override string ToString ( ) => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; + public override string ToString() => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; } } diff --git a/src/Discord.Net.Interactions/TypeConverters/ComponentInteractions/DefaultArrayComponentConverter.cs b/src/Discord.Net.Interactions/TypeConverters/ComponentInteractions/DefaultArrayComponentConverter.cs index 5efdd537..5dced965 100644 --- a/src/Discord.Net.Interactions/TypeConverters/ComponentInteractions/DefaultArrayComponentConverter.cs +++ b/src/Discord.Net.Interactions/TypeConverters/ComponentInteractions/DefaultArrayComponentConverter.cs @@ -34,7 +34,7 @@ namespace Discord.Interactions { var objs = new List(); - if(_typeReader is not null && option.Values.Count > 0) + if (_typeReader is not null && option.Values.Count > 0) foreach (var value in option.Values) { var result = await _typeReader.ReadAsync(context, value, services).ConfigureAwait(false); @@ -52,13 +52,13 @@ namespace Discord.Interactions foreach (var user in option.Users) users[user.Id] = user; - if(option.Members is not null) - foreach(var member in option.Members) + if (option.Members is not null) + foreach (var member in option.Members) users[member.Id] = member; objs.AddRange(users.Values); - if(option.Roles is not null) + if (option.Roles is not null) objs.AddRange(option.Roles); if (option.Channels is not null) diff --git a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultEntityTypeConverter.cs b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultEntityTypeConverter.cs index fb493ed7..76f135a9 100644 --- a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultEntityTypeConverter.cs +++ b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultEntityTypeConverter.cs @@ -9,7 +9,7 @@ namespace Discord.Interactions { internal abstract class DefaultEntityTypeConverter : TypeConverter where T : class { - public override Task ReadAsync (IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) + public override Task ReadAsync(IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) { var value = option.Value as T; @@ -27,19 +27,19 @@ namespace Discord.Interactions internal class DefaultRoleConverter : DefaultEntityTypeConverter where T : class, IRole { - public override ApplicationCommandOptionType GetDiscordType ( ) => ApplicationCommandOptionType.Role; + public override ApplicationCommandOptionType GetDiscordType() => ApplicationCommandOptionType.Role; } internal class DefaultUserConverter : DefaultEntityTypeConverter where T : class, IUser { - public override ApplicationCommandOptionType GetDiscordType ( ) => ApplicationCommandOptionType.User; + public override ApplicationCommandOptionType GetDiscordType() => ApplicationCommandOptionType.User; } internal class DefaultChannelConverter : DefaultEntityTypeConverter where T : class, IChannel { private readonly List _channelTypes; - public DefaultChannelConverter ( ) + public DefaultChannelConverter() { var type = typeof(T); @@ -73,9 +73,9 @@ namespace Discord.Interactions }; } - public override ApplicationCommandOptionType GetDiscordType ( ) => ApplicationCommandOptionType.Channel; + public override ApplicationCommandOptionType GetDiscordType() => ApplicationCommandOptionType.Channel; - public override void Write (ApplicationCommandOptionProperties properties, IParameterInfo parameter) + public override void Write(ApplicationCommandOptionProperties properties, IParameterInfo parameter) { if (_channelTypes is not null) properties.ChannelTypes = _channelTypes; @@ -84,6 +84,6 @@ namespace Discord.Interactions internal class DefaultMentionableConverter : DefaultEntityTypeConverter where T : class, IMentionable { - public override ApplicationCommandOptionType GetDiscordType ( ) => ApplicationCommandOptionType.Mentionable; + public override ApplicationCommandOptionType GetDiscordType() => ApplicationCommandOptionType.Mentionable; } } diff --git a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultValueConverter.cs b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultValueConverter.cs index 8e049ea7..15f61649 100644 --- a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultValueConverter.cs +++ b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/DefaultValueConverter.cs @@ -6,7 +6,7 @@ namespace Discord.Interactions { internal class DefaultValueConverter : TypeConverter where T : IConvertible { - public override ApplicationCommandOptionType GetDiscordType ( ) + public override ApplicationCommandOptionType GetDiscordType() { switch (Type.GetTypeCode(typeof(T))) { @@ -38,7 +38,7 @@ namespace Discord.Interactions throw new InvalidOperationException($"Parameter Type {typeof(T).FullName} is not supported by Discord."); } } - public override Task ReadAsync (IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) + public override Task ReadAsync(IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) { object value; diff --git a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/EnumConverter.cs b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/EnumConverter.cs index 1406c6f1..18609836 100644 --- a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/EnumConverter.cs +++ b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/EnumConverter.cs @@ -9,8 +9,8 @@ namespace Discord.Interactions { internal sealed class EnumConverter : TypeConverter where T : struct, Enum { - public override ApplicationCommandOptionType GetDiscordType ( ) => ApplicationCommandOptionType.String; - public override Task ReadAsync (IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) + public override ApplicationCommandOptionType GetDiscordType() => ApplicationCommandOptionType.String; + public override Task ReadAsync(IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) { if (Enum.TryParse((string)option.Value, out var result)) return Task.FromResult(TypeConverterResult.FromSuccess(result)); @@ -18,7 +18,7 @@ namespace Discord.Interactions return Task.FromResult(TypeConverterResult.FromError(InteractionCommandError.ConvertFailed, $"Value {option.Value} cannot be converted to {nameof(T)}")); } - public override void Write (ApplicationCommandOptionProperties properties, IParameterInfo parameterInfo) + public override void Write(ApplicationCommandOptionProperties properties, IParameterInfo parameterInfo) { var names = Enum.GetNames(typeof(T)); var members = names.SelectMany(x => typeof(T).GetMember(x)).Where(x => !x.IsDefined(typeof(HideAttribute), true)); diff --git a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/TimeSpanConverter.cs b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/TimeSpanConverter.cs index 9a5274ff..a299de09 100644 --- a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/TimeSpanConverter.cs +++ b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/TimeSpanConverter.cs @@ -7,10 +7,10 @@ namespace Discord.Interactions { internal sealed class TimeSpanConverter : TypeConverter { - public override ApplicationCommandOptionType GetDiscordType ( ) => ApplicationCommandOptionType.String; - public override Task ReadAsync (IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) + public override ApplicationCommandOptionType GetDiscordType() => ApplicationCommandOptionType.String; + public override Task ReadAsync(IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services) { - return ( TimeSpan.TryParseExact(( option.Value as string ).ToLowerInvariant(), Formats, CultureInfo.InvariantCulture, out var timeSpan) ) + return (TimeSpan.TryParseExact((option.Value as string).ToLowerInvariant(), Formats, CultureInfo.InvariantCulture, out var timeSpan)) ? Task.FromResult(TypeConverterResult.FromSuccess(timeSpan)) : Task.FromResult(TypeConverterResult.FromError(InteractionCommandError.ConvertFailed, "Failed to parse TimeSpan")); } diff --git a/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs b/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs index 52573e1d..1d1370cd 100644 --- a/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs +++ b/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs @@ -296,7 +296,7 @@ namespace Discord.Interactions throw new InvalidOperationException($"{input.GetType().FullName} isn't a valid component info class"); } - if(modifyModal is not null) + if (modifyModal is not null) modifyModal(builder); return builder.Build(); diff --git a/src/Discord.Net.Interactions/Utilities/EmptyServiceProvider.cs b/src/Discord.Net.Interactions/Utilities/EmptyServiceProvider.cs index a5380094..172f11cc 100644 --- a/src/Discord.Net.Interactions/Utilities/EmptyServiceProvider.cs +++ b/src/Discord.Net.Interactions/Utilities/EmptyServiceProvider.cs @@ -6,6 +6,6 @@ namespace Discord.Interactions { public static EmptyServiceProvider Instance => new EmptyServiceProvider(); - public object GetService (Type serviceType) => null; + public object GetService(Type serviceType) => null; } } diff --git a/src/Discord.Net.Interactions/Utilities/InteractionUtility.cs b/src/Discord.Net.Interactions/Utilities/InteractionUtility.cs index 9751b613..99af408e 100644 --- a/src/Discord.Net.Interactions/Utilities/InteractionUtility.cs +++ b/src/Discord.Net.Interactions/Utilities/InteractionUtility.cs @@ -21,7 +21,7 @@ namespace Discord.Interactions /// A Task representing the asyncronous waiting operation. If the user responded in the given amount of time, Task result contains the user response, /// otherwise the Task result is . /// - public static async Task WaitForInteractionAsync (BaseSocketClient client, TimeSpan timeout, + public static async Task WaitForInteractionAsync(BaseSocketClient client, TimeSpan timeout, Predicate predicate, CancellationToken cancellationToken = default) { var tcs = new TaskCompletionSource(); @@ -34,7 +34,7 @@ namespace Discord.Interactions tcs.SetResult(null); }); - cancellationToken.Register(( ) => tcs.SetCanceled()); + cancellationToken.Register(() => tcs.SetCanceled()); client.InteractionCreated += HandleInteraction; var result = await tcs.Task.ConfigureAwait(false); @@ -42,7 +42,7 @@ namespace Discord.Interactions return result; - Task HandleInteraction (SocketInteraction interaction) + Task HandleInteraction(SocketInteraction interaction) { if (predicate(interaction)) { @@ -68,7 +68,7 @@ namespace Discord.Interactions public static Task WaitForMessageComponentAsync(BaseSocketClient client, IUserMessage fromMessage, TimeSpan timeout, CancellationToken cancellationToken = default) { - bool Predicate (SocketInteraction interaction) => interaction is SocketMessageComponent component && + bool Predicate(SocketInteraction interaction) => interaction is SocketMessageComponent component && component.Message.Id == fromMessage.Id; return WaitForInteractionAsync(client, timeout, Predicate, cancellationToken); @@ -86,7 +86,7 @@ namespace Discord.Interactions /// A Task representing the asyncronous waiting operation with a result, /// the result is if the user declined the prompt or didnt answer in time, if the user confirmed the prompt. /// - public static async Task ConfirmAsync (BaseSocketClient client, IMessageChannel channel, TimeSpan timeout, string message = null, + public static async Task ConfirmAsync(BaseSocketClient client, IMessageChannel channel, TimeSpan timeout, string message = null, CancellationToken cancellationToken = default) { message ??= "Would you like to continue?"; diff --git a/src/Discord.Net.Interactions/Utilities/ReflectionUtils.cs b/src/Discord.Net.Interactions/Utilities/ReflectionUtils.cs index 0988f1f0..e642495c 100644 --- a/src/Discord.Net.Interactions/Utilities/ReflectionUtils.cs +++ b/src/Discord.Net.Interactions/Utilities/ReflectionUtils.cs @@ -10,10 +10,10 @@ namespace Discord.Interactions internal static class ReflectionUtils { private static readonly TypeInfo ObjectTypeInfo = typeof(object).GetTypeInfo(); - internal static T CreateObject (TypeInfo typeInfo, InteractionService commandService, IServiceProvider services = null) => + internal static T CreateObject(TypeInfo typeInfo, InteractionService commandService, IServiceProvider services = null) => CreateBuilder(typeInfo, commandService)(services); - internal static Func CreateBuilder (TypeInfo typeInfo, InteractionService commandService) + internal static Func CreateBuilder(TypeInfo typeInfo, InteractionService commandService) { var constructor = GetConstructor(typeInfo); var parameters = constructor.GetParameters(); @@ -32,7 +32,7 @@ namespace Discord.Interactions }; } - private static T InvokeConstructor (ConstructorInfo constructor, object[] args, TypeInfo ownerType) + private static T InvokeConstructor(ConstructorInfo constructor, object[] args, TypeInfo ownerType) { try { @@ -43,7 +43,7 @@ namespace Discord.Interactions throw new Exception($"Failed to create \"{ownerType.FullName}\".", ex); } } - private static ConstructorInfo GetConstructor (TypeInfo ownerType) + private static ConstructorInfo GetConstructor(TypeInfo ownerType) { var constructors = ownerType.DeclaredConstructors.Where(x => !x.IsStatic).ToArray(); if (constructors.Length == 0) @@ -52,7 +52,7 @@ namespace Discord.Interactions throw new InvalidOperationException($"Multiple constructors found for \"{ownerType.FullName}\"."); return constructors[0]; } - private static PropertyInfo[] GetProperties (TypeInfo ownerType) + private static PropertyInfo[] GetProperties(TypeInfo ownerType) { var result = new List(); while (ownerType != ObjectTypeInfo) @@ -66,7 +66,7 @@ namespace Discord.Interactions } return result.ToArray(); } - private static object GetMember (InteractionService commandService, IServiceProvider services, Type memberType, TypeInfo ownerType) + private static object GetMember(InteractionService commandService, IServiceProvider services, Type memberType, TypeInfo ownerType) { if (memberType == typeof(InteractionService)) return commandService; @@ -78,7 +78,7 @@ namespace Discord.Interactions throw new InvalidOperationException($"Failed to create \"{ownerType.FullName}\", dependency \"{memberType.Name}\" was not found."); } - internal static Func CreateMethodInvoker (MethodInfo methodInfo) + internal static Func CreateMethodInvoker(MethodInfo methodInfo) { var parameters = methodInfo.GetParameters(); var paramsExp = new Expression[parameters.Length]; @@ -105,7 +105,7 @@ namespace Discord.Interactions /// /// Create a type initializer using compiled lambda expressions /// - internal static Func CreateLambdaBuilder (TypeInfo typeInfo, InteractionService commandService) + internal static Func CreateLambdaBuilder(TypeInfo typeInfo, InteractionService commandService) { var constructor = GetConstructor(typeInfo); var parameters = constructor.GetParameters(); diff --git a/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs b/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs index 6e434d46..40bd0c1b 100644 --- a/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs +++ b/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs @@ -37,7 +37,7 @@ namespace Discord.API [JsonProperty("description_localized")] public Optional DescriptionLocalized { get; set; } - + // V2 Permissions [JsonProperty("dm_permission")] public Optional DmPermission { get; set; } diff --git a/src/Discord.Net.Rest/API/Common/AuditLogChange.cs b/src/Discord.Net.Rest/API/Common/AuditLogChange.cs index 44e58502..c2efcc7f 100644 --- a/src/Discord.Net.Rest/API/Common/AuditLogChange.cs +++ b/src/Discord.Net.Rest/API/Common/AuditLogChange.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs b/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs index b666215e..1b0144cf 100644 --- a/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs +++ b/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Discord.API { diff --git a/src/Discord.Net.Rest/API/Common/Embed.cs b/src/Discord.Net.Rest/API/Common/Embed.cs index 77efa12a..05709362 100644 --- a/src/Discord.Net.Rest/API/Common/Embed.cs +++ b/src/Discord.Net.Rest/API/Common/Embed.cs @@ -1,6 +1,6 @@ -using System; -using Newtonsoft.Json; using Discord.Net.Converters; +using Newtonsoft.Json; +using System; namespace Discord.API { diff --git a/src/Discord.Net.Rest/API/Common/EmbedField.cs b/src/Discord.Net.Rest/API/Common/EmbedField.cs index 6ce810f1..8afd02be 100644 --- a/src/Discord.Net.Rest/API/Common/EmbedField.cs +++ b/src/Discord.Net.Rest/API/Common/EmbedField.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Discord.API { diff --git a/src/Discord.Net.Rest/API/Common/GameSecrets.cs b/src/Discord.Net.Rest/API/Common/GameSecrets.cs index e70b48ff..dc9bbf1d 100644 --- a/src/Discord.Net.Rest/API/Common/GameSecrets.cs +++ b/src/Discord.Net.Rest/API/Common/GameSecrets.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Discord.API { @@ -11,4 +11,4 @@ namespace Discord.API [JsonProperty("spectate")] public string Spectate { get; set; } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/API/Common/GameTimestamps.cs b/src/Discord.Net.Rest/API/Common/GameTimestamps.cs index 5c6f10b8..ea324d9f 100644 --- a/src/Discord.Net.Rest/API/Common/GameTimestamps.cs +++ b/src/Discord.Net.Rest/API/Common/GameTimestamps.cs @@ -1,5 +1,5 @@ -using System; using Newtonsoft.Json; +using System; namespace Discord.API { @@ -12,4 +12,4 @@ namespace Discord.API [UnixTimestamp] public Optional End { get; set; } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/API/Common/Reaction.cs b/src/Discord.Net.Rest/API/Common/Reaction.cs index 4d368ab2..ffe7a478 100644 --- a/src/Discord.Net.Rest/API/Common/Reaction.cs +++ b/src/Discord.Net.Rest/API/Common/Reaction.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Discord.API { diff --git a/src/Discord.Net.Rest/API/Common/WelcomeScreenChannel.cs b/src/Discord.Net.Rest/API/Common/WelcomeScreenChannel.cs index 426883dc..b82fb923 100644 --- a/src/Discord.Net.Rest/API/Common/WelcomeScreenChannel.cs +++ b/src/Discord.Net.Rest/API/Common/WelcomeScreenChannel.cs @@ -14,5 +14,5 @@ internal class WelcomeScreenChannel public Optional EmojiId { get; set; } [JsonProperty("emoji_name")] - public Optional EmojiName{ get; set; } + public Optional EmojiName { get; set; } } diff --git a/src/Discord.Net.Rest/API/EntityOrId.cs b/src/Discord.Net.Rest/API/EntityOrId.cs index 9bcda260..b375d963 100644 --- a/src/Discord.Net.Rest/API/EntityOrId.cs +++ b/src/Discord.Net.Rest/API/EntityOrId.cs @@ -1,4 +1,4 @@ -namespace Discord.API +namespace Discord.API { internal struct EntityOrId { diff --git a/src/Discord.Net.Rest/API/Image.cs b/src/Discord.Net.Rest/API/Image.cs index b2357a0a..c37b77c4 100644 --- a/src/Discord.Net.Rest/API/Image.cs +++ b/src/Discord.Net.Rest/API/Image.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.IO; namespace Discord.API { diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs index fce9df11..017f9539 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs @@ -3,6 +3,6 @@ namespace Discord.API.Rest internal class CreateGuildBanParams { public Optional DeleteMessageDays { get; set; } - public string Reason { get; set; } + public string Reason { get; set; } } } diff --git a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs index 466ad41e..7b0d842d 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs @@ -28,7 +28,7 @@ namespace Discord.API.Rest [JsonProperty("sticker_ids")] public Optional Stickers { get; set; } - + [JsonProperty("flags")] public Optional Flags { get; set; } diff --git a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs index ef0e0dd1..297c28d5 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs @@ -13,7 +13,7 @@ namespace Discord.API.Rest private static JsonSerializer _serializer = new JsonSerializer { ContractResolver = new DiscordContractResolver() }; [JsonProperty("content")] - public Optional Content { get; set; } + public Optional Content { get; set; } [JsonProperty("nonce")] public Optional Nonce { get; set; } diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs index 420bdbea..cf78abfe 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs @@ -4,7 +4,7 @@ namespace Discord.API.Rest { [JsonObject(MemberSerialization = MemberSerialization.OptIn)] internal class ModifyGuildEmbedParams - { + { [JsonProperty("enabled")] public Optional Enabled { get; set; } [JsonProperty("channel")] diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs index 2e5658d5..a1c1a506 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs @@ -4,7 +4,7 @@ namespace Discord.API.Rest { [JsonObject(MemberSerialization = MemberSerialization.OptIn)] internal class ModifyGuildWidgetParams - { + { [JsonProperty("enabled")] public Optional Enabled { get; set; } [JsonProperty("channel")] diff --git a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs index b85ff646..82725c9a 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs @@ -32,7 +32,7 @@ namespace Discord.API.Rest public IReadOnlyDictionary ToDictionary() { var d = new Dictionary(); - + var payload = new Dictionary(); if (Content.IsSpecified) payload["content"] = Content.Value; @@ -55,7 +55,7 @@ namespace Discord.API.Rest List attachments = new(); - for(int n = 0; n != Files.Length; n++) + for (int n = 0; n != Files.Length; n++) { var attachment = Files[n]; diff --git a/src/Discord.Net.Rest/API/Rest/UploadInteractionFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadInteractionFileParams.cs index ca0f49cc..eda650cd 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadInteractionFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadInteractionFileParams.cs @@ -41,7 +41,7 @@ namespace Discord.API.Rest public IReadOnlyDictionary ToDictionary() { var d = new Dictionary(); - + var payload = new Dictionary(); payload["type"] = Type; diff --git a/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs index d945d149..60dc1baf 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; using Discord.Net.Converters; using Discord.Net.Rest; using Newtonsoft.Json; +using System.Collections.Generic; +using System.IO; +using System.Text; namespace Discord.API.Rest { diff --git a/src/Discord.Net.Rest/API/UnixTimestampAttribute.cs b/src/Discord.Net.Rest/API/UnixTimestampAttribute.cs index 3890ffc4..eac4573f 100644 --- a/src/Discord.Net.Rest/API/UnixTimestampAttribute.cs +++ b/src/Discord.Net.Rest/API/UnixTimestampAttribute.cs @@ -1,7 +1,7 @@ -using System; +using System; namespace Discord.API { [AttributeUsage(AttributeTargets.Property)] internal class UnixTimestampAttribute : Attribute { } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/BaseDiscordClient.cs b/src/Discord.Net.Rest/BaseDiscordClient.cs index 686c7b03..2af84a9c 100644 --- a/src/Discord.Net.Rest/BaseDiscordClient.cs +++ b/src/Discord.Net.Rest/BaseDiscordClient.cs @@ -126,7 +126,8 @@ namespace Discord.Rest } internal virtual async Task LogoutInternalAsync() { - if (LoginState == LoginState.LoggedOut) return; + if (LoginState == LoginState.LoggedOut) + return; LoginState = LoginState.LoggingOut; await ApiClient.LogoutAsync().ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/ClientHelper.cs b/src/Discord.Net.Rest/ClientHelper.cs index 61766131..3950cd31 100644 --- a/src/Discord.Net.Rest/ClientHelper.cs +++ b/src/Discord.Net.Rest/ClientHelper.cs @@ -1,5 +1,5 @@ -using System; using Discord.API.Rest; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.IO; diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 64964adf..c6e5c495 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -563,7 +563,7 @@ namespace Discord.API await SendAsync("DELETE", () => $"channels/{channelId}/thread-members/{userId}", bucket, options: options).ConfigureAwait(false); } - + public async Task ListThreadMembersAsync(ulong channelId, ulong? after = null, int? limit = null, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); @@ -1154,7 +1154,7 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); var ids = new BucketIds(channelId: newsChannelId); - return await SendJsonAsync("POST", () => $"channels/{newsChannelId}/followers", new { webhook_channel_id = followingChannelId}, ids, options: options).ConfigureAwait(false); + return await SendJsonAsync("POST", () => $"channels/{newsChannelId}/followers", new { webhook_channel_id = followingChannelId }, ids, options: options).ConfigureAwait(false); } #endregion diff --git a/src/Discord.Net.Rest/DiscordRestClient.cs b/src/Discord.Net.Rest/DiscordRestClient.cs index dbb2b991..7e976cfc 100644 --- a/src/Discord.Net.Rest/DiscordRestClient.cs +++ b/src/Discord.Net.Rest/DiscordRestClient.cs @@ -68,7 +68,7 @@ namespace Discord.Rest ApiClient.CurrentUserId = user.Id; base.CurrentUser = RestSelfUser.Create(this, user); - if(tokenType == TokenType.Bot) + if (tokenType == TokenType.Bot) { await GetApplicationInfoAsync(new RequestOptions { RetryMode = RetryMode.AlwaysRetry }).ConfigureAwait(false); ApiClient.CurrentApplicationId = _applicationInfo.Id; @@ -151,7 +151,7 @@ namespace Discord.Rest } #endregion - + public async Task GetCurrentUserAsync(RequestOptions options = null) { var user = await ApiClient.GetMyUserAsync(options); diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs b/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs index f071fc1f..2b850924 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs @@ -1,8 +1,7 @@ using System; using System.Collections.Generic; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { @@ -10,56 +9,56 @@ namespace Discord.Rest { private static readonly Dictionary> CreateMapping = new Dictionary>() - { - [ActionType.GuildUpdated] = GuildUpdateAuditLogData.Create, + { + [ActionType.GuildUpdated] = GuildUpdateAuditLogData.Create, - [ActionType.ChannelCreated] = ChannelCreateAuditLogData.Create, - [ActionType.ChannelUpdated] = ChannelUpdateAuditLogData.Create, - [ActionType.ChannelDeleted] = ChannelDeleteAuditLogData.Create, + [ActionType.ChannelCreated] = ChannelCreateAuditLogData.Create, + [ActionType.ChannelUpdated] = ChannelUpdateAuditLogData.Create, + [ActionType.ChannelDeleted] = ChannelDeleteAuditLogData.Create, - [ActionType.OverwriteCreated] = OverwriteCreateAuditLogData.Create, - [ActionType.OverwriteUpdated] = OverwriteUpdateAuditLogData.Create, - [ActionType.OverwriteDeleted] = OverwriteDeleteAuditLogData.Create, + [ActionType.OverwriteCreated] = OverwriteCreateAuditLogData.Create, + [ActionType.OverwriteUpdated] = OverwriteUpdateAuditLogData.Create, + [ActionType.OverwriteDeleted] = OverwriteDeleteAuditLogData.Create, - [ActionType.Kick] = KickAuditLogData.Create, - [ActionType.Prune] = PruneAuditLogData.Create, - [ActionType.Ban] = BanAuditLogData.Create, - [ActionType.Unban] = UnbanAuditLogData.Create, - [ActionType.MemberUpdated] = MemberUpdateAuditLogData.Create, - [ActionType.MemberRoleUpdated] = MemberRoleAuditLogData.Create, - [ActionType.MemberMoved] = MemberMoveAuditLogData.Create, - [ActionType.MemberDisconnected] = MemberDisconnectAuditLogData.Create, - [ActionType.BotAdded] = BotAddAuditLogData.Create, + [ActionType.Kick] = KickAuditLogData.Create, + [ActionType.Prune] = PruneAuditLogData.Create, + [ActionType.Ban] = BanAuditLogData.Create, + [ActionType.Unban] = UnbanAuditLogData.Create, + [ActionType.MemberUpdated] = MemberUpdateAuditLogData.Create, + [ActionType.MemberRoleUpdated] = MemberRoleAuditLogData.Create, + [ActionType.MemberMoved] = MemberMoveAuditLogData.Create, + [ActionType.MemberDisconnected] = MemberDisconnectAuditLogData.Create, + [ActionType.BotAdded] = BotAddAuditLogData.Create, - [ActionType.RoleCreated] = RoleCreateAuditLogData.Create, - [ActionType.RoleUpdated] = RoleUpdateAuditLogData.Create, - [ActionType.RoleDeleted] = RoleDeleteAuditLogData.Create, + [ActionType.RoleCreated] = RoleCreateAuditLogData.Create, + [ActionType.RoleUpdated] = RoleUpdateAuditLogData.Create, + [ActionType.RoleDeleted] = RoleDeleteAuditLogData.Create, - [ActionType.InviteCreated] = InviteCreateAuditLogData.Create, - [ActionType.InviteUpdated] = InviteUpdateAuditLogData.Create, - [ActionType.InviteDeleted] = InviteDeleteAuditLogData.Create, + [ActionType.InviteCreated] = InviteCreateAuditLogData.Create, + [ActionType.InviteUpdated] = InviteUpdateAuditLogData.Create, + [ActionType.InviteDeleted] = InviteDeleteAuditLogData.Create, - [ActionType.WebhookCreated] = WebhookCreateAuditLogData.Create, - [ActionType.WebhookUpdated] = WebhookUpdateAuditLogData.Create, - [ActionType.WebhookDeleted] = WebhookDeleteAuditLogData.Create, + [ActionType.WebhookCreated] = WebhookCreateAuditLogData.Create, + [ActionType.WebhookUpdated] = WebhookUpdateAuditLogData.Create, + [ActionType.WebhookDeleted] = WebhookDeleteAuditLogData.Create, - [ActionType.EmojiCreated] = EmoteCreateAuditLogData.Create, - [ActionType.EmojiUpdated] = EmoteUpdateAuditLogData.Create, - [ActionType.EmojiDeleted] = EmoteDeleteAuditLogData.Create, + [ActionType.EmojiCreated] = EmoteCreateAuditLogData.Create, + [ActionType.EmojiUpdated] = EmoteUpdateAuditLogData.Create, + [ActionType.EmojiDeleted] = EmoteDeleteAuditLogData.Create, - [ActionType.MessageDeleted] = MessageDeleteAuditLogData.Create, - [ActionType.MessageBulkDeleted] = MessageBulkDeleteAuditLogData.Create, - [ActionType.MessagePinned] = MessagePinAuditLogData.Create, - [ActionType.MessageUnpinned] = MessageUnpinAuditLogData.Create, + [ActionType.MessageDeleted] = MessageDeleteAuditLogData.Create, + [ActionType.MessageBulkDeleted] = MessageBulkDeleteAuditLogData.Create, + [ActionType.MessagePinned] = MessagePinAuditLogData.Create, + [ActionType.MessageUnpinned] = MessageUnpinAuditLogData.Create, - [ActionType.EventCreate] = ScheduledEventCreateAuditLogData.Create, - [ActionType.EventUpdate] = ScheduledEventUpdateAuditLogData.Create, - [ActionType.EventDelete] = ScheduledEventDeleteAuditLogData.Create, + [ActionType.EventCreate] = ScheduledEventCreateAuditLogData.Create, + [ActionType.EventUpdate] = ScheduledEventUpdateAuditLogData.Create, + [ActionType.EventDelete] = ScheduledEventDeleteAuditLogData.Create, - [ActionType.ThreadCreate] = ThreadCreateAuditLogData.Create, - [ActionType.ThreadUpdate] = ThreadUpdateAuditLogData.Create, - [ActionType.ThreadDelete] = ThreadDeleteAuditLogData.Create, - }; + [ActionType.ThreadCreate] = ThreadCreateAuditLogData.Create, + [ActionType.ThreadUpdate] = ThreadUpdateAuditLogData.Create, + [ActionType.ThreadDelete] = ThreadDeleteAuditLogData.Create, + }; public static IAuditLogData CreateData(BaseDiscordClient discord, Model log, EntryModel entry) { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs index 7246ac19..3a599ca0 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs index 288cb9d0..3e9394e8 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs index 5c2f81ae..07e90bce 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs index 81ae7155..d70b48ce 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs index b2294f18..90b69c4f 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs index 92e92574..4a0716de 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs index fd307d5a..3e58f3c1 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs index 96e791d8..0603e4b3 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs index 80b719a6..45673e97 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs index 3560b9a2..21b8410c 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs index 2dc2f22f..af5c929d 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs index 95bfb845..5d282666 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs index b533f026..02ec8a10 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs index b0374dc8..4181d9e9 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs @@ -1,5 +1,5 @@ -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs index f5373d34..cd60d0f2 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs @@ -1,5 +1,5 @@ -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs index 276604d0..339c6150 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs index f3437e62..57dca0f4 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs index 7a984634..ed6563d3 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs @@ -1,5 +1,5 @@ -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs index 746fc2ea..a4672326 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs @@ -1,8 +1,7 @@ -using System.Linq; - -using Model = Discord.API.AuditLog; -using EntryModel = Discord.API.AuditLogEntry; using System; +using System.Linq; +using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs index c33fd5f4..b740af46 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs index f6fd3177..654f3e02 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs index 3f391187..3990f643 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs @@ -1,7 +1,6 @@ -using System.Linq; - -using Model = Discord.API.AuditLog; +using System.Linq; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs index dc8948d3..a959c301 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs index c2b8d423..9aee0813 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs @@ -1,7 +1,6 @@ -using System.Linq; - -using Model = Discord.API.AuditLog; +using System.Linq; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs index c32d12b3..1f08eab5 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs @@ -1,5 +1,5 @@ -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs index cee255fb..be635ecb 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs @@ -1,7 +1,6 @@ -using System.Linq; - -using Model = Discord.API.AuditLog; +using System.Linq; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs index 78b5efc8..feb8064b 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs @@ -1,7 +1,6 @@ -using System.Linq; - -using Model = Discord.API.AuditLog; +using System.Linq; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs index 094e1e0e..89b2db3e 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs @@ -1,7 +1,6 @@ -using System.Linq; - -using Model = Discord.API.AuditLog; +using System.Linq; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs index 11faa337..823c60a7 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs @@ -1,9 +1,8 @@ +using Discord.API; using System; using System.Linq; -using Discord.API; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { @@ -14,22 +13,22 @@ namespace Discord.Rest { private ScheduledEventCreateAuditLogData(ulong id, ulong guildId, ulong? channelId, ulong? creatorId, string name, string description, DateTimeOffset scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel privacyLevel, GuildScheduledEventStatus status, GuildScheduledEventType entityType, ulong? entityId, string location, RestUser creator, int userCount, string image) { - Id = id ; - GuildId = guildId ; - ChannelId = channelId ; - CreatorId = creatorId ; - Name = name ; - Description = description ; + Id = id; + GuildId = guildId; + ChannelId = channelId; + CreatorId = creatorId; + Name = name; + Description = description; ScheduledStartTime = scheduledStartTime; - ScheduledEndTime = scheduledEndTime ; - PrivacyLevel = privacyLevel ; - Status = status ; - EntityType = entityType ; - EntityId = entityId ; - Location = location ; - Creator = creator ; - UserCount = userCount ; - Image = image ; + ScheduledEndTime = scheduledEndTime; + PrivacyLevel = privacyLevel; + Status = status; + EntityType = entityType; + EntityId = entityId; + Location = location; + Creator = creator; + UserCount = userCount; + Image = image; } internal static ScheduledEventCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs index 34fa9622..d8910348 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs @@ -1,9 +1,8 @@ +using Discord.API; using System; using System.Linq; -using Discord.API; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs index 98112edb..868c8e9d 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs @@ -62,19 +62,19 @@ namespace Discord.Rest internal ScheduledEventInfo(ulong? guildId, ulong? channelId, string name, string description, DateTimeOffset? scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel? privacyLevel, GuildScheduledEventStatus? status, GuildScheduledEventType? entityType, ulong? entityId, Optional location, int? userCount, string image) { - GuildId = guildId ; - ChannelId = channelId ; - Name = name ; - Description = description ; + GuildId = guildId; + ChannelId = channelId; + Name = name; + Description = description; ScheduledStartTime = scheduledStartTime; - ScheduledEndTime = scheduledEndTime ; - PrivacyLevel = privacyLevel ; - Status = status ; - EntityType = entityType ; - EntityId = entityId ; - Location = location ; - UserCount = userCount ; - Image = image ; + ScheduledEndTime = scheduledEndTime; + PrivacyLevel = privacyLevel; + Status = status; + EntityType = entityType; + EntityId = entityId; + Location = location; + UserCount = userCount; + Image = image; } } } diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs index 042cfd1c..e39759a4 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs @@ -1,8 +1,7 @@ using System; using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { @@ -13,9 +12,9 @@ namespace Discord.Rest { private ScheduledEventUpdateAuditLogData(ulong id, ScheduledEventInfo before, ScheduledEventInfo after) { - Id = id; + Id = id; Before = before; - After = after; + After = after; } internal static ScheduledEventUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs index eac99e87..778ecb1e 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs @@ -1,6 +1,6 @@ using System.Linq; -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs index d22c5601..becf0aa4 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs @@ -1,6 +1,6 @@ using System.Linq; -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs index 93a0344b..dfcf1386 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs @@ -1,6 +1,6 @@ using System.Linq; -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadCreateAuditLogData.cs index f1cacd72..d93529a2 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadCreateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadDeleteAuditLogData.cs index 962ec177..31e6420c 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadDeleteAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs index 8eb03114..9eb6b56d 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { @@ -51,7 +50,7 @@ namespace Discord.Rest var threadInfo = log.Threads.FirstOrDefault(x => x.Id == id); var threadChannel = threadInfo == null ? null : RestThreadChannel.Create(discord, (IGuild)null, threadInfo); - return new ThreadUpdateAuditLogData(threadChannel,type, before, after); + return new ThreadUpdateAuditLogData(threadChannel, type, before, after); } // Doc Note: Corresponds to the *current* data diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/UnbanAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/UnbanAuditLogData.cs index f12d9a1a..df8da5ff 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/UnbanAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/UnbanAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookCreateAuditLogData.cs index 81d902fc..ff6bc944 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookCreateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookCreateAuditLogData.cs @@ -1,7 +1,6 @@ -using System.Linq; - -using Model = Discord.API.AuditLog; +using System.Linq; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookDeleteAuditLogData.cs index 308020c9..4ab5ac99 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookDeleteAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookUpdateAuditLogData.cs index 18fe865d..c1540b0d 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/WebhookUpdateAuditLogData.cs @@ -1,7 +1,6 @@ using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs b/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs index 2176eab7..26b1cfe0 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs @@ -1,8 +1,7 @@ using System; using System.Linq; - -using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; +using Model = Discord.API.AuditLog; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs index 2b5511e0..fbfa0f3d 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs @@ -269,7 +269,7 @@ namespace Discord.Rest /// Message content is too long, length must be less or equal to . /// The only valid are and . public static async Task SendMessageAsync(IMessageChannel channel, BaseDiscordClient client, - string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, + string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, Embed[] embeds, MessageFlags flags) { embeds ??= Array.Empty(); @@ -345,41 +345,41 @@ namespace Discord.Rest /// Message content is too long, length must be less or equal to . /// The only valid are and . public static async Task SendFileAsync(IMessageChannel channel, BaseDiscordClient client, - string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, - MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, + string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, + MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, bool isSpoiler, Embed[] embeds, MessageFlags flags = MessageFlags.None) { string filename = Path.GetFileName(filePath); using (var file = File.OpenRead(filePath)) - return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, + return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags).ConfigureAwait(false); } /// Message content is too long, length must be less or equal to . /// The only valid are and . public static async Task SendFileAsync(IMessageChannel channel, BaseDiscordClient client, - Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, - MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, + Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, + MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, bool isSpoiler, Embed[] embeds, MessageFlags flags = MessageFlags.None) { using (var file = new FileAttachment(stream, filename, isSpoiler: isSpoiler)) - return await SendFileAsync(channel, client, file, text, isTTS, embed, allowedMentions, messageReference, + return await SendFileAsync(channel, client, file, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags).ConfigureAwait(false); } /// Message content is too long, length must be less or equal to . /// The only valid are and . public static Task SendFileAsync(IMessageChannel channel, BaseDiscordClient client, - FileAttachment attachment, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, - MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, + FileAttachment attachment, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, + MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, Embed[] embeds, MessageFlags flags = MessageFlags.None) - => SendFilesAsync(channel, client, new[] { attachment }, text, isTTS, embed, allowedMentions, messageReference, + => SendFilesAsync(channel, client, new[] { attachment }, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// The only valid are and . public static async Task SendFilesAsync(IMessageChannel channel, BaseDiscordClient client, - IEnumerable attachments, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, - MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, + IEnumerable attachments, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, + MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, Embed[] embeds, MessageFlags flags) { embeds ??= Array.Empty(); @@ -389,8 +389,8 @@ namespace Discord.Rest Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed."); - - foreach(var attachment in attachments) + + foreach (var attachment in attachments) { Preconditions.NotNullOrEmpty(attachment.FileName, nameof(attachment.FileName), "File Name must not be empty or null"); } @@ -429,18 +429,18 @@ namespace Discord.Rest Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed."); } - var args = new UploadFileParams(attachments.ToArray()) - { - Content = text, + var args = new UploadFileParams(attachments.ToArray()) + { + Content = text, IsTTS = isTTS, - Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional.Unspecified, - AllowedMentions = allowedMentions?.ToModel() ?? Optional.Unspecified, - MessageReference = messageReference?.ToModel() ?? Optional.Unspecified, + Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional.Unspecified, + AllowedMentions = allowedMentions?.ToModel() ?? Optional.Unspecified, + MessageReference = messageReference?.ToModel() ?? Optional.Unspecified, MessageComponent = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional.Unspecified, Flags = flags }; - + var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false); return RestUserMessage.Create(client, channel, client.CurrentUser, model); } diff --git a/src/Discord.Net.Rest/Entities/Channels/ForumHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ForumHelper.cs index 4ecafd87..6ad0d49f 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ForumHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ForumHelper.cs @@ -16,7 +16,7 @@ internal static class ForumHelper func(args); Preconditions.AtMost(args.Tags.IsSpecified ? args.Tags.Value.Count() : 0, 5, nameof(args.Tags), "Forum channel can have max 20 tags."); - + var apiArgs = new API.Rest.ModifyForumChannelParams() { Name = args.Name, diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestAudioChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestAudioChannel.cs index 2c334153..01eca766 100644 --- a/src/Discord.Net.Rest/Entities/Channels/IRestAudioChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/IRestAudioChannel.cs @@ -1,4 +1,4 @@ -namespace Discord.Rest +namespace Discord.Rest { public interface IRestAudioChannel : IAudioChannel { diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs index 678db093..256fc350 100644 --- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs @@ -11,13 +11,13 @@ namespace Discord.Rest { /// new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None); - + /// new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None); - + /// new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None); - + /// new Task SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None); diff --git a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs index 3bf43a59..35c2411b 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs @@ -95,10 +95,10 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, - RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, + RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// @@ -128,36 +128,36 @@ namespace Discord.Rest /// Message content is too long, length must be less or equal to . /// The only valid are and . public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, - RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// /// Message content is too long, length must be less or equal to . - public Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// @@ -271,7 +271,7 @@ namespace Discord.Rest AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); - + #endregion #region IChannel diff --git a/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs index 4068eea2..59d6741d 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs @@ -70,7 +70,7 @@ namespace Discord.Rest if (model.ThreadRateLimitPerUser.IsSpecified) DefaultSlowModeInterval = model.ThreadRateLimitPerUser.Value; - if(model.SlowMode.IsSpecified) + if (model.SlowMode.IsSpecified) ThreadCreationInterval = model.SlowMode.Value; DefaultSortOrder = model.DefaultSortOrder.GetValueOrDefault(); @@ -90,7 +90,7 @@ namespace Discord.Rest } CategoryId = model.CategoryId.GetValueOrDefault(); - DefaultLayout= model.DefaultForumLayout.GetValueOrDefault(); + DefaultLayout = model.DefaultForumLayout.GetValueOrDefault(); } /// @@ -101,7 +101,7 @@ namespace Discord.Rest } /// - public Task CreatePostAsync(string title, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, + public Task CreatePostAsync(string title, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null) => ThreadHelper.CreatePostAsync(this, Discord, title, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags?.Select(tag => tag.Id).ToArray()); diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs index d21852f9..ba4cbdb2 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs @@ -105,10 +105,10 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, - RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, + RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// @@ -137,26 +137,26 @@ namespace Discord.Rest /// An I/O error occurred while opening the file. /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, - RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, + RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags); /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags); /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + public Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference, @@ -164,11 +164,11 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + public Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, + => ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// public Task TriggerTypingAsync(RequestOptions options = null) @@ -246,16 +246,16 @@ namespace Discord.Rest async Task IMessageChannel.SendFilesAsync(IEnumerable attachments, string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) - => await SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components, + => await SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); /// async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, + => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); - + #endregion #region IAudioChannel diff --git a/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs index 7554c69d..1d71abe1 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs @@ -29,6 +29,6 @@ namespace Discord.Rest /// public Task FollowAnnouncementChannelAsync(ulong channelId, RequestOptions options = null) - => ChannelHelper.FollowAnnouncementChannelAsync(this, channelId, Discord, options); + => ChannelHelper.FollowAnnouncementChannelAsync(this, channelId, Discord, options); } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs index b34afd02..bbb68932 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs @@ -39,7 +39,7 @@ namespace Discord.Rest internal void Update(StageInstance model, bool isLive = false) { IsLive = isLive; - if(isLive) + if (isLive) { PrivacyLevel = model.PrivacyLevel; IsDiscoverableDisabled = model.DiscoverableDisabled; diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index 25c92df3..1d1e6df9 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -111,10 +111,10 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public virtual Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, + public virtual Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// @@ -143,39 +143,39 @@ namespace Discord.Rest /// An I/O error occurred while opening the file. /// Message content is too long, length must be less or equal to . /// The only valid are and . - public virtual Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, - RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public virtual Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, + RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags); /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public virtual Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public virtual Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags); /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public virtual Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public virtual Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public virtual Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public virtual Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); @@ -371,34 +371,34 @@ namespace Discord.Rest /// async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, - RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, + RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, + => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, - Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, + async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, + Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(FileAttachment attachment, string text, bool isTTS, - Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, + async Task IMessageChannel.SendFileAsync(FileAttachment attachment, string text, bool isTTS, + Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); /// - async Task IMessageChannel.SendFilesAsync(IEnumerable attachments, string text, + async Task IMessageChannel.SendFilesAsync(IEnumerable attachments, string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); /// - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, - AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, + AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); #endregion diff --git a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs index a4124bc8..df5b187f 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs @@ -44,10 +44,10 @@ namespace Discord.Rest { base.Update(model); - if(model.Bitrate.IsSpecified) + if (model.Bitrate.IsSpecified) Bitrate = model.Bitrate.Value; - if(model.UserLimit.IsSpecified) + if (model.UserLimit.IsSpecified) UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null; VideoQualityMode = model.VideoQualityMode.GetValueOrDefault(VideoQualityMode.Auto); diff --git a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs index 7b6d42e2..4c9a50bc 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs @@ -215,7 +215,7 @@ namespace Discord.Rest if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds) throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds and none.", nameof(flags)); - + if (channel.Flags.HasFlag(ChannelFlags.RequireTag)) throw new ArgumentException($"The channel {channel.Name} requires posts to have at least one tag."); diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index ea88e4db..5407f0ed 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -3,13 +3,13 @@ using Discord.API.Rest; using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.IO; using System.Linq; using System.Threading.Tasks; -using WidgetModel = Discord.API.GuildWidget; +using ImageModel = Discord.API.Image; using Model = Discord.API.Guild; using RoleModel = Discord.API.Role; -using ImageModel = Discord.API.Image; -using System.IO; +using WidgetModel = Discord.API.GuildWidget; namespace Discord.Rest { @@ -1040,7 +1040,7 @@ namespace Discord.Rest { Enabled = enabled, Description = description, - WelcomeChannels = channels?.Select(ch => new API.WelcomeScreenChannel + WelcomeChannels = channels?.Select(ch => new API.WelcomeScreenChannel { ChannelId = ch.Id, Description = ch.Description, @@ -1051,7 +1051,7 @@ namespace Discord.Rest var model = await client.ApiClient.ModifyGuildWelcomeScreenAsync(args, guild.Id, options); - if(model.WelcomeChannels.Length == 0) + if (model.WelcomeChannels.Length == 0) return null; return new WelcomeScreen(model.Description.GetValueOrDefault(null), model.WelcomeChannels.Select( diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs b/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs index d77d3b62..a0cba625 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs @@ -38,7 +38,7 @@ namespace Discord.Rest /// public override string ToString() => User.ToString(); private string DebuggerDisplay => $"{User}: {Reason}"; -#endregion + #endregion #region IBan /// diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index 79ec77c2..10e0acc5 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -4,11 +4,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Globalization; +using System.IO; using System.Linq; using System.Threading.Tasks; -using WidgetModel = Discord.API.GuildWidget; using Model = Discord.API.Guild; -using System.IO; +using WidgetModel = Discord.API.GuildWidget; namespace Discord.Rest { @@ -950,7 +950,7 @@ namespace Discord.Rest /// A task that represents the asynchronous get operation. The task result contains a read-only collection /// of application commands found within the guild. /// - public async Task> GetApplicationCommandsAsync (bool withLocalizations = false, string locale = null, RequestOptions options = null) + public async Task> GetApplicationCommandsAsync(bool withLocalizations = false, string locale = null, RequestOptions options = null) => await ClientHelper.GetGuildApplicationCommandsAsync(Discord, Id, withLocalizations, locale, options).ConfigureAwait(false); /// /// Gets an application command within this guild with the specified id. @@ -1119,7 +1119,7 @@ namespace Discord.Rest List stickers = new List(); - foreach(var model in models) + foreach (var model in models) { var entity = CustomSticker.Create(Discord, model, this, model.User.IsSpecified ? model.User.Value.Id : null); stickers.Add(entity); @@ -1300,7 +1300,7 @@ namespace Discord.Rest return null; } /// - async Task IGuild.GetStageChannelAsync(ulong id, CacheMode mode, RequestOptions options ) + async Task IGuild.GetStageChannelAsync(ulong id, CacheMode mode, RequestOptions options) { if (mode == CacheMode.AllowDownload) return await GetStageChannelAsync(id, options).ConfigureAwait(false); @@ -1487,7 +1487,7 @@ namespace Discord.Rest async Task> IGuild.GetWebhooksAsync(RequestOptions options) => await GetWebhooksAsync(options).ConfigureAwait(false); /// - async Task> IGuild.GetApplicationCommandsAsync (bool withLocalizations, string locale, RequestOptions options) + async Task> IGuild.GetApplicationCommandsAsync(bool withLocalizations, string locale, RequestOptions options) => await GetApplicationCommandsAsync(withLocalizations, locale, options).ConfigureAwait(false); /// async Task IGuild.CreateStickerAsync(string name, string description, IEnumerable tags, Image image, RequestOptions options) diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestUserGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestUserGuild.cs index 6131c652..66b424a6 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestUserGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestUserGuild.cs @@ -43,7 +43,7 @@ namespace Discord.Rest Permissions = new GuildPermissions(model.Permissions); Features = model.Features; } - + public async Task LeaveAsync(RequestOptions options = null) { await Discord.ApiClient.LeaveGuildAsync(Id, options).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Entities/Integrations/RestIntegration.cs b/src/Discord.Net.Rest/Entities/Integrations/RestIntegration.cs index e92ecdde..d8ffca2f 100644 --- a/src/Discord.Net.Rest/Entities/Integrations/RestIntegration.cs +++ b/src/Discord.Net.Rest/Entities/Integrations/RestIntegration.cs @@ -76,7 +76,7 @@ namespace Discord.Rest _syncedAtTicks = model.SyncedAt.IsSpecified ? model.SyncedAt.Value.UtcTicks : null; } - + public async Task DeleteAsync() { await Discord.ApiClient.DeleteIntegrationAsync(GuildId, Id).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestCommandBase.cs b/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestCommandBase.cs index 102ede7b..b0175358 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestCommandBase.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestCommandBase.cs @@ -193,7 +193,7 @@ namespace Discord.Rest Preconditions.NotNull(fileStream, nameof(fileStream), "File Stream must have data"); Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null"); - using(var file = new FileAttachment(fileStream, fileName)) + using (var file = new FileAttachment(fileStream, fileName)) return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); } diff --git a/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs b/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs index 72b89472..1be74261 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs @@ -77,7 +77,7 @@ namespace Discord.Rest { foreach (var role in resolved.Roles.Value) { - var restRole = RestRole.Create(discord, guild, role.Value); + var restRole = RestRole.Create(discord, guild, role.Value); Roles.Add(ulong.Parse(role.Key), restRole); } @@ -108,7 +108,7 @@ namespace Discord.Rest Messages.Add(message.Id, message); } } - + if (resolved.Attachments.IsSpecified) { foreach (var attachment in resolved.Attachments.Value) diff --git a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs index 34c664b0..465d9962 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs @@ -17,7 +17,7 @@ namespace Discord.Rest internal RestMessageCommand(DiscordRestClient client, Model model) : base(client, model) { - + } internal new static async Task CreateAsync(DiscordRestClient client, Model model, bool doApiCall) @@ -34,7 +34,7 @@ namespace Discord.Rest var dataModel = model.Data.IsSpecified ? (DataModel)model.Data.Value : null; - + Data = await RestMessageCommandData.CreateAsync(client, dataModel, Guild, Channel, doApiCall).ConfigureAwait(false); } diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index 9d440140..6241722c 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -51,7 +51,7 @@ namespace Discord.Rest IDiscordInteraction interaction, RequestOptions options = null) { var model = await client.ApiClient.GetInteractionResponseAsync(interaction.Token, options).ConfigureAwait(false); - if(model != null) + if (model != null) return RestInteractionMessage.Create(client, model, interaction.Token, channel); return null; } @@ -150,7 +150,7 @@ namespace Discord.Rest DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), DmPermission = arg.IsDMEnabled.ToNullable(), Nsfw = arg.IsNsfw.GetValueOrDefault(false) - }; + }; if (arg is SlashCommandProperties slashProps) { diff --git a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs index b400852d..f93e97ad 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs @@ -1,12 +1,12 @@ +using Discord.Net.Rest; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using Model = Discord.API.Interaction; using DataModel = Discord.API.MessageComponentInteractionData; -using System.IO; -using Discord.Net.Rest; +using Model = Discord.API.Interaction; namespace Discord.Rest { @@ -286,7 +286,7 @@ namespace Discord.Rest Preconditions.NotNull(fileStream, nameof(fileStream), "File Stream must have data"); Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null"); - using(var file = new FileAttachment(fileStream, fileName)) + using (var file = new FileAttachment(fileStream, fileName)) return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); } @@ -308,7 +308,7 @@ namespace Discord.Rest fileName ??= Path.GetFileName(filePath); Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null"); - using(var file = new FileAttachment(File.OpenRead(filePath), fileName)) + using (var file = new FileAttachment(File.OpenRead(filePath), fileName)) return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); } diff --git a/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs b/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs index ef16d7b2..8016d5be 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs @@ -32,7 +32,7 @@ namespace Discord.Rest await entity.UpdateAsync(client, model, doApiCall); return entity; } - + private object _lock = new object(); /// diff --git a/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModalData.cs b/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModalData.cs index 7ecf804a..c1f329e7 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModalData.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModalData.cs @@ -1,9 +1,9 @@ +using System; using System.Collections.Generic; using System.Linq; -using System; -using Model = Discord.API.ModalInteractionData; -using InterationModel = Discord.API.Interaction; using DataModel = Discord.API.MessageComponentInteractionData; +using InterationModel = Discord.API.Interaction; +using Model = Discord.API.ModalInteractionData; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs index ed22712e..84ce9628 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs @@ -101,7 +101,7 @@ namespace Discord.Rest NameLocalized = model.NameLocalized.GetValueOrDefault(); DescriptionLocalized = model.DescriptionLocalized.GetValueOrDefault(); - + IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true); DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0)); IsNsfw = model.Nsfw.GetValueOrDefault(false).GetValueOrDefault(false); diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs b/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs index ba2de12a..1caa4613 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs @@ -1,12 +1,12 @@ +using Discord.Net; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Threading.Tasks; -using Model = Discord.API.Interaction; using DataModel = Discord.API.ApplicationCommandInteractionData; -using Newtonsoft.Json; -using Discord.Net; +using Model = Discord.API.Interaction; namespace Discord.Rest { @@ -98,7 +98,7 @@ namespace Discord.Rest internal static async Task CreateAsync(DiscordRestClient client, Model model, bool doApiCall) { - if(model.Type == InteractionType.Ping) + if (model.Type == InteractionType.Ping) { return await RestPingInteraction.CreateAsync(client, model, doApiCall); } @@ -142,13 +142,13 @@ namespace Discord.Rest GuildId = model.GuildId.IsSpecified ? model.GuildId.Value : null; - + IsDMInteraction = GuildId is null; Data = model.Data.IsSpecified ? model.Data.Value : null; - + Token = model.Token; Version = model.Version; Type = model.Type; @@ -176,7 +176,7 @@ namespace Discord.Rest User = RestUser.Create(Discord, model.User.Value); } } - + if (Channel is null && ChannelId is not null) { @@ -294,7 +294,7 @@ namespace Discord.Rest } /// public abstract string RespondWithModal(Modal modal, RequestOptions options = null); - + /// public abstract string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null); diff --git a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs index 27c53624..4f57e3b6 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using Model = Discord.API.Interaction; using DataModel = Discord.API.AutocompleteInteractionData; -using System.IO; +using Model = Discord.API.Interaction; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs index f955e785..8fbd3a8c 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs @@ -20,7 +20,7 @@ namespace Discord.Rest internal RestSlashCommand(DiscordRestClient client, Model model) : base(client, model) - { + { } internal new static async Task CreateAsync(DiscordRestClient client, Model model, bool doApiCall) diff --git a/src/Discord.Net.Rest/Entities/Invites/InviteHelper.cs b/src/Discord.Net.Rest/Entities/Invites/InviteHelper.cs index ebcd9377..95f2d902 100644 --- a/src/Discord.Net.Rest/Entities/Invites/InviteHelper.cs +++ b/src/Discord.Net.Rest/Entities/Invites/InviteHelper.cs @@ -4,7 +4,7 @@ namespace Discord.Rest { internal static class InviteHelper { - public static async Task DeleteAsync(IInvite invite, BaseDiscordClient client, + public static async Task DeleteAsync(IInvite invite, BaseDiscordClient client, RequestOptions options) { await client.ApiClient.DeleteInviteAsync(invite.Code, options).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs b/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs index 93f79ad2..cec771d3 100644 --- a/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs +++ b/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs @@ -39,7 +39,7 @@ namespace Discord.Rest public InviteGuild InviteGuild { get; private set; } internal IChannel Channel { get; } - + internal IGuild Guild { get; } /// diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs index 4d9ef008..1cb9f07e 100644 --- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs +++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs @@ -85,7 +85,7 @@ namespace Discord.Rest Preconditions.AtMost(apiEmbeds?.Count ?? 0, 10, nameof(args.Embeds), "A max of 10 embeds are allowed."); - if(!args.Attachments.IsSpecified) + if (!args.Attachments.IsSpecified) { var apiArgs = new API.Rest.ModifyMessageParams { @@ -267,10 +267,13 @@ namespace Discord.Rest while (true) { index = text.IndexOf('<', index); - if (index == -1) break; + if (index == -1) + break; int endIndex = text.IndexOf('>', index + 1); - if (endIndex == -1) break; - if (CheckWrappedCode()) break; + if (endIndex == -1) + break; + if (CheckWrappedCode()) + break; string content = text.Substring(index, endIndex - index + 1); if (MentionUtils.TryParseUser(content, out ulong id)) @@ -317,8 +320,10 @@ namespace Discord.Rest while (true) { index = text.IndexOf("@everyone", index); - if (index == -1) break; - if (CheckWrappedCode()) break; + if (index == -1) + break; + if (CheckWrappedCode()) + break; var tagIndex = FindIndex(tags, index); if (tagIndex.HasValue) tags.Insert(tagIndex.Value, new Tag(TagType.EveryoneMention, index, "@everyone".Length, 0, guild?.EveryoneRole)); @@ -330,8 +335,10 @@ namespace Discord.Rest while (true) { index = text.IndexOf("@here", index); - if (index == -1) break; - if (CheckWrappedCode()) break; + if (index == -1) + break; + if (CheckWrappedCode()) + break; var tagIndex = FindIndex(tags, index); if (tagIndex.HasValue) tags.Insert(tagIndex.Value, new Tag(TagType.HereMention, index, "@here".Length, 0, guild?.EveryoneRole)); diff --git a/src/Discord.Net.Rest/Entities/RestApplication.cs b/src/Discord.Net.Rest/Entities/RestApplication.cs index 8347a70d..a9a30ef7 100644 --- a/src/Discord.Net.Rest/Entities/RestApplication.cs +++ b/src/Discord.Net.Rest/Entities/RestApplication.cs @@ -55,7 +55,7 @@ namespace Discord.Rest return entity; } internal void Update(Model model) - { + { Description = model.Description; RPCOrigins = model.RPCOrigins.IsSpecified ? model.RPCOrigins.Value.ToImmutableArray() : ImmutableArray.Empty; Name = model.Name; diff --git a/src/Discord.Net.Rest/Entities/RestEntity.cs b/src/Discord.Net.Rest/Entities/RestEntity.cs index 2b1bb888..84936988 100644 --- a/src/Discord.Net.Rest/Entities/RestEntity.cs +++ b/src/Discord.Net.Rest/Entities/RestEntity.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs index 2f6d1f06..1f1cad35 100644 --- a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs +++ b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; -using Model = Discord.API.Role; using BulkParams = Discord.API.Rest.ModifyGuildRolesParams; +using Model = Discord.API.Role; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/Users/RestConnection.cs b/src/Discord.Net.Rest/Entities/Users/RestConnection.cs index 49627972..b0e19e2e 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestConnection.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestConnection.cs @@ -31,7 +31,8 @@ namespace Discord.Rest internal BaseDiscordClient Discord { get; } - internal RestConnection(BaseDiscordClient discord) { + internal RestConnection(BaseDiscordClient discord) + { Discord = discord; } @@ -48,7 +49,7 @@ namespace Discord.Rest Name = model.Name; Type = model.Type; IsRevoked = model.Revoked.IsSpecified ? model.Revoked.Value : null; - Integrations = model.Integrations.IsSpecified ?model.Integrations.Value + Integrations = model.Integrations.IsSpecified ? model.Integrations.Value .Select(intergration => RestIntegration.Create(Discord, null, intergration)).ToImmutableArray() : null; Verified = model.Verified; FriendSync = model.FriendSync; diff --git a/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs b/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs index a8c1a9b0..8412d133 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs @@ -21,7 +21,7 @@ namespace Discord.Rest entity.Update(model); return entity; } -#endregion + #endregion #region IVoiceState /// diff --git a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs index e1f871fd..b26e1b4d 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs @@ -201,7 +201,7 @@ namespace Discord.Rest /// public string GetGuildAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) => CDN.GetGuildUserAvatarUrl(Id, GuildId, GuildAvatarId, size, format); -#endregion + #endregion #region IGuildUser /// diff --git a/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs b/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs index 0187e5f7..fdd20e9d 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs @@ -41,7 +41,7 @@ namespace Discord.Rest internal void Update(Model model) { ThreadJoinedAt = model.JoinTimestamp; - if(model.GuildMember.IsSpecified) + if (model.GuildMember.IsSpecified) GuildUser = RestGuildUser.Create(Discord, Guild, model.GuildMember.Value); } diff --git a/src/Discord.Net.Rest/Entities/Users/RestUser.cs b/src/Discord.Net.Rest/Entities/Users/RestUser.cs index dfdb5381..812ae77d 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestUser.cs @@ -1,11 +1,11 @@ using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Globalization; using System.Threading.Tasks; -using Model = Discord.API.User; using EventUserModel = Discord.API.GuildScheduledEventUser; -using System.Collections.Generic; +using Model = Discord.API.User; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs index 10d23713..268faf00 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs @@ -34,7 +34,7 @@ namespace Discord.Rest entity.Update(model); return entity; } -#endregion + #endregion #region IGuildUser /// diff --git a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs index 66fd5326..965d83d2 100644 --- a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs +++ b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs @@ -1,10 +1,10 @@ using Discord.API.Rest; using System; using System.Collections.Generic; -using System.Threading.Tasks; -using Model = Discord.API.User; -using ImageModel = Discord.API.Image; using System.Linq; +using System.Threading.Tasks; +using ImageModel = Discord.API.Image; +using Model = Discord.API.User; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs index 0528d6b1..2f8cc96f 100644 --- a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs +++ b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs @@ -100,10 +100,10 @@ namespace Discord.Rest #region IWebhook /// - IGuild IWebhook.Guild + IGuild IWebhook.Guild => Guild ?? throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); /// - IIntegrationChannel IWebhook.Channel + IIntegrationChannel IWebhook.Channel => Channel ?? throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); /// Task IWebhook.ModifyAsync(Action func, RequestOptions options) diff --git a/src/Discord.Net.Rest/Entities/Webhooks/WebhookHelper.cs b/src/Discord.Net.Rest/Entities/Webhooks/WebhookHelper.cs index 0b61b6c2..5faa856a 100644 --- a/src/Discord.Net.Rest/Entities/Webhooks/WebhookHelper.cs +++ b/src/Discord.Net.Rest/Entities/Webhooks/WebhookHelper.cs @@ -1,6 +1,6 @@ -using System; -using System.Threading.Tasks; using Discord.API.Rest; +using System; +using System.Threading.Tasks; using ImageModel = Discord.API.Image; using Model = Discord.API.Webhook; diff --git a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs index f5a88486..f6ed5824 100644 --- a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs +++ b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs @@ -43,7 +43,8 @@ namespace Discord.Rest } public static API.Embed ToModel(this Embed entity) { - if (entity == null) return null; + if (entity == null) + return null; var model = new API.Embed { Type = entity.Type, @@ -71,7 +72,8 @@ namespace Discord.Rest public static API.AllowedMentions ToModel(this AllowedMentions entity) { - if (entity == null) return null; + if (entity == null) + return null; return new API.AllowedMentions() { Parse = entity.AllowedTypes?.EnumerateMentionTypes().ToArray(), @@ -187,7 +189,7 @@ namespace Discord.Rest Flags = data.Flags, }; - if(interaction is IApplicationCommandInteraction command) + if (interaction is IApplicationCommandInteraction command) { messageModel.Interaction = new API.MessageInteraction { diff --git a/src/Discord.Net.Rest/Extensions/StringExtensions.cs b/src/Discord.Net.Rest/Extensions/StringExtensions.cs index 4981a429..bc784d49 100644 --- a/src/Discord.Net.Rest/Extensions/StringExtensions.cs +++ b/src/Discord.Net.Rest/Extensions/StringExtensions.cs @@ -1,7 +1,7 @@ using Discord.Net.Converters; using Newtonsoft.Json; -using System.Linq; using System; +using System.Linq; namespace Discord.Rest { diff --git a/src/Discord.Net.Rest/Net/Converters/DiscordErrorConverter.cs b/src/Discord.Net.Rest/Net/Converters/DiscordErrorConverter.cs index 772ddc6b..9e42cff1 100644 --- a/src/Discord.Net.Rest/Net/Converters/DiscordErrorConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/DiscordErrorConverter.cs @@ -68,7 +68,7 @@ namespace Discord.Net.Converters Errors = prop.Value.ToObject() }); } - else if(int.TryParse(prop.Name, out var i)) // array value + else if (int.TryParse(prop.Name, out var i)) // array value { var r = prop.Value.CreateReader(); errs.AddRange(ReadErrors(r, path + $"[{i}]")); diff --git a/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs b/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs index cacd2e2e..93ef8c1d 100644 --- a/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs @@ -1,5 +1,5 @@ -using System; using Newtonsoft.Json; +using System; namespace Discord.Net.Converters { diff --git a/src/Discord.Net.Rest/Net/Converters/GuildFeaturesConverter.cs b/src/Discord.Net.Rest/Net/Converters/GuildFeaturesConverter.cs index 22363199..30842439 100644 --- a/src/Discord.Net.Rest/Net/Converters/GuildFeaturesConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/GuildFeaturesConverter.cs @@ -22,7 +22,7 @@ namespace Discord.Net.Converters GuildFeature features = GuildFeature.None; List experimental = new(); - foreach(var item in arr) + foreach (var item in arr) { if (Enum.TryParse(string.Concat(item.Split('_')), true, out var result)) { diff --git a/src/Discord.Net.Rest/Net/Converters/ImageConverter.cs b/src/Discord.Net.Rest/Net/Converters/ImageConverter.cs index 941a35bf..6f148686 100644 --- a/src/Discord.Net.Rest/Net/Converters/ImageConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/ImageConverter.cs @@ -1,6 +1,6 @@ +using Newtonsoft.Json; using System; using System.IO; -using Newtonsoft.Json; using Model = Discord.API.Image; namespace Discord.Net.Converters diff --git a/src/Discord.Net.Rest/Net/Converters/NullableConverter.cs b/src/Discord.Net.Rest/Net/Converters/NullableConverter.cs index 0b149e72..ddbe21d4 100644 --- a/src/Discord.Net.Rest/Net/Converters/NullableConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/NullableConverter.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; namespace Discord.Net.Converters diff --git a/src/Discord.Net.Rest/Net/Converters/StringEntityConverter.cs b/src/Discord.Net.Rest/Net/Converters/StringEntityConverter.cs index d7dd58d7..b78d3519 100644 --- a/src/Discord.Net.Rest/Net/Converters/StringEntityConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/StringEntityConverter.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; namespace Discord.Net.Converters diff --git a/src/Discord.Net.Rest/Net/Converters/UInt64EntityConverter.cs b/src/Discord.Net.Rest/Net/Converters/UInt64EntityConverter.cs index b8d8f105..25c77678 100644 --- a/src/Discord.Net.Rest/Net/Converters/UInt64EntityConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/UInt64EntityConverter.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Globalization; diff --git a/src/Discord.Net.Rest/Net/Converters/UnixTimestampConverter.cs b/src/Discord.Net.Rest/Net/Converters/UnixTimestampConverter.cs index 876254fb..858d1113 100644 --- a/src/Discord.Net.Rest/Net/Converters/UnixTimestampConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/UnixTimestampConverter.cs @@ -1,5 +1,5 @@ -using System; using Newtonsoft.Json; +using System; namespace Discord.Net.Converters { diff --git a/src/Discord.Net.Rest/Net/DefaultRestClient.cs b/src/Discord.Net.Rest/Net/DefaultRestClient.cs index 97872ee6..8959caa4 100644 --- a/src/Discord.Net.Rest/Net/DefaultRestClient.cs +++ b/src/Discord.Net.Rest/Net/DefaultRestClient.cs @@ -72,7 +72,8 @@ namespace Discord.Net.Rest string uri = Path.Combine(_baseUrl, endpoint); using (var restRequest = new HttpRequestMessage(GetMethod(method), uri)) { - if (reason != null) restRequest.Headers.Add("X-Audit-Log-Reason", Uri.EscapeDataString(reason)); + if (reason != null) + restRequest.Headers.Add("X-Audit-Log-Reason", Uri.EscapeDataString(reason)); if (requestHeaders != null) foreach (var header in requestHeaders) restRequest.Headers.Add(header.Key, header.Value); @@ -85,7 +86,8 @@ namespace Discord.Net.Rest string uri = Path.Combine(_baseUrl, endpoint); using (var restRequest = new HttpRequestMessage(GetMethod(method), uri)) { - if (reason != null) restRequest.Headers.Add("X-Audit-Log-Reason", Uri.EscapeDataString(reason)); + if (reason != null) + restRequest.Headers.Add("X-Audit-Log-Reason", Uri.EscapeDataString(reason)); if (requestHeaders != null) foreach (var header in requestHeaders) restRequest.Headers.Add(header.Key, header.Value); @@ -101,7 +103,8 @@ namespace Discord.Net.Rest string uri = Path.Combine(_baseUrl, endpoint); using (var restRequest = new HttpRequestMessage(GetMethod(method), uri)) { - if (reason != null) restRequest.Headers.Add("X-Audit-Log-Reason", Uri.EscapeDataString(reason)); + if (reason != null) + restRequest.Headers.Add("X-Audit-Log-Reason", Uri.EscapeDataString(reason)); if (requestHeaders != null) foreach (var header in requestHeaders) restRequest.Headers.Add(header.Key, header.Value); @@ -114,33 +117,36 @@ namespace Discord.Net.Rest switch (p.Value) { #pragma warning disable IDISP004 - case string stringValue: { content.Add(new StringContent(stringValue, Encoding.UTF8, "text/plain"), p.Key); continue; } - case byte[] byteArrayValue: { content.Add(new ByteArrayContent(byteArrayValue), p.Key); continue; } - case Stream streamValue: { content.Add(new StreamContent(streamValue), p.Key); continue; } + case string stringValue: + { content.Add(new StringContent(stringValue, Encoding.UTF8, "text/plain"), p.Key); continue; } + case byte[] byteArrayValue: + { content.Add(new ByteArrayContent(byteArrayValue), p.Key); continue; } + case Stream streamValue: + { content.Add(new StreamContent(streamValue), p.Key); continue; } case MultipartFile fileValue: - { - var stream = fileValue.Stream; - if (!stream.CanSeek) { - memoryStream = new MemoryStream(); - await stream.CopyToAsync(memoryStream).ConfigureAwait(false); - memoryStream.Position = 0; + var stream = fileValue.Stream; + if (!stream.CanSeek) + { + memoryStream = new MemoryStream(); + await stream.CopyToAsync(memoryStream).ConfigureAwait(false); + memoryStream.Position = 0; #pragma warning disable IDISP001 - stream = memoryStream; + stream = memoryStream; #pragma warning restore IDISP001 - } + } - var streamContent = new StreamContent(stream); - var extension = fileValue.Filename.Split('.').Last(); + var streamContent = new StreamContent(stream); + var extension = fileValue.Filename.Split('.').Last(); - if(fileValue.ContentType != null) - streamContent.Headers.ContentType = new MediaTypeHeaderValue(fileValue.ContentType); + if (fileValue.ContentType != null) + streamContent.Headers.ContentType = new MediaTypeHeaderValue(fileValue.ContentType); - content.Add(streamContent, p.Key, fileValue.Filename); + content.Add(streamContent, p.Key, fileValue.Filename); #pragma warning restore IDISP004 - continue; - } + continue; + } default: throw new InvalidOperationException($"Unsupported param type \"{p.Value.GetType().Name}\"."); } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/GroupElement.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/GroupElement.cs index d54b5ada..703d6ed7 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/GroupElement.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/GroupElement.cs @@ -1,8 +1,8 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - /* + /* ge means group element. Here the group is the set of pairs (x,y) of field elements (see fe.h) @@ -16,48 +16,48 @@ namespace Discord.Net.ED25519.Ed25519Ref10 ge_precomp (Duif): (y+x,y-x,2dxy) */ - internal struct GroupElementP2 - { - public FieldElement X; - public FieldElement Y; - public FieldElement Z; - } ; + internal struct GroupElementP2 + { + public FieldElement X; + public FieldElement Y; + public FieldElement Z; + }; - internal struct GroupElementP3 - { - public FieldElement X; - public FieldElement Y; - public FieldElement Z; - public FieldElement T; - } ; + internal struct GroupElementP3 + { + public FieldElement X; + public FieldElement Y; + public FieldElement Z; + public FieldElement T; + }; - internal struct GroupElementP1P1 - { - public FieldElement X; - public FieldElement Y; - public FieldElement Z; - public FieldElement T; - } ; + internal struct GroupElementP1P1 + { + public FieldElement X; + public FieldElement Y; + public FieldElement Z; + public FieldElement T; + }; - internal struct GroupElementPreComp - { - public FieldElement yplusx; - public FieldElement yminusx; - public FieldElement xy2d; + internal struct GroupElementPreComp + { + public FieldElement yplusx; + public FieldElement yminusx; + public FieldElement xy2d; - public GroupElementPreComp(FieldElement yplusx, FieldElement yminusx, FieldElement xy2d) - { - this.yplusx = yplusx; - this.yminusx = yminusx; - this.xy2d = xy2d; - } - } ; + public GroupElementPreComp(FieldElement yplusx, FieldElement yminusx, FieldElement xy2d) + { + this.yplusx = yplusx; + this.yminusx = yminusx; + this.xy2d = xy2d; + } + }; - internal struct GroupElementCached - { - public FieldElement YplusX; - public FieldElement YminusX; - public FieldElement Z; - public FieldElement T2d; - } ; + internal struct GroupElementCached + { + public FieldElement YplusX; + public FieldElement YminusX; + public FieldElement Z; + public FieldElement T2d; + }; } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/base2.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/base2.cs index c86de62a..34a92a18 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/base2.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/base2.cs @@ -45,6 +45,6 @@ namespace Discord.Net.ED25519.Ed25519Ref10 new FieldElement( -24326370,15950226,-31801215,-14592823,-11662737,-5090925,1573892,-2625887,2198790,-15804619 ), new FieldElement( -3099351,10324967,-2241613,7453183,-5446979,-2735503,-13812022,-16236442,-32461234,-12290683 ) ) - }; + }; } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d.cs index b5a95730..e02ff8a0 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d.cs @@ -2,8 +2,8 @@ using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class LookupTables - { - internal static FieldElement d = new FieldElement(-10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116); - } + internal static partial class LookupTables + { + internal static FieldElement d = new FieldElement(-10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116); + } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d2.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d2.cs index 5c6bb61e..adf50499 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d2.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/d2.cs @@ -2,8 +2,8 @@ using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class LookupTables - { - internal static FieldElement d2 = new FieldElement(-21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199); - } + internal static partial class LookupTables + { + internal static FieldElement d2 = new FieldElement(-21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199); + } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_0.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_0.cs index 632c1b94..e4f31c07 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_0.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_0.cs @@ -2,11 +2,11 @@ using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - public static void fe_0(out FieldElement h) - { - h = default(FieldElement); - } - } + internal static partial class FieldOperations + { + public static void fe_0(out FieldElement h) + { + h = default(FieldElement); + } + } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_1.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_1.cs index dfed794b..5eba3f5e 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_1.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_1.cs @@ -2,12 +2,12 @@ using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - public static void fe_1(out FieldElement h) - { - h = default(FieldElement); - h.x0 = 1; - } - } + internal static partial class FieldOperations + { + public static void fe_1(out FieldElement h) + { + h = default(FieldElement); + h.x0 = 1; + } + } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_add.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_add.cs index 7eb6b9ff..aac2f6ee 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_add.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_add.cs @@ -2,9 +2,9 @@ using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - /* + internal static partial class FieldOperations + { + /* h = f + g Can overlap h with f or g. @@ -15,9 +15,9 @@ namespace Discord.Net.ED25519.Ed25519Ref10 Postconditions: |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. */ - //void fe_add(fe h,const fe f,const fe g) - internal static void fe_add(out FieldElement h, ref FieldElement f, ref FieldElement g) - { + //void fe_add(fe h,const fe f,const fe g) + internal static void fe_add(out FieldElement h, ref FieldElement f, ref FieldElement g) + { int f0 = f.x0; int f1 = f.x1; int f2 = f.x2; @@ -49,16 +49,16 @@ namespace Discord.Net.ED25519.Ed25519Ref10 int h8 = f8 + g8; int h9 = f9 + g9; - h.x0 = h0; - h.x1 = h1; - h.x2 = h2; - h.x3 = h3; - h.x4 = h4; - h.x5 = h5; - h.x6 = h6; - h.x7 = h7; - h.x8 = h8; - h.x9 = h9; - } - } + h.x0 = h0; + h.x1 = h1; + h.x2 = h2; + h.x3 = h3; + h.x4 = h4; + h.x5 = h5; + h.x6 = h6; + h.x7 = h7; + h.x8 = h8; + h.x9 = h9; + } + } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_cmov.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_cmov.cs index 76565069..c6555a74 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_cmov.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_cmov.cs @@ -2,18 +2,18 @@ using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - /* + internal static partial class FieldOperations + { + /* Replace (f,g) with (g,g) if b == 1; replace (f,g) with (f,g) if b == 0. Preconditions: b in {0,1}. */ - //void fe_cmov(fe f,const fe g,unsigned int b) - internal static void fe_cmov(ref FieldElement f, ref FieldElement g, int b) - { + //void fe_cmov(fe f,const fe g,unsigned int b) + internal static void fe_cmov(ref FieldElement f, ref FieldElement g, int b) + { int f0 = f.x0; int f1 = f.x1; int f2 = f.x2; @@ -45,27 +45,27 @@ namespace Discord.Net.ED25519.Ed25519Ref10 int x8 = f8 ^ g8; int x9 = f9 ^ g9; - b = -b; - x0 &= b; - x1 &= b; - x2 &= b; - x3 &= b; - x4 &= b; - x5 &= b; - x6 &= b; - x7 &= b; - x8 &= b; - x9 &= b; - f.x0 = f0 ^ x0; - f.x1 = f1 ^ x1; - f.x2 = f2 ^ x2; - f.x3 = f3 ^ x3; - f.x4 = f4 ^ x4; - f.x5 = f5 ^ x5; - f.x6 = f6 ^ x6; - f.x7 = f7 ^ x7; - f.x8 = f8 ^ x8; - f.x9 = f9 ^ x9; - } - } + b = -b; + x0 &= b; + x1 &= b; + x2 &= b; + x3 &= b; + x4 &= b; + x5 &= b; + x6 &= b; + x7 &= b; + x8 &= b; + x9 &= b; + f.x0 = f0 ^ x0; + f.x1 = f1 ^ x1; + f.x2 = f2 ^ x2; + f.x3 = f3 ^ x3; + f.x4 = f4 ^ x4; + f.x5 = f5 ^ x5; + f.x6 = f6 ^ x6; + f.x7 = f7 ^ x7; + f.x8 = f8 ^ x8; + f.x9 = f9 ^ x9; + } + } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_frombytes.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_frombytes.cs index 3689ff95..4d6cafbe 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_frombytes.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_frombytes.cs @@ -37,17 +37,37 @@ namespace Discord.Net.ED25519.Ed25519Ref10 var h8 = load_3(data, offset + 26) << 4; var h9 = (load_3(data, offset + 29) & 8388607) << 2; - var carry9 = (h9 + (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - var carry1 = (h1 + (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - var carry3 = (h3 + (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - var carry5 = (h5 + (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - var carry7 = (h7 + (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + var carry9 = (h9 + (1 << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 << 25; + var carry1 = (h1 + (1 << 24)) >> 25; + h2 += carry1; + h1 -= carry1 << 25; + var carry3 = (h3 + (1 << 24)) >> 25; + h4 += carry3; + h3 -= carry3 << 25; + var carry5 = (h5 + (1 << 24)) >> 25; + h6 += carry5; + h5 -= carry5 << 25; + var carry7 = (h7 + (1 << 24)) >> 25; + h8 += carry7; + h7 -= carry7 << 25; - var carry0 = (h0 + (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - var carry2 = (h2 + (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - var carry4 = (h4 + (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - var carry6 = (h6 + (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - var carry8 = (h8 + (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; + var carry0 = (h0 + (1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; + var carry2 = (h2 + (1 << 25)) >> 26; + h3 += carry2; + h2 -= carry2 << 26; + var carry4 = (h4 + (1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; + var carry6 = (h6 + (1 << 25)) >> 26; + h7 += carry6; + h6 -= carry6 << 26; + var carry8 = (h8 + (1 << 25)) >> 26; + h9 += carry8; + h8 -= carry8 << 26; h.x0 = (int)h0; h.x1 = (int)h1; @@ -75,17 +95,37 @@ namespace Discord.Net.ED25519.Ed25519Ref10 var h8 = load_3(data, offset + 26) << 4; var h9 = load_3(data, offset + 29) << 2; - var carry9 = (h9 + (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - var carry1 = (h1 + (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - var carry3 = (h3 + (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - var carry5 = (h5 + (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - var carry7 = (h7 + (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + var carry9 = (h9 + (1 << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 << 25; + var carry1 = (h1 + (1 << 24)) >> 25; + h2 += carry1; + h1 -= carry1 << 25; + var carry3 = (h3 + (1 << 24)) >> 25; + h4 += carry3; + h3 -= carry3 << 25; + var carry5 = (h5 + (1 << 24)) >> 25; + h6 += carry5; + h5 -= carry5 << 25; + var carry7 = (h7 + (1 << 24)) >> 25; + h8 += carry7; + h7 -= carry7 << 25; - var carry0 = (h0 + (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - var carry2 = (h2 + (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - var carry4 = (h4 + (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - var carry6 = (h6 + (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - var carry8 = (h8 + (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; + var carry0 = (h0 + (1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; + var carry2 = (h2 + (1 << 25)) >> 26; + h3 += carry2; + h2 -= carry2 << 26; + var carry4 = (h4 + (1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; + var carry6 = (h6 + (1 << 25)) >> 26; + h7 += carry6; + h6 -= carry6 << 26; + var carry8 = (h8 + (1 << 25)) >> 26; + h9 += carry8; + h8 -= carry8 << 26; h.x0 = (int)h0; h.x1 = (int)h1; diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_invert.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_invert.cs index 943133e0..d97ff5b2 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_invert.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_invert.cs @@ -1,128 +1,146 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - internal static void fe_invert(out FieldElement result, ref FieldElement z) - { - FieldElement t0, t1, t2, t3; - int i; + internal static partial class FieldOperations + { + internal static void fe_invert(out FieldElement result, ref FieldElement z) + { + FieldElement t0, t1, t2, t3; + int i; - /* qhasm: z2 = z1^2^1 */ - /* asm 1: fe_sq(>z2=fe#1,z2=fe#1,>z2=fe#1); */ - /* asm 2: fe_sq(>z2=t0,z2=t0,>z2=t0); */ - fe_sq(out t0, ref z); //for (i = 1; i < 1; ++i) fe_sq(out t0, ref t0); + /* qhasm: z2 = z1^2^1 */ + /* asm 1: fe_sq(>z2=fe#1,z2=fe#1,>z2=fe#1); */ + /* asm 2: fe_sq(>z2=t0,z2=t0,>z2=t0); */ + fe_sq(out t0, ref z); //for (i = 1; i < 1; ++i) fe_sq(out t0, ref t0); - /* qhasm: z8 = z2^2^2 */ - /* asm 1: fe_sq(>z8=fe#2,z8=fe#2,>z8=fe#2); */ - /* asm 2: fe_sq(>z8=t1,z8=t1,>z8=t1); */ - fe_sq(out t1, ref t0); for (i = 1; i < 2; ++i) fe_sq(out t1, ref t1); + /* qhasm: z8 = z2^2^2 */ + /* asm 1: fe_sq(>z8=fe#2,z8=fe#2,>z8=fe#2); */ + /* asm 2: fe_sq(>z8=t1,z8=t1,>z8=t1); */ + fe_sq(out t1, ref t0); + for (i = 1; i < 2; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z9 = z1*z8 */ - /* asm 1: fe_mul(>z9=fe#2,z9=t1,z9=fe#2,z9=t1,z11=fe#1,z11=t0,z11=fe#1,z11=t0,z22=fe#3,z22=fe#3,>z22=fe#3); */ - /* asm 2: fe_sq(>z22=t2,z22=t2,>z22=t2); */ - fe_sq(out t2, ref t0); //for (i = 1; i < 1; ++i) fe_sq(out t2, ref t2); + /* qhasm: z22 = z11^2^1 */ + /* asm 1: fe_sq(>z22=fe#3,z22=fe#3,>z22=fe#3); */ + /* asm 2: fe_sq(>z22=t2,z22=t2,>z22=t2); */ + fe_sq(out t2, ref t0); //for (i = 1; i < 1; ++i) fe_sq(out t2, ref t2); - /* qhasm: z_5_0 = z9*z22 */ - /* asm 1: fe_mul(>z_5_0=fe#2,z_5_0=t1,z_5_0=fe#2,z_5_0=t1,z_10_5=fe#3,z_10_5=fe#3,>z_10_5=fe#3); */ - /* asm 2: fe_sq(>z_10_5=t2,z_10_5=t2,>z_10_5=t2); */ - fe_sq(out t2, ref t1); for (i = 1; i < 5; ++i) fe_sq(out t2, ref t2); + /* qhasm: z_10_5 = z_5_0^2^5 */ + /* asm 1: fe_sq(>z_10_5=fe#3,z_10_5=fe#3,>z_10_5=fe#3); */ + /* asm 2: fe_sq(>z_10_5=t2,z_10_5=t2,>z_10_5=t2); */ + fe_sq(out t2, ref t1); + for (i = 1; i < 5; ++i) + fe_sq(out t2, ref t2); - /* qhasm: z_10_0 = z_10_5*z_5_0 */ - /* asm 1: fe_mul(>z_10_0=fe#2,z_10_0=t1,z_10_0=fe#2,z_10_0=t1,z_20_10=fe#3,z_20_10=fe#3,>z_20_10=fe#3); */ - /* asm 2: fe_sq(>z_20_10=t2,z_20_10=t2,>z_20_10=t2); */ - fe_sq(out t2, ref t1); for (i = 1; i < 10; ++i) fe_sq(out t2, ref t2); + /* qhasm: z_20_10 = z_10_0^2^10 */ + /* asm 1: fe_sq(>z_20_10=fe#3,z_20_10=fe#3,>z_20_10=fe#3); */ + /* asm 2: fe_sq(>z_20_10=t2,z_20_10=t2,>z_20_10=t2); */ + fe_sq(out t2, ref t1); + for (i = 1; i < 10; ++i) + fe_sq(out t2, ref t2); - /* qhasm: z_20_0 = z_20_10*z_10_0 */ - /* asm 1: fe_mul(>z_20_0=fe#3,z_20_0=t2,z_20_0=fe#3,z_20_0=t2,z_40_20=fe#4,z_40_20=fe#4,>z_40_20=fe#4); */ - /* asm 2: fe_sq(>z_40_20=t3,z_40_20=t3,>z_40_20=t3); */ - fe_sq(out t3, ref t2); for (i = 1; i < 20; ++i) fe_sq(out t3, ref t3); + /* qhasm: z_40_20 = z_20_0^2^20 */ + /* asm 1: fe_sq(>z_40_20=fe#4,z_40_20=fe#4,>z_40_20=fe#4); */ + /* asm 2: fe_sq(>z_40_20=t3,z_40_20=t3,>z_40_20=t3); */ + fe_sq(out t3, ref t2); + for (i = 1; i < 20; ++i) + fe_sq(out t3, ref t3); - /* qhasm: z_40_0 = z_40_20*z_20_0 */ - /* asm 1: fe_mul(>z_40_0=fe#3,z_40_0=t2,z_40_0=fe#3,z_40_0=t2,z_50_10=fe#3,z_50_10=fe#3,>z_50_10=fe#3); */ - /* asm 2: fe_sq(>z_50_10=t2,z_50_10=t2,>z_50_10=t2); */ - fe_sq(out t2, ref t2); for (i = 1; i < 10; ++i) fe_sq(out t2, ref t2); + /* qhasm: z_50_10 = z_40_0^2^10 */ + /* asm 1: fe_sq(>z_50_10=fe#3,z_50_10=fe#3,>z_50_10=fe#3); */ + /* asm 2: fe_sq(>z_50_10=t2,z_50_10=t2,>z_50_10=t2); */ + fe_sq(out t2, ref t2); + for (i = 1; i < 10; ++i) + fe_sq(out t2, ref t2); - /* qhasm: z_50_0 = z_50_10*z_10_0 */ - /* asm 1: fe_mul(>z_50_0=fe#2,z_50_0=t1,z_50_0=fe#2,z_50_0=t1,z_100_50=fe#3,z_100_50=fe#3,>z_100_50=fe#3); */ - /* asm 2: fe_sq(>z_100_50=t2,z_100_50=t2,>z_100_50=t2); */ - fe_sq(out t2, ref t1); for (i = 1; i < 50; ++i) fe_sq(out t2, ref t2); + /* qhasm: z_100_50 = z_50_0^2^50 */ + /* asm 1: fe_sq(>z_100_50=fe#3,z_100_50=fe#3,>z_100_50=fe#3); */ + /* asm 2: fe_sq(>z_100_50=t2,z_100_50=t2,>z_100_50=t2); */ + fe_sq(out t2, ref t1); + for (i = 1; i < 50; ++i) + fe_sq(out t2, ref t2); - /* qhasm: z_100_0 = z_100_50*z_50_0 */ - /* asm 1: fe_mul(>z_100_0=fe#3,z_100_0=t2,z_100_0=fe#3,z_100_0=t2,z_200_100=fe#4,z_200_100=fe#4,>z_200_100=fe#4); */ - /* asm 2: fe_sq(>z_200_100=t3,z_200_100=t3,>z_200_100=t3); */ - fe_sq(out t3, ref t2); for (i = 1; i < 100; ++i) fe_sq(out t3, ref t3); + /* qhasm: z_200_100 = z_100_0^2^100 */ + /* asm 1: fe_sq(>z_200_100=fe#4,z_200_100=fe#4,>z_200_100=fe#4); */ + /* asm 2: fe_sq(>z_200_100=t3,z_200_100=t3,>z_200_100=t3); */ + fe_sq(out t3, ref t2); + for (i = 1; i < 100; ++i) + fe_sq(out t3, ref t3); - /* qhasm: z_200_0 = z_200_100*z_100_0 */ - /* asm 1: fe_mul(>z_200_0=fe#3,z_200_0=t2,z_200_0=fe#3,z_200_0=t2,z_250_50=fe#3,z_250_50=fe#3,>z_250_50=fe#3); */ - /* asm 2: fe_sq(>z_250_50=t2,z_250_50=t2,>z_250_50=t2); */ - fe_sq(out t2, ref t2); for (i = 1; i < 50; ++i) fe_sq(out t2, ref t2); + /* qhasm: z_250_50 = z_200_0^2^50 */ + /* asm 1: fe_sq(>z_250_50=fe#3,z_250_50=fe#3,>z_250_50=fe#3); */ + /* asm 2: fe_sq(>z_250_50=t2,z_250_50=t2,>z_250_50=t2); */ + fe_sq(out t2, ref t2); + for (i = 1; i < 50; ++i) + fe_sq(out t2, ref t2); - /* qhasm: z_250_0 = z_250_50*z_50_0 */ - /* asm 1: fe_mul(>z_250_0=fe#2,z_250_0=t1,z_250_0=fe#2,z_250_0=t1,z_255_5=fe#2,z_255_5=fe#2,>z_255_5=fe#2); */ - /* asm 2: fe_sq(>z_255_5=t1,z_255_5=t1,>z_255_5=t1); */ - fe_sq(out t1, ref t1); for (i = 1; i < 5; ++i) fe_sq(out t1, ref t1); + /* qhasm: z_255_5 = z_250_0^2^5 */ + /* asm 1: fe_sq(>z_255_5=fe#2,z_255_5=fe#2,>z_255_5=fe#2); */ + /* asm 2: fe_sq(>z_255_5=t1,z_255_5=t1,>z_255_5=t1); */ + fe_sq(out t1, ref t1); + for (i = 1; i < 5; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z_255_21 = z_255_5*z11 */ - /* asm 1: fe_mul(>z_255_21=fe#12,z_255_21=out,z_255_21=fe#12,z_255_21=out,> 31) ^ 1); } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul.cs index 4774cd5d..fca65446 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul.cs @@ -1,10 +1,10 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - /* + internal static partial class FieldOperations + { + /* h = f * g Can overlap h with f or g. @@ -16,7 +16,7 @@ namespace Discord.Net.ED25519.Ed25519Ref10 |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. */ - /* + /* Notes on implementation strategy: Using schoolbook multiplication. @@ -36,8 +36,8 @@ namespace Discord.Net.ED25519.Ed25519Ref10 With tighter constraints on inputs can squeeze carries into int32. */ - internal static void fe_mul(out FieldElement h, ref FieldElement f, ref FieldElement g) - { + internal static void fe_mul(out FieldElement h, ref FieldElement f, ref FieldElement g) + { int f0 = f.x0; int f1 = f.x1; int f2 = f.x2; @@ -198,66 +198,90 @@ namespace Discord.Net.ED25519.Ed25519Ref10 long carry8; long carry9; - /* + /* |h0| <= (1.65*1.65*2^52*(1+19+19+19+19)+1.65*1.65*2^50*(38+38+38+38+38)) i.e. |h0| <= 1.4*2^60; narrower ranges for h2, h4, h6, h8 |h1| <= (1.65*1.65*2^51*(1+1+19+19+19+19+19+19+19+19)) i.e. |h1| <= 1.7*2^59; narrower ranges for h3, h5, h7, h9 */ - carry0 = (h0 + (long)(1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry4 = (h4 + (long)(1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - /* |h0| <= 2^25 */ - /* |h4| <= 2^25 */ - /* |h1| <= 1.71*2^59 */ - /* |h5| <= 1.71*2^59 */ + carry0 = (h0 + (long)(1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; + carry4 = (h4 + (long)(1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; + /* |h0| <= 2^25 */ + /* |h4| <= 2^25 */ + /* |h1| <= 1.71*2^59 */ + /* |h5| <= 1.71*2^59 */ - carry1 = (h1 + (long)(1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry5 = (h5 + (long)(1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - /* |h1| <= 2^24; from now on fits into int32 */ - /* |h5| <= 2^24; from now on fits into int32 */ - /* |h2| <= 1.41*2^60 */ - /* |h6| <= 1.41*2^60 */ + carry1 = (h1 + (long)(1 << 24)) >> 25; + h2 += carry1; + h1 -= carry1 << 25; + carry5 = (h5 + (long)(1 << 24)) >> 25; + h6 += carry5; + h5 -= carry5 << 25; + /* |h1| <= 2^24; from now on fits into int32 */ + /* |h5| <= 2^24; from now on fits into int32 */ + /* |h2| <= 1.41*2^60 */ + /* |h6| <= 1.41*2^60 */ - carry2 = (h2 + (long)(1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry6 = (h6 + (long)(1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - /* |h2| <= 2^25; from now on fits into int32 unchanged */ - /* |h6| <= 2^25; from now on fits into int32 unchanged */ - /* |h3| <= 1.71*2^59 */ - /* |h7| <= 1.71*2^59 */ + carry2 = (h2 + (long)(1 << 25)) >> 26; + h3 += carry2; + h2 -= carry2 << 26; + carry6 = (h6 + (long)(1 << 25)) >> 26; + h7 += carry6; + h6 -= carry6 << 26; + /* |h2| <= 2^25; from now on fits into int32 unchanged */ + /* |h6| <= 2^25; from now on fits into int32 unchanged */ + /* |h3| <= 1.71*2^59 */ + /* |h7| <= 1.71*2^59 */ - carry3 = (h3 + (long)(1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry7 = (h7 + (long)(1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - /* |h3| <= 2^24; from now on fits into int32 unchanged */ - /* |h7| <= 2^24; from now on fits into int32 unchanged */ - /* |h4| <= 1.72*2^34 */ - /* |h8| <= 1.41*2^60 */ + carry3 = (h3 + (long)(1 << 24)) >> 25; + h4 += carry3; + h3 -= carry3 << 25; + carry7 = (h7 + (long)(1 << 24)) >> 25; + h8 += carry7; + h7 -= carry7 << 25; + /* |h3| <= 2^24; from now on fits into int32 unchanged */ + /* |h7| <= 2^24; from now on fits into int32 unchanged */ + /* |h4| <= 1.72*2^34 */ + /* |h8| <= 1.41*2^60 */ - carry4 = (h4 + (long)(1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry8 = (h8 + (long)(1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; - /* |h4| <= 2^25; from now on fits into int32 unchanged */ - /* |h8| <= 2^25; from now on fits into int32 unchanged */ - /* |h5| <= 1.01*2^24 */ - /* |h9| <= 1.71*2^59 */ + carry4 = (h4 + (long)(1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; + carry8 = (h8 + (long)(1 << 25)) >> 26; + h9 += carry8; + h8 -= carry8 << 26; + /* |h4| <= 2^25; from now on fits into int32 unchanged */ + /* |h8| <= 2^25; from now on fits into int32 unchanged */ + /* |h5| <= 1.01*2^24 */ + /* |h9| <= 1.71*2^59 */ - carry9 = (h9 + (long)(1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - /* |h9| <= 2^24; from now on fits into int32 unchanged */ - /* |h0| <= 1.1*2^39 */ + carry9 = (h9 + (long)(1 << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 << 25; + /* |h9| <= 2^24; from now on fits into int32 unchanged */ + /* |h0| <= 1.1*2^39 */ - carry0 = (h0 + (long)(1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - /* |h0| <= 2^25; from now on fits into int32 unchanged */ - /* |h1| <= 1.01*2^24 */ + carry0 = (h0 + (long)(1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; + /* |h0| <= 2^25; from now on fits into int32 unchanged */ + /* |h1| <= 1.01*2^24 */ - h.x0 = (int)h0; - h.x1 = (int)h1; - h.x2 = (int)h2; - h.x3 = (int)h3; - h.x4 = (int)h4; - h.x5 = (int)h5; - h.x6 = (int)h6; - h.x7 = (int)h7; - h.x8 = (int)h8; - h.x9 = (int)h9; - } - } -} \ No newline at end of file + h.x0 = (int)h0; + h.x1 = (int)h1; + h.x2 = (int)h2; + h.x3 = (int)h3; + h.x4 = (int)h4; + h.x5 = (int)h5; + h.x6 = (int)h6; + h.x7 = (int)h7; + h.x8 = (int)h8; + h.x9 = (int)h9; + } + } +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul121666.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul121666.cs index 2bbd3f68..8f0a5161 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul121666.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_mul121666.cs @@ -2,10 +2,10 @@ using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { + internal static partial class FieldOperations + { - /* + /* h = f * 121666 Can overlap h with f. @@ -16,8 +16,8 @@ namespace Discord.Net.ED25519.Ed25519Ref10 |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. */ - public static void fe_mul121666(out FieldElement h, ref FieldElement f) - { + public static void fe_mul121666(out FieldElement h, ref FieldElement f) + { int f0 = f.x0; int f1 = f.x1; int f2 = f.x2; @@ -40,28 +40,48 @@ namespace Discord.Net.ED25519.Ed25519Ref10 var h8 = f8 * 121666L; var h9 = f9 * 121666L; - var carry9 = (h9 + (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - var carry1 = (h1 + (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - var carry3 = (h3 + (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - var carry5 = (h5 + (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - var carry7 = (h7 + (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + var carry9 = (h9 + (1 << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 << 25; + var carry1 = (h1 + (1 << 24)) >> 25; + h2 += carry1; + h1 -= carry1 << 25; + var carry3 = (h3 + (1 << 24)) >> 25; + h4 += carry3; + h3 -= carry3 << 25; + var carry5 = (h5 + (1 << 24)) >> 25; + h6 += carry5; + h5 -= carry5 << 25; + var carry7 = (h7 + (1 << 24)) >> 25; + h8 += carry7; + h7 -= carry7 << 25; - var carry0 = (h0 + (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - var carry2 = (h2 + (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - var carry4 = (h4 + (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - var carry6 = (h6 + (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - var carry8 = (h8 + (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; + var carry0 = (h0 + (1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; + var carry2 = (h2 + (1 << 25)) >> 26; + h3 += carry2; + h2 -= carry2 << 26; + var carry4 = (h4 + (1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; + var carry6 = (h6 + (1 << 25)) >> 26; + h7 += carry6; + h6 -= carry6 << 26; + var carry8 = (h8 + (1 << 25)) >> 26; + h9 += carry8; + h8 -= carry8 << 26; - h.x0 = (int)h0; - h.x1 = (int)h1; - h.x2 = (int)h2; - h.x3 = (int)h3; - h.x4 = (int)h4; - h.x5 = (int)h5; - h.x6 = (int)h6; - h.x7 = (int)h7; - h.x8 = (int)h8; - h.x9 = (int)h9; - } - } + h.x0 = (int)h0; + h.x1 = (int)h1; + h.x2 = (int)h2; + h.x3 = (int)h3; + h.x4 = (int)h4; + h.x5 = (int)h5; + h.x6 = (int)h6; + h.x7 = (int)h7; + h.x8 = (int)h8; + h.x9 = (int)h9; + } + } } diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_neg.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_neg.cs index 9b3d1813..1d62d127 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_neg.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_neg.cs @@ -1,10 +1,10 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - /* + internal static partial class FieldOperations + { + /* h = -f Preconditions: @@ -13,8 +13,8 @@ namespace Discord.Net.ED25519.Ed25519Ref10 Postconditions: |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. */ - internal static void fe_neg(out FieldElement h, ref FieldElement f) - { + internal static void fe_neg(out FieldElement h, ref FieldElement f) + { int f0 = f.x0; int f1 = f.x1; int f2 = f.x2; @@ -36,16 +36,16 @@ namespace Discord.Net.ED25519.Ed25519Ref10 int h8 = -f8; int h9 = -f9; - h.x0 = h0; - h.x1 = h1; - h.x2 = h2; - h.x3 = h3; - h.x4 = h4; - h.x5 = h5; - h.x6 = h6; - h.x7 = h7; - h.x8 = h8; - h.x9 = h9; - } - } -} \ No newline at end of file + h.x0 = h0; + h.x1 = h1; + h.x2 = h2; + h.x3 = h3; + h.x4 = h4; + h.x5 = h5; + h.x6 = h6; + h.x7 = h7; + h.x8 = h8; + h.x9 = h9; + } + } +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_pow22523.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_pow22523.cs index 63bb33b5..04f3bc88 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_pow22523.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_pow22523.cs @@ -1,125 +1,143 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - internal static void fe_pow22523(out FieldElement result, ref FieldElement z) - { - FieldElement t0, t1, t2; - int i; + internal static partial class FieldOperations + { + internal static void fe_pow22523(out FieldElement result, ref FieldElement z) + { + FieldElement t0, t1, t2; + int i; - /* qhasm: z2 = z1^2^1 */ - /* asm 1: fe_sq(>z2=fe#1,z2=fe#1,>z2=fe#1); */ - /* asm 2: fe_sq(>z2=t0,z2=t0,>z2=t0); */ - fe_sq(out t0, ref z); //for (i = 1; i < 1; ++i) fe_sq(out t0, ref t0); + /* qhasm: z2 = z1^2^1 */ + /* asm 1: fe_sq(>z2=fe#1,z2=fe#1,>z2=fe#1); */ + /* asm 2: fe_sq(>z2=t0,z2=t0,>z2=t0); */ + fe_sq(out t0, ref z); //for (i = 1; i < 1; ++i) fe_sq(out t0, ref t0); - /* qhasm: z8 = z2^2^2 */ - /* asm 1: fe_sq(>z8=fe#2,z8=fe#2,>z8=fe#2); */ - /* asm 2: fe_sq(>z8=t1,z8=t1,>z8=t1); */ - fe_sq(out t1, ref t0); for (i = 1; i < 2; ++i) fe_sq(out t1, ref t1); + /* qhasm: z8 = z2^2^2 */ + /* asm 1: fe_sq(>z8=fe#2,z8=fe#2,>z8=fe#2); */ + /* asm 2: fe_sq(>z8=t1,z8=t1,>z8=t1); */ + fe_sq(out t1, ref t0); + for (i = 1; i < 2; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z9 = z1*z8 */ - /* asm 1: fe_mul(>z9=fe#2,z9=t1,z9=fe#2,z9=t1,z11=fe#1,z11=t0,z11=fe#1,z11=t0,z22=fe#1,z22=fe#1,>z22=fe#1); */ - /* asm 2: fe_sq(>z22=t0,z22=t0,>z22=t0); */ - fe_sq(out t0, ref t0); //for (i = 1; i < 1; ++i) fe_sq(out t0, ref t0); + /* qhasm: z22 = z11^2^1 */ + /* asm 1: fe_sq(>z22=fe#1,z22=fe#1,>z22=fe#1); */ + /* asm 2: fe_sq(>z22=t0,z22=t0,>z22=t0); */ + fe_sq(out t0, ref t0); //for (i = 1; i < 1; ++i) fe_sq(out t0, ref t0); - /* qhasm: z_5_0 = z9*z22 */ - /* asm 1: fe_mul(>z_5_0=fe#1,z_5_0=t0,z_5_0=fe#1,z_5_0=t0,z_10_5=fe#2,z_10_5=fe#2,>z_10_5=fe#2); */ - /* asm 2: fe_sq(>z_10_5=t1,z_10_5=t1,>z_10_5=t1); */ - fe_sq(out t1, ref t0); for (i = 1; i < 5; ++i) fe_sq(out t1, ref t1); + /* qhasm: z_10_5 = z_5_0^2^5 */ + /* asm 1: fe_sq(>z_10_5=fe#2,z_10_5=fe#2,>z_10_5=fe#2); */ + /* asm 2: fe_sq(>z_10_5=t1,z_10_5=t1,>z_10_5=t1); */ + fe_sq(out t1, ref t0); + for (i = 1; i < 5; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z_10_0 = z_10_5*z_5_0 */ - /* asm 1: fe_mul(>z_10_0=fe#1,z_10_0=t0,z_10_0=fe#1,z_10_0=t0,z_20_10=fe#2,z_20_10=fe#2,>z_20_10=fe#2); */ - /* asm 2: fe_sq(>z_20_10=t1,z_20_10=t1,>z_20_10=t1); */ - fe_sq(out t1, ref t0); for (i = 1; i < 10; ++i) fe_sq(out t1, ref t1); + /* qhasm: z_20_10 = z_10_0^2^10 */ + /* asm 1: fe_sq(>z_20_10=fe#2,z_20_10=fe#2,>z_20_10=fe#2); */ + /* asm 2: fe_sq(>z_20_10=t1,z_20_10=t1,>z_20_10=t1); */ + fe_sq(out t1, ref t0); + for (i = 1; i < 10; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z_20_0 = z_20_10*z_10_0 */ - /* asm 1: fe_mul(>z_20_0=fe#2,z_20_0=t1,z_20_0=fe#2,z_20_0=t1,z_40_20=fe#3,z_40_20=fe#3,>z_40_20=fe#3); */ - /* asm 2: fe_sq(>z_40_20=t2,z_40_20=t2,>z_40_20=t2); */ - fe_sq(out t2, ref t1); for (i = 1; i < 20; ++i) fe_sq(out t2, ref t2); + /* qhasm: z_40_20 = z_20_0^2^20 */ + /* asm 1: fe_sq(>z_40_20=fe#3,z_40_20=fe#3,>z_40_20=fe#3); */ + /* asm 2: fe_sq(>z_40_20=t2,z_40_20=t2,>z_40_20=t2); */ + fe_sq(out t2, ref t1); + for (i = 1; i < 20; ++i) + fe_sq(out t2, ref t2); - /* qhasm: z_40_0 = z_40_20*z_20_0 */ - /* asm 1: fe_mul(>z_40_0=fe#2,z_40_0=t1,z_40_0=fe#2,z_40_0=t1,z_50_10=fe#2,z_50_10=fe#2,>z_50_10=fe#2); */ - /* asm 2: fe_sq(>z_50_10=t1,z_50_10=t1,>z_50_10=t1); */ - fe_sq(out t1, ref t1); for (i = 1; i < 10; ++i) fe_sq(out t1, ref t1); + /* qhasm: z_50_10 = z_40_0^2^10 */ + /* asm 1: fe_sq(>z_50_10=fe#2,z_50_10=fe#2,>z_50_10=fe#2); */ + /* asm 2: fe_sq(>z_50_10=t1,z_50_10=t1,>z_50_10=t1); */ + fe_sq(out t1, ref t1); + for (i = 1; i < 10; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z_50_0 = z_50_10*z_10_0 */ - /* asm 1: fe_mul(>z_50_0=fe#1,z_50_0=t0,z_50_0=fe#1,z_50_0=t0,z_100_50=fe#2,z_100_50=fe#2,>z_100_50=fe#2); */ - /* asm 2: fe_sq(>z_100_50=t1,z_100_50=t1,>z_100_50=t1); */ - fe_sq(out t1, ref t0); for (i = 1; i < 50; ++i) fe_sq(out t1, ref t1); + /* qhasm: z_100_50 = z_50_0^2^50 */ + /* asm 1: fe_sq(>z_100_50=fe#2,z_100_50=fe#2,>z_100_50=fe#2); */ + /* asm 2: fe_sq(>z_100_50=t1,z_100_50=t1,>z_100_50=t1); */ + fe_sq(out t1, ref t0); + for (i = 1; i < 50; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z_100_0 = z_100_50*z_50_0 */ - /* asm 1: fe_mul(>z_100_0=fe#2,z_100_0=t1,z_100_0=fe#2,z_100_0=t1,z_200_100=fe#3,z_200_100=fe#3,>z_200_100=fe#3); */ - /* asm 2: fe_sq(>z_200_100=t2,z_200_100=t2,>z_200_100=t2); */ - fe_sq(out t2, ref t1); for (i = 1; i < 100; ++i) fe_sq(out t2, ref t2); + /* qhasm: z_200_100 = z_100_0^2^100 */ + /* asm 1: fe_sq(>z_200_100=fe#3,z_200_100=fe#3,>z_200_100=fe#3); */ + /* asm 2: fe_sq(>z_200_100=t2,z_200_100=t2,>z_200_100=t2); */ + fe_sq(out t2, ref t1); + for (i = 1; i < 100; ++i) + fe_sq(out t2, ref t2); - /* qhasm: z_200_0 = z_200_100*z_100_0 */ - /* asm 1: fe_mul(>z_200_0=fe#2,z_200_0=t1,z_200_0=fe#2,z_200_0=t1,z_250_50=fe#2,z_250_50=fe#2,>z_250_50=fe#2); */ - /* asm 2: fe_sq(>z_250_50=t1,z_250_50=t1,>z_250_50=t1); */ - fe_sq(out t1, ref t1); for (i = 1; i < 50; ++i) fe_sq(out t1, ref t1); + /* qhasm: z_250_50 = z_200_0^2^50 */ + /* asm 1: fe_sq(>z_250_50=fe#2,z_250_50=fe#2,>z_250_50=fe#2); */ + /* asm 2: fe_sq(>z_250_50=t1,z_250_50=t1,>z_250_50=t1); */ + fe_sq(out t1, ref t1); + for (i = 1; i < 50; ++i) + fe_sq(out t1, ref t1); - /* qhasm: z_250_0 = z_250_50*z_50_0 */ - /* asm 1: fe_mul(>z_250_0=fe#1,z_250_0=t0,z_250_0=fe#1,z_250_0=t0,z_252_2=fe#1,z_252_2=fe#1,>z_252_2=fe#1); */ - /* asm 2: fe_sq(>z_252_2=t0,z_252_2=t0,>z_252_2=t0); */ - fe_sq(out t0, ref t0); for (i = 1; i < 2; ++i) fe_sq(out t0, ref t0); + /* qhasm: z_252_2 = z_250_0^2^2 */ + /* asm 1: fe_sq(>z_252_2=fe#1,z_252_2=fe#1,>z_252_2=fe#1); */ + /* asm 2: fe_sq(>z_252_2=t0,z_252_2=t0,>z_252_2=t0); */ + fe_sq(out t0, ref t0); + for (i = 1; i < 2; ++i) + fe_sq(out t0, ref t0); - /* qhasm: z_252_3 = z_252_2*z1 */ - /* asm 1: fe_mul(>z_252_3=fe#12,z_252_3=out,z_252_3=fe#12,z_252_3=out,> 26; h1 += carry0; h0 -= carry0 << 26; - var carry4 = (h4 + (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - var carry1 = (h1 + (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - var carry5 = (h5 + (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - var carry2 = (h2 + (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - var carry6 = (h6 + (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - var carry3 = (h3 + (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - var carry7 = (h7 + (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + var carry0 = (h0 + (1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; + var carry4 = (h4 + (1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; + var carry1 = (h1 + (1 << 24)) >> 25; + h2 += carry1; + h1 -= carry1 << 25; + var carry5 = (h5 + (1 << 24)) >> 25; + h6 += carry5; + h5 -= carry5 << 25; + var carry2 = (h2 + (1 << 25)) >> 26; + h3 += carry2; + h2 -= carry2 << 26; + var carry6 = (h6 + (1 << 25)) >> 26; + h7 += carry6; + h6 -= carry6 << 26; + var carry3 = (h3 + (1 << 24)) >> 25; + h4 += carry3; + h3 -= carry3 << 25; + var carry7 = (h7 + (1 << 24)) >> 25; + h8 += carry7; + h7 -= carry7 << 25; - carry4 = (h4 + (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry4 = (h4 + (1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; - var carry8 = (h8 + (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; - var carry9 = (h9 + (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; + var carry8 = (h8 + (1 << 25)) >> 26; + h9 += carry8; + h8 -= carry8 << 26; + var carry9 = (h9 + (1 << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 << 25; - carry0 = (h0 + (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry0 = (h0 + (1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; - h.x0 = (int)h0; - h.x1 = (int)h1; - h.x2 = (int)h2; - h.x3 = (int)h3; - h.x4 = (int)h4; - h.x5 = (int)h5; - h.x6 = (int)h6; - h.x7 = (int)h7; - h.x8 = (int)h8; - h.x9 = (int)h9; - } - } -} \ No newline at end of file + h.x0 = (int)h0; + h.x1 = (int)h1; + h.x2 = (int)h2; + h.x3 = (int)h3; + h.x4 = (int)h4; + h.x5 = (int)h5; + h.x6 = (int)h6; + h.x7 = (int)h7; + h.x8 = (int)h8; + h.x9 = (int)h9; + } + } +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sq2.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sq2.cs index d1c2ee33..5150fca5 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sq2.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sq2.cs @@ -1,10 +1,10 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - /* + internal static partial class FieldOperations + { + /* h = 2 * f * f Can overlap h with f. @@ -15,11 +15,11 @@ Postconditions: |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. */ - /* + /* See fe_mul.c for discussion of implementation strategy. */ - internal static void fe_sq2(out FieldElement h, ref FieldElement f) - { + internal static void fe_sq2(out FieldElement h, ref FieldElement f) + { int f0 = f.x0; int f1 = f.x1; int f2 = f.x2; @@ -112,43 +112,67 @@ Postconditions: var h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; var h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; - h0 += h0; - h1 += h1; - h2 += h2; - h3 += h3; - h4 += h4; - h5 += h5; - h6 += h6; - h7 += h7; - h8 += h8; - h9 += h9; + h0 += h0; + h1 += h1; + h2 += h2; + h3 += h3; + h4 += h4; + h5 += h5; + h6 += h6; + h7 += h7; + h8 += h8; + h9 += h9; - var carry0 = (h0 + (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - var carry4 = (h4 + (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - var carry1 = (h1 + (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - var carry5 = (h5 + (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - var carry2 = (h2 + (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - var carry6 = (h6 + (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - var carry3 = (h3 + (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - var carry7 = (h7 + (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + var carry0 = (h0 + (1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; + var carry4 = (h4 + (1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; + var carry1 = (h1 + (1 << 24)) >> 25; + h2 += carry1; + h1 -= carry1 << 25; + var carry5 = (h5 + (1 << 24)) >> 25; + h6 += carry5; + h5 -= carry5 << 25; + var carry2 = (h2 + (1 << 25)) >> 26; + h3 += carry2; + h2 -= carry2 << 26; + var carry6 = (h6 + (1 << 25)) >> 26; + h7 += carry6; + h6 -= carry6 << 26; + var carry3 = (h3 + (1 << 24)) >> 25; + h4 += carry3; + h3 -= carry3 << 25; + var carry7 = (h7 + (1 << 24)) >> 25; + h8 += carry7; + h7 -= carry7 << 25; - carry4 = (h4 + (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry4 = (h4 + (1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 << 26; - var carry8 = (h8 + (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; - var carry9 = (h9 + (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; + var carry8 = (h8 + (1 << 25)) >> 26; + h9 += carry8; + h8 -= carry8 << 26; + var carry9 = (h9 + (1 << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 << 25; - carry0 = (h0 + (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry0 = (h0 + (1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 << 26; - h.x0 = (int)h0; - h.x1 = (int)h1; - h.x2 = (int)h2; - h.x3 = (int)h3; - h.x4 = (int)h4; - h.x5 = (int)h5; - h.x6 = (int)h6; - h.x7 = (int)h7; - h.x8 = (int)h8; - h.x9 = (int)h9; - } - } -} \ No newline at end of file + h.x0 = (int)h0; + h.x1 = (int)h1; + h.x2 = (int)h2; + h.x3 = (int)h3; + h.x4 = (int)h4; + h.x5 = (int)h5; + h.x6 = (int)h6; + h.x7 = (int)h7; + h.x8 = (int)h8; + h.x9 = (int)h9; + } + } +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sub.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sub.cs index f76e6d75..093b5cc6 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sub.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_sub.cs @@ -1,10 +1,10 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class FieldOperations - { - /* + internal static partial class FieldOperations + { + /* h = f - g Can overlap h with f or g. @@ -16,8 +16,8 @@ namespace Discord.Net.ED25519.Ed25519Ref10 |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. */ - internal static void fe_sub(out FieldElement h, ref FieldElement f, ref FieldElement g) - { + internal static void fe_sub(out FieldElement h, ref FieldElement f, ref FieldElement g) + { int f0 = f.x0; int f1 = f.x1; int f2 = f.x2; @@ -51,16 +51,16 @@ namespace Discord.Net.ED25519.Ed25519Ref10 int h8 = f8 - g8; int h9 = f9 - g9; - h.x0 = h0; - h.x1 = h1; - h.x2 = h2; - h.x3 = h3; - h.x4 = h4; - h.x5 = h5; - h.x6 = h6; - h.x7 = h7; - h.x8 = h8; - h.x9 = h9; - } - } -} \ No newline at end of file + h.x0 = h0; + h.x1 = h1; + h.x2 = h2; + h.x3 = h3; + h.x4 = h4; + h.x5 = h5; + h.x6 = h6; + h.x7 = h7; + h.x8 = h8; + h.x9 = h9; + } + } +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_tobytes.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_tobytes.cs index 601f88f2..b3560bc2 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_tobytes.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/fe_tobytes.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { @@ -52,38 +52,38 @@ namespace Discord.Net.ED25519.Ed25519Ref10 */ unchecked { - s[offset + 0] = (byte) (h0 >> 0); - s[offset + 1] = (byte) (h0 >> 8); - s[offset + 2] = (byte) (h0 >> 16); - s[offset + 3] = (byte) ((h0 >> 24) | (h1 << 2)); - s[offset + 4] = (byte) (h1 >> 6); - s[offset + 5] = (byte) (h1 >> 14); - s[offset + 6] = (byte) ((h1 >> 22) | (h2 << 3)); - s[offset + 7] = (byte) (h2 >> 5); - s[offset + 8] = (byte) (h2 >> 13); - s[offset + 9] = (byte) ((h2 >> 21) | (h3 << 5)); - s[offset + 10] = (byte) (h3 >> 3); - s[offset + 11] = (byte) (h3 >> 11); - s[offset + 12] = (byte) ((h3 >> 19) | (h4 << 6)); - s[offset + 13] = (byte) (h4 >> 2); - s[offset + 14] = (byte) (h4 >> 10); - s[offset + 15] = (byte) (h4 >> 18); - s[offset + 16] = (byte) (h5 >> 0); - s[offset + 17] = (byte) (h5 >> 8); - s[offset + 18] = (byte) (h5 >> 16); - s[offset + 19] = (byte) ((h5 >> 24) | (h6 << 1)); - s[offset + 20] = (byte) (h6 >> 7); - s[offset + 21] = (byte) (h6 >> 15); - s[offset + 22] = (byte) ((h6 >> 23) | (h7 << 3)); - s[offset + 23] = (byte) (h7 >> 5); - s[offset + 24] = (byte) (h7 >> 13); - s[offset + 25] = (byte) ((h7 >> 21) | (h8 << 4)); - s[offset + 26] = (byte) (h8 >> 4); - s[offset + 27] = (byte) (h8 >> 12); - s[offset + 28] = (byte) ((h8 >> 20) | (h9 << 6)); - s[offset + 29] = (byte) (h9 >> 2); - s[offset + 30] = (byte) (h9 >> 10); - s[offset + 31] = (byte) (h9 >> 18); + s[offset + 0] = (byte)(h0 >> 0); + s[offset + 1] = (byte)(h0 >> 8); + s[offset + 2] = (byte)(h0 >> 16); + s[offset + 3] = (byte)((h0 >> 24) | (h1 << 2)); + s[offset + 4] = (byte)(h1 >> 6); + s[offset + 5] = (byte)(h1 >> 14); + s[offset + 6] = (byte)((h1 >> 22) | (h2 << 3)); + s[offset + 7] = (byte)(h2 >> 5); + s[offset + 8] = (byte)(h2 >> 13); + s[offset + 9] = (byte)((h2 >> 21) | (h3 << 5)); + s[offset + 10] = (byte)(h3 >> 3); + s[offset + 11] = (byte)(h3 >> 11); + s[offset + 12] = (byte)((h3 >> 19) | (h4 << 6)); + s[offset + 13] = (byte)(h4 >> 2); + s[offset + 14] = (byte)(h4 >> 10); + s[offset + 15] = (byte)(h4 >> 18); + s[offset + 16] = (byte)(h5 >> 0); + s[offset + 17] = (byte)(h5 >> 8); + s[offset + 18] = (byte)(h5 >> 16); + s[offset + 19] = (byte)((h5 >> 24) | (h6 << 1)); + s[offset + 20] = (byte)(h6 >> 7); + s[offset + 21] = (byte)(h6 >> 15); + s[offset + 22] = (byte)((h6 >> 23) | (h7 << 3)); + s[offset + 23] = (byte)(h7 >> 5); + s[offset + 24] = (byte)(h7 >> 13); + s[offset + 25] = (byte)((h7 >> 21) | (h8 << 4)); + s[offset + 26] = (byte)(h8 >> 4); + s[offset + 27] = (byte)(h8 >> 12); + s[offset + 28] = (byte)((h8 >> 20) | (h9 << 6)); + s[offset + 29] = (byte)(h9 >> 2); + s[offset + 30] = (byte)(h9 >> 10); + s[offset + 31] = (byte)(h9 >> 18); } } @@ -118,16 +118,35 @@ namespace Discord.Net.ED25519.Ed25519Ref10 h0 += 19 * q; /* Goal: Output h-2^255 q, which is between 0 and 2^255-20. */ - var carry0 = h0 >> 26; h1 += carry0; h0 -= carry0 << 26; - var carry1 = h1 >> 25; h2 += carry1; h1 -= carry1 << 25; - var carry2 = h2 >> 26; h3 += carry2; h2 -= carry2 << 26; - var carry3 = h3 >> 25; h4 += carry3; h3 -= carry3 << 25; - var carry4 = h4 >> 26; h5 += carry4; h4 -= carry4 << 26; - var carry5 = h5 >> 25; h6 += carry5; h5 -= carry5 << 25; - var carry6 = h6 >> 26; h7 += carry6; h6 -= carry6 << 26; - var carry7 = h7 >> 25; h8 += carry7; h7 -= carry7 << 25; - var carry8 = h8 >> 26; h9 += carry8; h8 -= carry8 << 26; - var carry9 = h9 >> 25; h9 -= carry9 << 25; + var carry0 = h0 >> 26; + h1 += carry0; + h0 -= carry0 << 26; + var carry1 = h1 >> 25; + h2 += carry1; + h1 -= carry1 << 25; + var carry2 = h2 >> 26; + h3 += carry2; + h2 -= carry2 << 26; + var carry3 = h3 >> 25; + h4 += carry3; + h3 -= carry3 << 25; + var carry4 = h4 >> 26; + h5 += carry4; + h4 -= carry4 << 26; + var carry5 = h5 >> 25; + h6 += carry5; + h5 -= carry5 << 25; + var carry6 = h6 >> 26; + h7 += carry6; + h6 -= carry6 << 26; + var carry7 = h7 >> 25; + h8 += carry7; + h7 -= carry7 << 25; + var carry8 = h8 >> 26; + h9 += carry8; + h8 -= carry8 << 26; + var carry9 = h9 >> 25; + h9 -= carry9 << 25; /* h10 = carry9 */ hr.x0 = h0; @@ -142,4 +161,4 @@ namespace Discord.Net.ED25519.Ed25519Ref10 hr.x9 = h9; } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_add.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_add.cs index de8e08f1..6c3f8947 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_add.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_add.cs @@ -1,73 +1,73 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class GroupOperations - { - /* + internal static partial class GroupOperations + { + /* r = p + q */ - internal static void ge_add(out GroupElementP1P1 r, ref GroupElementP3 p, ref GroupElementCached q) - { - FieldElement t0; + internal static void ge_add(out GroupElementP1P1 r, ref GroupElementP3 p, ref GroupElementCached q) + { + FieldElement t0; - /* qhasm: YpX1 = Y1+X1 */ - /* asm 1: fe_add(>YpX1=fe#1,YpX1=r.X,YpX1=fe#1,YpX1=r.X,YmX1=fe#2,YmX1=r.Y,YmX1=fe#2,YmX1=r.Y,A=fe#3,A=r.Z,A=fe#3,A=r.Z,B=fe#2,B=r.Y,B=fe#2,B=r.Y,C=fe#4,C=r.T,C=fe#4,C=r.T,ZZ=fe#1,ZZ=r.X,ZZ=fe#1,ZZ=r.X,D=fe#5,D=t0,D=fe#5,D=t0,X3=fe#1,X3=r.X,X3=fe#1,X3=r.X,Y3=fe#2,Y3=r.Y,Y3=fe#2,Y3=r.Y,Z3=fe#3,Z3=r.Z,Z3=fe#3,Z3=r.Z,T3=fe#4,T3=r.T,T3=fe#4,T3=r.T,> 3] >> (i & 7))); + internal static partial class GroupOperations + { + private static void slide(sbyte[] r, byte[] a) + { + for (int i = 0; i < 256; ++i) + r[i] = (sbyte)(1 & (a[i >> 3] >> (i & 7))); for (int i = 0; i < 256; ++i) { @@ -19,7 +19,8 @@ namespace Discord.Net.ED25519.Ed25519Ref10 { if (r[i] + (r[i + b] << b) <= 15) { - r[i] += (sbyte)(r[i + b] << b); r[i + b] = 0; + r[i] += (sbyte)(r[i + b] << b); + r[i + b] = 0; } else if (r[i] - (r[i + b] << b) >= -15) { @@ -40,76 +41,92 @@ namespace Discord.Net.ED25519.Ed25519Ref10 } } } - } + } - /* + /* r = a * A + b * B where a = a[0]+256*a[1]+...+256^31 a[31]. and b = b[0]+256*b[1]+...+256^31 b[31]. B is the Ed25519 base point (x,4/5) with x positive. */ - public static void ge_double_scalarmult_vartime(out GroupElementP2 r, byte[] a, ref GroupElementP3 A, byte[] b) - { - GroupElementPreComp[] Bi = LookupTables.Base2; + public static void ge_double_scalarmult_vartime(out GroupElementP2 r, byte[] a, ref GroupElementP3 A, byte[] b) + { + GroupElementPreComp[] Bi = LookupTables.Base2; // todo: Perhaps remove these allocations? - sbyte[] aslide = new sbyte[256]; - sbyte[] bslide = new sbyte[256]; - GroupElementCached[] Ai = new GroupElementCached[8]; /* A,3A,5A,7A,9A,11A,13A,15A */ - GroupElementP1P1 t; - GroupElementP3 u; - GroupElementP3 A2; - int i; + sbyte[] aslide = new sbyte[256]; + sbyte[] bslide = new sbyte[256]; + GroupElementCached[] Ai = new GroupElementCached[8]; /* A,3A,5A,7A,9A,11A,13A,15A */ + GroupElementP1P1 t; + GroupElementP3 u; + GroupElementP3 A2; + int i; - slide(aslide, a); - slide(bslide, b); + slide(aslide, a); + slide(bslide, b); - ge_p3_to_cached(out Ai[0], ref A); - ge_p3_dbl(out t, ref A); ge_p1p1_to_p3(out A2, ref t); - ge_add(out t, ref A2, ref Ai[0]); ge_p1p1_to_p3(out u, ref t); ge_p3_to_cached(out Ai[1], ref u); - ge_add(out t, ref A2, ref Ai[1]); ge_p1p1_to_p3(out u, ref t); ge_p3_to_cached(out Ai[2], ref u); - ge_add(out t, ref A2, ref Ai[2]); ge_p1p1_to_p3(out u, ref t); ge_p3_to_cached(out Ai[3], ref u); - ge_add(out t, ref A2, ref Ai[3]); ge_p1p1_to_p3(out u, ref t); ge_p3_to_cached(out Ai[4], ref u); - ge_add(out t, ref A2, ref Ai[4]); ge_p1p1_to_p3(out u, ref t); ge_p3_to_cached(out Ai[5], ref u); - ge_add(out t, ref A2, ref Ai[5]); ge_p1p1_to_p3(out u, ref t); ge_p3_to_cached(out Ai[6], ref u); - ge_add(out t, ref A2, ref Ai[6]); ge_p1p1_to_p3(out u, ref t); ge_p3_to_cached(out Ai[7], ref u); + ge_p3_to_cached(out Ai[0], ref A); + ge_p3_dbl(out t, ref A); + ge_p1p1_to_p3(out A2, ref t); + ge_add(out t, ref A2, ref Ai[0]); + ge_p1p1_to_p3(out u, ref t); + ge_p3_to_cached(out Ai[1], ref u); + ge_add(out t, ref A2, ref Ai[1]); + ge_p1p1_to_p3(out u, ref t); + ge_p3_to_cached(out Ai[2], ref u); + ge_add(out t, ref A2, ref Ai[2]); + ge_p1p1_to_p3(out u, ref t); + ge_p3_to_cached(out Ai[3], ref u); + ge_add(out t, ref A2, ref Ai[3]); + ge_p1p1_to_p3(out u, ref t); + ge_p3_to_cached(out Ai[4], ref u); + ge_add(out t, ref A2, ref Ai[4]); + ge_p1p1_to_p3(out u, ref t); + ge_p3_to_cached(out Ai[5], ref u); + ge_add(out t, ref A2, ref Ai[5]); + ge_p1p1_to_p3(out u, ref t); + ge_p3_to_cached(out Ai[6], ref u); + ge_add(out t, ref A2, ref Ai[6]); + ge_p1p1_to_p3(out u, ref t); + ge_p3_to_cached(out Ai[7], ref u); - ge_p2_0(out r); + ge_p2_0(out r); - for (i = 255; i >= 0; --i) - { - if ((aslide[i] != 0) || (bslide[i] != 0)) break; - } + for (i = 255; i >= 0; --i) + { + if ((aslide[i] != 0) || (bslide[i] != 0)) + break; + } - for (; i >= 0; --i) - { - ge_p2_dbl(out t, ref r); + for (; i >= 0; --i) + { + ge_p2_dbl(out t, ref r); - if (aslide[i] > 0) - { - ge_p1p1_to_p3(out u, ref t); - ge_add(out t, ref u, ref Ai[aslide[i] / 2]); - } - else if (aslide[i] < 0) - { - ge_p1p1_to_p3(out u, ref t); - ge_sub(out t, ref u, ref Ai[(-aslide[i]) / 2]); - } + if (aslide[i] > 0) + { + ge_p1p1_to_p3(out u, ref t); + ge_add(out t, ref u, ref Ai[aslide[i] / 2]); + } + else if (aslide[i] < 0) + { + ge_p1p1_to_p3(out u, ref t); + ge_sub(out t, ref u, ref Ai[(-aslide[i]) / 2]); + } - if (bslide[i] > 0) - { - ge_p1p1_to_p3(out u, ref t); - ge_madd(out t, ref u, ref Bi[bslide[i] / 2]); - } - else if (bslide[i] < 0) - { - ge_p1p1_to_p3(out u, ref t); - ge_msub(out t, ref u, ref Bi[(-bslide[i]) / 2]); - } + if (bslide[i] > 0) + { + ge_p1p1_to_p3(out u, ref t); + ge_madd(out t, ref u, ref Bi[bslide[i] / 2]); + } + else if (bslide[i] < 0) + { + ge_p1p1_to_p3(out u, ref t); + ge_msub(out t, ref u, ref Bi[(-bslide[i]) / 2]); + } - ge_p1p1_to_p2(out r, ref t); - } - } + ge_p1p1_to_p2(out r, ref t); + } + } - } -} \ No newline at end of file + } +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_frombytes.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_frombytes.cs index 2e7abe9d..4639d102 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_frombytes.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_frombytes.cs @@ -1,50 +1,50 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class GroupOperations - { - public static int ge_frombytes_negate_vartime(out GroupElementP3 h, byte[] data, int offset) - { - FieldElement u, v, v3, vxx, check; + internal static partial class GroupOperations + { + public static int ge_frombytes_negate_vartime(out GroupElementP3 h, byte[] data, int offset) + { + FieldElement u, v, v3, vxx, check; - FieldOperations.fe_frombytes(out h.Y, data, offset); - FieldOperations.fe_1(out h.Z); - FieldOperations.fe_sq(out u, ref h.Y); - FieldOperations.fe_mul(out v, ref u, ref LookupTables.d); - FieldOperations.fe_sub(out u, ref u, ref h.Z); /* u = y^2-1 */ - FieldOperations.fe_add(out v, ref v, ref h.Z); /* v = dy^2+1 */ + FieldOperations.fe_frombytes(out h.Y, data, offset); + FieldOperations.fe_1(out h.Z); + FieldOperations.fe_sq(out u, ref h.Y); + FieldOperations.fe_mul(out v, ref u, ref LookupTables.d); + FieldOperations.fe_sub(out u, ref u, ref h.Z); /* u = y^2-1 */ + FieldOperations.fe_add(out v, ref v, ref h.Z); /* v = dy^2+1 */ - FieldOperations.fe_sq(out v3, ref v); - FieldOperations.fe_mul(out v3, ref v3, ref v); /* v3 = v^3 */ - FieldOperations.fe_sq(out h.X, ref v3); - FieldOperations.fe_mul(out h.X, ref h.X, ref v); - FieldOperations.fe_mul(out h.X, ref h.X, ref u); /* x = uv^7 */ + FieldOperations.fe_sq(out v3, ref v); + FieldOperations.fe_mul(out v3, ref v3, ref v); /* v3 = v^3 */ + FieldOperations.fe_sq(out h.X, ref v3); + FieldOperations.fe_mul(out h.X, ref h.X, ref v); + FieldOperations.fe_mul(out h.X, ref h.X, ref u); /* x = uv^7 */ - FieldOperations.fe_pow22523(out h.X, ref h.X); /* x = (uv^7)^((q-5)/8) */ - FieldOperations.fe_mul(out h.X, ref h.X, ref v3); - FieldOperations.fe_mul(out h.X, ref h.X, ref u); /* x = uv^3(uv^7)^((q-5)/8) */ + FieldOperations.fe_pow22523(out h.X, ref h.X); /* x = (uv^7)^((q-5)/8) */ + FieldOperations.fe_mul(out h.X, ref h.X, ref v3); + FieldOperations.fe_mul(out h.X, ref h.X, ref u); /* x = uv^3(uv^7)^((q-5)/8) */ - FieldOperations.fe_sq(out vxx, ref h.X); - FieldOperations.fe_mul(out vxx, ref vxx, ref v); - FieldOperations.fe_sub(out check, ref vxx, ref u); /* vx^2-u */ - if (FieldOperations.fe_isnonzero(ref check) != 0) - { - FieldOperations.fe_add(out check, ref vxx, ref u); /* vx^2+u */ - if (FieldOperations.fe_isnonzero(ref check) != 0) - { - h = default(GroupElementP3); - return -1; - } - FieldOperations.fe_mul(out h.X, ref h.X, ref LookupTables.sqrtm1); - } + FieldOperations.fe_sq(out vxx, ref h.X); + FieldOperations.fe_mul(out vxx, ref vxx, ref v); + FieldOperations.fe_sub(out check, ref vxx, ref u); /* vx^2-u */ + if (FieldOperations.fe_isnonzero(ref check) != 0) + { + FieldOperations.fe_add(out check, ref vxx, ref u); /* vx^2+u */ + if (FieldOperations.fe_isnonzero(ref check) != 0) + { + h = default(GroupElementP3); + return -1; + } + FieldOperations.fe_mul(out h.X, ref h.X, ref LookupTables.sqrtm1); + } - if (FieldOperations.fe_isnegative(ref h.X) == (data[offset + 31] >> 7)) - FieldOperations.fe_neg(out h.X, ref h.X); + if (FieldOperations.fe_isnegative(ref h.X) == (data[offset + 31] >> 7)) + FieldOperations.fe_neg(out h.X, ref h.X); - FieldOperations.fe_mul(out h.T, ref h.X, ref h.Y); - return 0; - } + FieldOperations.fe_mul(out h.T, ref h.X, ref h.Y); + return 0; + } - } -} \ No newline at end of file + } +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_madd.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_madd.cs index 547e17d8..19499646 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_madd.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_madd.cs @@ -1,69 +1,69 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class GroupOperations - { - /* + internal static partial class GroupOperations + { + /* r = p + q */ - public static void ge_madd(out GroupElementP1P1 r, ref GroupElementP3 p, ref GroupElementPreComp q) - { - FieldElement t0; + public static void ge_madd(out GroupElementP1P1 r, ref GroupElementP3 p, ref GroupElementPreComp q) + { + FieldElement t0; - /* qhasm: YpX1 = Y1+X1 */ - /* asm 1: fe_add(>YpX1=fe#1,YpX1=r.X,YpX1=fe#1,YpX1=r.X,YmX1=fe#2,YmX1=r.Y,YmX1=fe#2,YmX1=r.Y,A=fe#3,A=r.Z,A=fe#3,A=r.Z,B=fe#2,B=r.Y,B=fe#2,B=r.Y,C=fe#4,C=r.T,C=fe#4,C=r.T,D=fe#5,D=t0,D=fe#5,D=t0,X3=fe#1,X3=r.X,X3=fe#1,X3=r.X,Y3=fe#2,Y3=r.Y,Y3=fe#2,Y3=r.Y,Z3=fe#3,Z3=r.Z,Z3=fe#3,Z3=r.Z,T3=fe#4,T3=r.T,T3=fe#4,T3=r.T,YpX1=fe#1,YpX1=r.X,YpX1=fe#1,YpX1=r.X,YmX1=fe#2,YmX1=r.Y,YmX1=fe#2,YmX1=r.Y,A=fe#3,A=r.Z,A=fe#3,A=r.Z,B=fe#2,B=r.Y,B=fe#2,B=r.Y,C=fe#4,C=r.T,C=fe#4,C=r.T,D=fe#5,D=t0,D=fe#5,D=t0,X3=fe#1,X3=r.X,X3=fe#1,X3=r.X,Y3=fe#2,Y3=r.Y,Y3=fe#2,Y3=r.Y,Z3=fe#3,Z3=r.Z,Z3=fe#3,Z3=r.Z,T3=fe#4,T3=r.T,T3=fe#4,T3=r.T,XX=fe#1,XX=r.X,XX=fe#1,XX=r.X,YY=fe#3,YY=r.Z,YY=fe#3,YY=r.Z,B=fe#4,B=r.T,B=fe#4,B=r.T,A=fe#2,A=r.Y,A=fe#2,A=r.Y,AA=fe#5,AA=t0,AA=fe#5,AA=t0,Y3=fe#2,Y3=r.Y,Y3=fe#2,Y3=r.Y,Z3=fe#3,Z3=r.Z,Z3=fe#3,Z3=r.Z,X3=fe#1,X3=r.X,X3=fe#1,X3=r.X,T3=fe#4,T3=r.T,T3=fe#4,T3=r.T,>= 31; /* 1: yes; 0: no */ return (byte)y; } @@ -94,20 +95,26 @@ namespace Discord.Net.ED25519.Ed25519Ref10 for (int i = 1; i < 64; i += 2) { select(out t, i / 2, e[i]); - ge_madd(out r, ref h, ref t); ge_p1p1_to_p3(out h, ref r); + ge_madd(out r, ref h, ref t); + ge_p1p1_to_p3(out h, ref r); } - ge_p3_dbl(out r, ref h); ge_p1p1_to_p2(out s, ref r); - ge_p2_dbl(out r, ref s); ge_p1p1_to_p2(out s, ref r); - ge_p2_dbl(out r, ref s); ge_p1p1_to_p2(out s, ref r); - ge_p2_dbl(out r, ref s); ge_p1p1_to_p3(out h, ref r); + ge_p3_dbl(out r, ref h); + ge_p1p1_to_p2(out s, ref r); + ge_p2_dbl(out r, ref s); + ge_p1p1_to_p2(out s, ref r); + ge_p2_dbl(out r, ref s); + ge_p1p1_to_p2(out s, ref r); + ge_p2_dbl(out r, ref s); + ge_p1p1_to_p3(out h, ref r); for (int i = 0; i < 64; i += 2) { select(out t, i / 2, e[i]); - ge_madd(out r, ref h, ref t); ge_p1p1_to_p3(out h, ref r); + ge_madd(out r, ref h, ref t); + ge_p1p1_to_p3(out h, ref r); } } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_sub.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_sub.cs index c0b9ba5a..25d909ef 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_sub.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/ge_sub.cs @@ -1,74 +1,74 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - internal static partial class GroupOperations - { - /* + internal static partial class GroupOperations + { + /* r = p - q */ - public static void ge_sub(out GroupElementP1P1 r, ref GroupElementP3 p, ref GroupElementCached q) - { - FieldElement t0; + public static void ge_sub(out GroupElementP1P1 r, ref GroupElementP3 p, ref GroupElementCached q) + { + FieldElement t0; - /* qhasm: YpX1 = Y1+X1 */ - /* asm 1: fe_add(>YpX1=fe#1,YpX1=r.X,YpX1=fe#1,YpX1=r.X,YmX1=fe#2,YmX1=r.Y,YmX1=fe#2,YmX1=r.Y,A=fe#3,A=r.Z,A=fe#3,A=r.Z,B=fe#2,B=r.Y,B=fe#2,B=r.Y,C=fe#4,C=r.T,C=fe#4,C=r.T,ZZ=fe#1,ZZ=r.X,ZZ=fe#1,ZZ=r.X,D=fe#5,D=t0,D=fe#5,D=t0,X3=fe#1,X3=r.X,X3=fe#1,X3=r.X,Y3=fe#2,Y3=r.Y,Y3=fe#2,Y3=r.Y,Z3=fe#3,Z3=r.Z,Z3=fe#3,Z3=r.Z,T3=fe#4,T3=r.T,T3=fe#4,T3=r.T,> 21; s1 += carry0; s0 -= carry0 << 21; - carry2 = (s2 + (1 << 20)) >> 21; s3 += carry2; s2 -= carry2 << 21; - carry4 = (s4 + (1 << 20)) >> 21; s5 += carry4; s4 -= carry4 << 21; - carry6 = (s6 + (1 << 20)) >> 21; s7 += carry6; s6 -= carry6 << 21; - carry8 = (s8 + (1 << 20)) >> 21; s9 += carry8; s8 -= carry8 << 21; - carry10 = (s10 + (1 << 20)) >> 21; s11 += carry10; s10 -= carry10 << 21; - carry12 = (s12 + (1 << 20)) >> 21; s13 += carry12; s12 -= carry12 << 21; - carry14 = (s14 + (1 << 20)) >> 21; s15 += carry14; s14 -= carry14 << 21; - carry16 = (s16 + (1 << 20)) >> 21; s17 += carry16; s16 -= carry16 << 21; - carry18 = (s18 + (1 << 20)) >> 21; s19 += carry18; s18 -= carry18 << 21; - carry20 = (s20 + (1 << 20)) >> 21; s21 += carry20; s20 -= carry20 << 21; - carry22 = (s22 + (1 << 20)) >> 21; s23 += carry22; s22 -= carry22 << 21; + carry0 = (s0 + (1 << 20)) >> 21; + s1 += carry0; + s0 -= carry0 << 21; + carry2 = (s2 + (1 << 20)) >> 21; + s3 += carry2; + s2 -= carry2 << 21; + carry4 = (s4 + (1 << 20)) >> 21; + s5 += carry4; + s4 -= carry4 << 21; + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= carry10 << 21; + carry12 = (s12 + (1 << 20)) >> 21; + s13 += carry12; + s12 -= carry12 << 21; + carry14 = (s14 + (1 << 20)) >> 21; + s15 += carry14; + s14 -= carry14 << 21; + carry16 = (s16 + (1 << 20)) >> 21; + s17 += carry16; + s16 -= carry16 << 21; + carry18 = (s18 + (1 << 20)) >> 21; + s19 += carry18; + s18 -= carry18 << 21; + carry20 = (s20 + (1 << 20)) >> 21; + s21 += carry20; + s20 -= carry20 << 21; + carry22 = (s22 + (1 << 20)) >> 21; + s23 += carry22; + s22 -= carry22 << 21; - carry1 = (s1 + (1 << 20)) >> 21; s2 += carry1; s1 -= carry1 << 21; - carry3 = (s3 + (1 << 20)) >> 21; s4 += carry3; s3 -= carry3 << 21; - carry5 = (s5 + (1 << 20)) >> 21; s6 += carry5; s5 -= carry5 << 21; - carry7 = (s7 + (1 << 20)) >> 21; s8 += carry7; s7 -= carry7 << 21; - carry9 = (s9 + (1 << 20)) >> 21; s10 += carry9; s9 -= carry9 << 21; - carry11 = (s11 + (1 << 20)) >> 21; s12 += carry11; s11 -= carry11 << 21; - carry13 = (s13 + (1 << 20)) >> 21; s14 += carry13; s13 -= carry13 << 21; - carry15 = (s15 + (1 << 20)) >> 21; s16 += carry15; s15 -= carry15 << 21; - carry17 = (s17 + (1 << 20)) >> 21; s18 += carry17; s17 -= carry17 << 21; - carry19 = (s19 + (1 << 20)) >> 21; s20 += carry19; s19 -= carry19 << 21; - carry21 = (s21 + (1 << 20)) >> 21; s22 += carry21; s21 -= carry21 << 21; + carry1 = (s1 + (1 << 20)) >> 21; + s2 += carry1; + s1 -= carry1 << 21; + carry3 = (s3 + (1 << 20)) >> 21; + s4 += carry3; + s3 -= carry3 << 21; + carry5 = (s5 + (1 << 20)) >> 21; + s6 += carry5; + s5 -= carry5 << 21; + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= carry11 << 21; + carry13 = (s13 + (1 << 20)) >> 21; + s14 += carry13; + s13 -= carry13 << 21; + carry15 = (s15 + (1 << 20)) >> 21; + s16 += carry15; + s15 -= carry15 << 21; + carry17 = (s17 + (1 << 20)) >> 21; + s18 += carry17; + s17 -= carry17 << 21; + carry19 = (s19 + (1 << 20)) >> 21; + s20 += carry19; + s19 -= carry19 << 21; + carry21 = (s21 + (1 << 20)) >> 21; + s22 += carry21; + s21 -= carry21 << 21; s11 += s23 * 666643; s12 += s23 * 470296; @@ -218,18 +264,40 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s11 -= s18 * 683901; s18 = 0; - carry6 = (s6 + (1 << 20)) >> 21; s7 += carry6; s6 -= carry6 << 21; - carry8 = (s8 + (1 << 20)) >> 21; s9 += carry8; s8 -= carry8 << 21; - carry10 = (s10 + (1 << 20)) >> 21; s11 += carry10; s10 -= carry10 << 21; - carry12 = (s12 + (1 << 20)) >> 21; s13 += carry12; s12 -= carry12 << 21; - carry14 = (s14 + (1 << 20)) >> 21; s15 += carry14; s14 -= carry14 << 21; - carry16 = (s16 + (1 << 20)) >> 21; s17 += carry16; s16 -= carry16 << 21; + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= carry10 << 21; + carry12 = (s12 + (1 << 20)) >> 21; + s13 += carry12; + s12 -= carry12 << 21; + carry14 = (s14 + (1 << 20)) >> 21; + s15 += carry14; + s14 -= carry14 << 21; + carry16 = (s16 + (1 << 20)) >> 21; + s17 += carry16; + s16 -= carry16 << 21; - carry7 = (s7 + (1 << 20)) >> 21; s8 += carry7; s7 -= carry7 << 21; - carry9 = (s9 + (1 << 20)) >> 21; s10 += carry9; s9 -= carry9 << 21; - carry11 = (s11 + (1 << 20)) >> 21; s12 += carry11; s11 -= carry11 << 21; - carry13 = (s13 + (1 << 20)) >> 21; s14 += carry13; s13 -= carry13 << 21; - carry15 = (s15 + (1 << 20)) >> 21; s16 += carry15; s15 -= carry15 << 21; + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= carry11 << 21; + carry13 = (s13 + (1 << 20)) >> 21; + s14 += carry13; + s13 -= carry13 << 21; + carry15 = (s15 + (1 << 20)) >> 21; + s16 += carry15; + s15 -= carry15 << 21; s5 += s17 * 666643; s6 += s17 * 470296; @@ -279,19 +347,43 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s5 -= s12 * 683901; s12 = 0; - carry0 = (s0 + (1 << 20)) >> 21; s1 += carry0; s0 -= carry0 << 21; - carry2 = (s2 + (1 << 20)) >> 21; s3 += carry2; s2 -= carry2 << 21; - carry4 = (s4 + (1 << 20)) >> 21; s5 += carry4; s4 -= carry4 << 21; - carry6 = (s6 + (1 << 20)) >> 21; s7 += carry6; s6 -= carry6 << 21; - carry8 = (s8 + (1 << 20)) >> 21; s9 += carry8; s8 -= carry8 << 21; - carry10 = (s10 + (1 << 20)) >> 21; s11 += carry10; s10 -= carry10 << 21; + carry0 = (s0 + (1 << 20)) >> 21; + s1 += carry0; + s0 -= carry0 << 21; + carry2 = (s2 + (1 << 20)) >> 21; + s3 += carry2; + s2 -= carry2 << 21; + carry4 = (s4 + (1 << 20)) >> 21; + s5 += carry4; + s4 -= carry4 << 21; + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= carry10 << 21; - carry1 = (s1 + (1 << 20)) >> 21; s2 += carry1; s1 -= carry1 << 21; - carry3 = (s3 + (1 << 20)) >> 21; s4 += carry3; s3 -= carry3 << 21; - carry5 = (s5 + (1 << 20)) >> 21; s6 += carry5; s5 -= carry5 << 21; - carry7 = (s7 + (1 << 20)) >> 21; s8 += carry7; s7 -= carry7 << 21; - carry9 = (s9 + (1 << 20)) >> 21; s10 += carry9; s9 -= carry9 << 21; - carry11 = (s11 + (1 << 20)) >> 21; s12 += carry11; s11 -= carry11 << 21; + carry1 = (s1 + (1 << 20)) >> 21; + s2 += carry1; + s1 -= carry1 << 21; + carry3 = (s3 + (1 << 20)) >> 21; + s4 += carry3; + s3 -= carry3 << 21; + carry5 = (s5 + (1 << 20)) >> 21; + s6 += carry5; + s5 -= carry5 << 21; + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= carry11 << 21; s0 += s12 * 666643; s1 += s12 * 470296; @@ -301,18 +393,42 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s5 -= s12 * 683901; s12 = 0; - carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21; - carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21; - carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21; - carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21; - carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21; - carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21; - carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21; - carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21; - carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21; - carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21; - carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21; - carry11 = s11 >> 21; s12 += carry11; s11 -= carry11 << 21; + carry0 = s0 >> 21; + s1 += carry0; + s0 -= carry0 << 21; + carry1 = s1 >> 21; + s2 += carry1; + s1 -= carry1 << 21; + carry2 = s2 >> 21; + s3 += carry2; + s2 -= carry2 << 21; + carry3 = s3 >> 21; + s4 += carry3; + s3 -= carry3 << 21; + carry4 = s4 >> 21; + s5 += carry4; + s4 -= carry4 << 21; + carry5 = s5 >> 21; + s6 += carry5; + s5 -= carry5 << 21; + carry6 = s6 >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry7 = s7 >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry8 = s8 >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry9 = s9 >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry10 = s10 >> 21; + s11 += carry10; + s10 -= carry10 << 21; + carry11 = s11 >> 21; + s12 += carry11; + s11 -= carry11 << 21; s0 += s12 * 666643; s1 += s12 * 470296; @@ -322,17 +438,39 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s5 -= s12 * 683901; s12 = 0; - carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21; - carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21; - carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21; - carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21; - carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21; - carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21; - carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21; - carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21; - carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21; - carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21; - carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21; + carry0 = s0 >> 21; + s1 += carry0; + s0 -= carry0 << 21; + carry1 = s1 >> 21; + s2 += carry1; + s1 -= carry1 << 21; + carry2 = s2 >> 21; + s3 += carry2; + s2 -= carry2 << 21; + carry3 = s3 >> 21; + s4 += carry3; + s3 -= carry3 << 21; + carry4 = s4 >> 21; + s5 += carry4; + s4 -= carry4 << 21; + carry5 = s5 >> 21; + s6 += carry5; + s5 -= carry5 << 21; + carry6 = s6 >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry7 = s7 >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry8 = s8 >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry9 = s9 >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry10 = s10 >> 21; + s11 += carry10; + s10 -= carry10 << 21; unchecked { @@ -371,4 +509,4 @@ namespace Discord.Net.ED25519.Ed25519Ref10 } } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/sc_reduce.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/sc_reduce.cs index d3554455..d30863e9 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/sc_reduce.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/sc_reduce.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { @@ -107,18 +107,40 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s11 -= s18 * 683901; s18 = 0; - carry6 = (s6 + (1 << 20)) >> 21; s7 += carry6; s6 -= carry6 << 21; - carry8 = (s8 + (1 << 20)) >> 21; s9 += carry8; s8 -= carry8 << 21; - carry10 = (s10 + (1 << 20)) >> 21; s11 += carry10; s10 -= carry10 << 21; - carry12 = (s12 + (1 << 20)) >> 21; s13 += carry12; s12 -= carry12 << 21; - carry14 = (s14 + (1 << 20)) >> 21; s15 += carry14; s14 -= carry14 << 21; - carry16 = (s16 + (1 << 20)) >> 21; s17 += carry16; s16 -= carry16 << 21; + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= carry10 << 21; + carry12 = (s12 + (1 << 20)) >> 21; + s13 += carry12; + s12 -= carry12 << 21; + carry14 = (s14 + (1 << 20)) >> 21; + s15 += carry14; + s14 -= carry14 << 21; + carry16 = (s16 + (1 << 20)) >> 21; + s17 += carry16; + s16 -= carry16 << 21; - carry7 = (s7 + (1 << 20)) >> 21; s8 += carry7; s7 -= carry7 << 21; - carry9 = (s9 + (1 << 20)) >> 21; s10 += carry9; s9 -= carry9 << 21; - carry11 = (s11 + (1 << 20)) >> 21; s12 += carry11; s11 -= carry11 << 21; - carry13 = (s13 + (1 << 20)) >> 21; s14 += carry13; s13 -= carry13 << 21; - carry15 = (s15 + (1 << 20)) >> 21; s16 += carry15; s15 -= carry15 << 21; + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= carry11 << 21; + carry13 = (s13 + (1 << 20)) >> 21; + s14 += carry13; + s13 -= carry13 << 21; + carry15 = (s15 + (1 << 20)) >> 21; + s16 += carry15; + s15 -= carry15 << 21; s5 += s17 * 666643; s6 += s17 * 470296; @@ -168,19 +190,43 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s5 -= s12 * 683901; s12 = 0; - carry0 = (s0 + (1 << 20)) >> 21; s1 += carry0; s0 -= carry0 << 21; - carry2 = (s2 + (1 << 20)) >> 21; s3 += carry2; s2 -= carry2 << 21; - carry4 = (s4 + (1 << 20)) >> 21; s5 += carry4; s4 -= carry4 << 21; - carry6 = (s6 + (1 << 20)) >> 21; s7 += carry6; s6 -= carry6 << 21; - carry8 = (s8 + (1 << 20)) >> 21; s9 += carry8; s8 -= carry8 << 21; - carry10 = (s10 + (1 << 20)) >> 21; s11 += carry10; s10 -= carry10 << 21; + carry0 = (s0 + (1 << 20)) >> 21; + s1 += carry0; + s0 -= carry0 << 21; + carry2 = (s2 + (1 << 20)) >> 21; + s3 += carry2; + s2 -= carry2 << 21; + carry4 = (s4 + (1 << 20)) >> 21; + s5 += carry4; + s4 -= carry4 << 21; + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= carry10 << 21; - carry1 = (s1 + (1 << 20)) >> 21; s2 += carry1; s1 -= carry1 << 21; - carry3 = (s3 + (1 << 20)) >> 21; s4 += carry3; s3 -= carry3 << 21; - carry5 = (s5 + (1 << 20)) >> 21; s6 += carry5; s5 -= carry5 << 21; - carry7 = (s7 + (1 << 20)) >> 21; s8 += carry7; s7 -= carry7 << 21; - carry9 = (s9 + (1 << 20)) >> 21; s10 += carry9; s9 -= carry9 << 21; - carry11 = (s11 + (1 << 20)) >> 21; s12 += carry11; s11 -= carry11 << 21; + carry1 = (s1 + (1 << 20)) >> 21; + s2 += carry1; + s1 -= carry1 << 21; + carry3 = (s3 + (1 << 20)) >> 21; + s4 += carry3; + s3 -= carry3 << 21; + carry5 = (s5 + (1 << 20)) >> 21; + s6 += carry5; + s5 -= carry5 << 21; + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= carry11 << 21; s0 += s12 * 666643; s1 += s12 * 470296; @@ -190,18 +236,42 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s5 -= s12 * 683901; s12 = 0; - carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21; - carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21; - carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21; - carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21; - carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21; - carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21; - carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21; - carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21; - carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21; - carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21; - carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21; - carry11 = s11 >> 21; s12 += carry11; s11 -= carry11 << 21; + carry0 = s0 >> 21; + s1 += carry0; + s0 -= carry0 << 21; + carry1 = s1 >> 21; + s2 += carry1; + s1 -= carry1 << 21; + carry2 = s2 >> 21; + s3 += carry2; + s2 -= carry2 << 21; + carry3 = s3 >> 21; + s4 += carry3; + s3 -= carry3 << 21; + carry4 = s4 >> 21; + s5 += carry4; + s4 -= carry4 << 21; + carry5 = s5 >> 21; + s6 += carry5; + s5 -= carry5 << 21; + carry6 = s6 >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry7 = s7 >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry8 = s8 >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry9 = s9 >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry10 = s10 >> 21; + s11 += carry10; + s10 -= carry10 << 21; + carry11 = s11 >> 21; + s12 += carry11; + s11 -= carry11 << 21; s0 += s12 * 666643; s1 += s12 * 470296; @@ -211,17 +281,39 @@ namespace Discord.Net.ED25519.Ed25519Ref10 s5 -= s12 * 683901; s12 = 0; - carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21; - carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21; - carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21; - carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21; - carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21; - carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21; - carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21; - carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21; - carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21; - carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21; - carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21; + carry0 = s0 >> 21; + s1 += carry0; + s0 -= carry0 << 21; + carry1 = s1 >> 21; + s2 += carry1; + s1 -= carry1 << 21; + carry2 = s2 >> 21; + s3 += carry2; + s2 -= carry2 << 21; + carry3 = s3 >> 21; + s4 += carry3; + s3 -= carry3 << 21; + carry4 = s4 >> 21; + s5 += carry4; + s4 -= carry4 << 21; + carry5 = s5 >> 21; + s6 += carry5; + s5 -= carry5 << 21; + carry6 = s6 >> 21; + s7 += carry6; + s6 -= carry6 << 21; + carry7 = s7 >> 21; + s8 += carry7; + s7 -= carry7 << 21; + carry8 = s8 >> 21; + s9 += carry8; + s8 -= carry8 << 21; + carry9 = s9 >> 21; + s10 += carry9; + s9 -= carry9 << 21; + carry10 = s10 >> 21; + s11 += carry10; + s10 -= carry10 << 21; unchecked { @@ -261,4 +353,4 @@ namespace Discord.Net.ED25519.Ed25519Ref10 } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/scalarmult.cs b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/scalarmult.cs index 3a7d8fee..6dc0d7f8 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/scalarmult.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Ed25519Ref10/scalarmult.cs @@ -1,153 +1,153 @@ -using System; +using System; namespace Discord.Net.ED25519.Ed25519Ref10 { - public static class MontgomeryOperations - { - public static void scalarmult( - byte[] q, int qoffset, - byte[] n, int noffset, - byte[] p, int poffset) - { - FieldElement p0, q0; - FieldOperations.fe_frombytes2(out p0, p, poffset); - scalarmult(out q0, n, noffset, ref p0); - FieldOperations.fe_tobytes(q, qoffset, ref q0); - } + public static class MontgomeryOperations + { + public static void scalarmult( + byte[] q, int qoffset, + byte[] n, int noffset, + byte[] p, int poffset) + { + FieldElement p0, q0; + FieldOperations.fe_frombytes2(out p0, p, poffset); + scalarmult(out q0, n, noffset, ref p0); + FieldOperations.fe_tobytes(q, qoffset, ref q0); + } - internal static void scalarmult( - out FieldElement q, - byte[] n, int noffset, - ref FieldElement p) - { - byte[] e = new byte[32];//ToDo: remove allocation - FieldElement x1, x2, x3; - FieldElement z2, z3; - FieldElement tmp0, tmp1; + internal static void scalarmult( + out FieldElement q, + byte[] n, int noffset, + ref FieldElement p) + { + byte[] e = new byte[32];//ToDo: remove allocation + FieldElement x1, x2, x3; + FieldElement z2, z3; + FieldElement tmp0, tmp1; - for (int i = 0; i < 32; ++i) - e[i] = n[noffset + i]; - ScalarOperations.sc_clamp(e, 0); - x1 = p; - FieldOperations.fe_1(out x2); - FieldOperations.fe_0(out z2); - x3 = x1; - FieldOperations.fe_1(out z3); + for (int i = 0; i < 32; ++i) + e[i] = n[noffset + i]; + ScalarOperations.sc_clamp(e, 0); + x1 = p; + FieldOperations.fe_1(out x2); + FieldOperations.fe_0(out z2); + x3 = x1; + FieldOperations.fe_1(out z3); - uint swap = 0; - for (int pos = 254; pos >= 0; --pos) - { - uint b = (uint)(e[pos / 8] >> (pos & 7)); - b &= 1; - swap ^= b; - FieldOperations.fe_cswap(ref x2, ref x3, swap); - FieldOperations.fe_cswap(ref z2, ref z3, swap); - swap = b; + uint swap = 0; + for (int pos = 254; pos >= 0; --pos) + { + uint b = (uint)(e[pos / 8] >> (pos & 7)); + b &= 1; + swap ^= b; + FieldOperations.fe_cswap(ref x2, ref x3, swap); + FieldOperations.fe_cswap(ref z2, ref z3, swap); + swap = b; - /* qhasm: enter ladder */ + /* qhasm: enter ladder */ - /* qhasm: D = X3-Z3 */ - /* asm 1: fe_sub(>D=fe#5,D=tmp0,D=fe#5,D=tmp0,B=fe#6,B=tmp1,B=fe#6,B=tmp1,A=fe#1,A=x2,A=fe#1,A=x2,C=fe#2,C=z2,C=fe#2,C=z2,DA=fe#4,DA=z3,DA=fe#4,DA=z3,CB=fe#2,CB=z2,CB=fe#2,CB=z2,BB=fe#5,BB=tmp0,BB=fe#5,BB=tmp0,AA=fe#6,AA=tmp1,AA=fe#6,AA=tmp1,t0=fe#3,t0=x3,t0=fe#3,t0=x3,t1=fe#2,t1=z2,t1=fe#2,t1=z2,X4=fe#1,X4=x2,X4=fe#1,X4=x2,E=fe#6,E=tmp1,E=fe#6,E=tmp1,t2=fe#2,t2=z2,t2=fe#2,t2=z2,t3=fe#4,t3=z3,t3=fe#4,t3=z3,X5=fe#3,X5=x3,X5=fe#3,X5=x3,t4=fe#5,t4=tmp0,t4=fe#5,t4=tmp0,Z5=fe#4,x1,Z5=z3,x1,Z5=fe#4,x1,Z5=z3,x1,Z4=fe#2,Z4=z2,Z4=fe#2,Z4=z2,Sequence length public void Update(byte[] data, int index, int length) { - + Array16 block; int bytesInBuffer = (int)_totalBytes & (BlockSize - 1); _totalBytes += (uint)length; diff --git a/src/Discord.Net.Rest/Net/ED25519/Sha512Internal.cs b/src/Discord.Net.Rest/Net/ED25519/Sha512Internal.cs index df8842d8..5d9879eb 100644 --- a/src/Discord.Net.Rest/Net/ED25519/Sha512Internal.cs +++ b/src/Discord.Net.Rest/Net/ED25519/Sha512Internal.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace Discord.Net.ED25519 @@ -79,11 +79,11 @@ namespace Discord.Net.ED25519 {//0 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w0; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -98,11 +98,11 @@ namespace Discord.Net.ED25519 {//1 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w1; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -117,11 +117,11 @@ namespace Discord.Net.ED25519 {//2 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w2; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -136,11 +136,11 @@ namespace Discord.Net.ED25519 {//3 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w3; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -155,11 +155,11 @@ namespace Discord.Net.ED25519 {//4 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w4; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -174,11 +174,11 @@ namespace Discord.Net.ED25519 {//5 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w5; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -193,11 +193,11 @@ namespace Discord.Net.ED25519 {//6 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w6; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -212,11 +212,11 @@ namespace Discord.Net.ED25519 {//7 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w7; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -231,11 +231,11 @@ namespace Discord.Net.ED25519 {//8 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w8; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -250,11 +250,11 @@ namespace Discord.Net.ED25519 {//9 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w9; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -269,11 +269,11 @@ namespace Discord.Net.ED25519 {//10 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w10; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -288,11 +288,11 @@ namespace Discord.Net.ED25519 {//11 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w11; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -307,11 +307,11 @@ namespace Discord.Net.ED25519 {//12 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w12; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -326,11 +326,11 @@ namespace Discord.Net.ED25519 {//13 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w13; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -345,11 +345,11 @@ namespace Discord.Net.ED25519 {//14 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w14; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; @@ -364,11 +364,11 @@ namespace Discord.Net.ED25519 {//15 t1 = h + ((e >> 14) ^ (e << (64 - 14)) ^ (e >> 18) ^ (e << (64 - 18)) ^ (e >> 41) ^ (e << (64 - 41))) + - //Sigma1(e) + //Sigma1(e) ((e & f) ^ (~e & g)) + //Ch(e,f,g) K[t] + w15; t2 = ((a >> 28) ^ (a << (64 - 28)) ^ (a >> 34) ^ (a << (64 - 34)) ^ (a >> 39) ^ (a << (64 - 39))) + - //Sigma0(a) + //Sigma0(a) ((a & b) ^ (a & c) ^ (b & c)); //Maj(a,b,c) h = g; g = f; diff --git a/src/Discord.Net.Rest/Net/Queue/ClientBucket.cs b/src/Discord.Net.Rest/Net/Queue/ClientBucket.cs index e726a08c..61a80286 100644 --- a/src/Discord.Net.Rest/Net/Queue/ClientBucket.cs +++ b/src/Discord.Net.Rest/Net/Queue/ClientBucket.cs @@ -33,7 +33,7 @@ namespace Discord.Net.Queue public static ClientBucket Get(ClientBucketType type) => DefsByType[type]; public static ClientBucket Get(BucketId id) => DefsById[id]; - + public ClientBucketType Type { get; } public BucketId Id { get; } public int WindowCount { get; } diff --git a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs index c596f112..978a97ca 100644 --- a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs +++ b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs @@ -87,7 +87,7 @@ namespace Discord.Net.Queue #if DEBUG_LIMITS Debug.WriteLine($"[{id}] (!) 429"); #endif - UpdateRateLimit(id, request, info, true, body:response.Stream); + UpdateRateLimit(id, request, info, true, body: response.Stream); } await _queue.RaiseRateLimitTriggered(Id, info, $"{request.Method} {request.Endpoint}").ConfigureAwait(false); continue; //Retry diff --git a/src/Discord.Net.Rest/Net/Queue/Requests/JsonRestRequest.cs b/src/Discord.Net.Rest/Net/Queue/Requests/JsonRestRequest.cs index 2949bab3..d0a44903 100644 --- a/src/Discord.Net.Rest/Net/Queue/Requests/JsonRestRequest.cs +++ b/src/Discord.Net.Rest/Net/Queue/Requests/JsonRestRequest.cs @@ -1,4 +1,4 @@ -using Discord.Net.Rest; +using Discord.Net.Rest; using System.Threading.Tasks; namespace Discord.Net.Queue diff --git a/src/Discord.Net.Rest/Net/Queue/Requests/MultipartRestRequest.cs b/src/Discord.Net.Rest/Net/Queue/Requests/MultipartRestRequest.cs index c8d97bbd..09d558f1 100644 --- a/src/Discord.Net.Rest/Net/Queue/Requests/MultipartRestRequest.cs +++ b/src/Discord.Net.Rest/Net/Queue/Requests/MultipartRestRequest.cs @@ -1,4 +1,4 @@ -using Discord.Net.Rest; +using Discord.Net.Rest; using System.Collections.Generic; using System.Threading.Tasks; @@ -7,7 +7,7 @@ namespace Discord.Net.Queue public class MultipartRestRequest : RestRequest { public IReadOnlyDictionary MultipartParams { get; } - + public MultipartRestRequest(IRestClient client, string method, string endpoint, IReadOnlyDictionary multipartParams, RequestOptions options) : base(client, method, endpoint, options) { diff --git a/src/Discord.Net.Rest/Net/RateLimitInfo.cs b/src/Discord.Net.Rest/Net/RateLimitInfo.cs index 9d0b9a42..42b97661 100644 --- a/src/Discord.Net.Rest/Net/RateLimitInfo.cs +++ b/src/Discord.Net.Rest/Net/RateLimitInfo.cs @@ -46,15 +46,15 @@ namespace Discord.Net IsGlobal = headers.TryGetValue("X-RateLimit-Global", out string temp) && bool.TryParse(temp, out var isGlobal) && isGlobal; - Limit = headers.TryGetValue("X-RateLimit-Limit", out temp) && + Limit = headers.TryGetValue("X-RateLimit-Limit", out temp) && int.TryParse(temp, NumberStyles.None, CultureInfo.InvariantCulture, out var limit) ? limit : (int?)null; - Remaining = headers.TryGetValue("X-RateLimit-Remaining", out temp) && + Remaining = headers.TryGetValue("X-RateLimit-Remaining", out temp) && int.TryParse(temp, NumberStyles.None, CultureInfo.InvariantCulture, out var remaining) ? remaining : (int?)null; - Reset = headers.TryGetValue("X-RateLimit-Reset", out temp) && + Reset = headers.TryGetValue("X-RateLimit-Reset", out temp) && double.TryParse(temp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var reset) ? DateTimeOffset.FromUnixTimeMilliseconds((long)(reset * 1000)) : (DateTimeOffset?)null; RetryAfter = headers.TryGetValue("Retry-After", out temp) && int.TryParse(temp, NumberStyles.None, CultureInfo.InvariantCulture, out var retryAfter) ? retryAfter : (int?)null; - ResetAfter = headers.TryGetValue("X-RateLimit-Reset-After", out temp) && + ResetAfter = headers.TryGetValue("X-RateLimit-Reset-After", out temp) && double.TryParse(temp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var resetAfter) ? TimeSpan.FromSeconds(resetAfter) : (TimeSpan?)null; Bucket = headers.TryGetValue("X-RateLimit-Bucket", out temp) ? temp : null; Lag = headers.TryGetValue("Date", out temp) && diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs index bb6a3962..f8988494 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs @@ -4,7 +4,7 @@ namespace Discord.API.Gateway { internal class GuildRoleUpdateEvent { - [JsonProperty("guild_id")] + [JsonProperty("guild_id")] public ulong GuildId { get; set; } [JsonProperty("role")] public Role Role { get; set; } diff --git a/src/Discord.Net.WebSocket/API/Gateway/RemoveAllReactionsEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/RemoveAllReactionsEvent.cs index 4833c512..582dbd68 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/RemoveAllReactionsEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/RemoveAllReactionsEvent.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Discord.API.Gateway { diff --git a/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs index 870ae736..1225cd3b 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs @@ -2,8 +2,8 @@ using Newtonsoft.Json; namespace Discord.API.Gateway { - internal class ResumedEvent - { + internal class ResumedEvent + { [JsonProperty("heartbeat_interval")] public int HeartbeatInterval { get; set; } } diff --git a/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs index 8df3f010..bd3db17b 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs @@ -3,12 +3,12 @@ using Newtonsoft.Json; namespace Discord.API.Gateway { internal class VoiceServerUpdateEvent - { - [JsonProperty("guild_id")] - public ulong GuildId { get; set; } + { + [JsonProperty("guild_id")] + public ulong GuildId { get; set; } [JsonProperty("endpoint")] - public string Endpoint { get; set; } + public string Endpoint { get; set; } [JsonProperty("token")] - public string Token { get; set; } + public string Token { get; set; } } } diff --git a/src/Discord.Net.WebSocket/Audio/AudioClient.cs b/src/Discord.Net.WebSocket/Audio/AudioClient.cs index 78780577..6b44a1be 100644 --- a/src/Discord.Net.WebSocket/Audio/AudioClient.cs +++ b/src/Discord.Net.WebSocket/Audio/AudioClient.cs @@ -7,11 +7,11 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Collections.Generic; namespace Discord.Audio { @@ -137,7 +137,8 @@ namespace Discord.Audio await keepaliveTask.ConfigureAwait(false); _keepaliveTask = null; - while (_heartbeatTimes.TryDequeue(out _)) { } + while (_heartbeatTimes.TryDequeue(out _)) + { } _lastMessageTime = 0; await ClearInputStreamsAsync().ConfigureAwait(false); @@ -149,7 +150,7 @@ namespace Discord.Audio public AudioOutStream CreateOpusStream(int bufferMillis) { var outputStream = new OutputStream(ApiClient); //Ignores header - var sodiumEncrypter = new SodiumEncryptStream( outputStream, this); //Passes header + var sodiumEncrypter = new SodiumEncryptStream(outputStream, this); //Passes header var rtpWriter = new RTPWriteStream(sodiumEncrypter, _ssrc); //Consumes header, passes return new BufferedWriteStream(rtpWriter, this, bufferMillis, _connection.CancelToken, _audioLogger); //Generates header } diff --git a/src/Discord.Net.WebSocket/Audio/Opus/OpusApplication.cs b/src/Discord.Net.WebSocket/Audio/Opus/OpusApplication.cs index e288bb62..68f9d412 100644 --- a/src/Discord.Net.WebSocket/Audio/Opus/OpusApplication.cs +++ b/src/Discord.Net.WebSocket/Audio/Opus/OpusApplication.cs @@ -1,4 +1,4 @@ -namespace Discord.Audio +namespace Discord.Audio { internal enum OpusApplication : int { diff --git a/src/Discord.Net.WebSocket/Audio/Opus/OpusConverter.cs b/src/Discord.Net.WebSocket/Audio/Opus/OpusConverter.cs index 4179ce9c..c8a164fb 100644 --- a/src/Discord.Net.WebSocket/Audio/Opus/OpusConverter.cs +++ b/src/Discord.Net.WebSocket/Audio/Opus/OpusConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Discord.Audio { @@ -15,7 +15,7 @@ namespace Discord.Audio public const int FrameSamplesPerChannel = SamplingRate / 1000 * FrameMillis; public const int FrameSamples = FrameSamplesPerChannel * Channels; public const int FrameBytes = FrameSamplesPerChannel * SampleBytes; - + protected bool _isDisposed = false; protected virtual void Dispose(bool disposing) @@ -32,7 +32,7 @@ namespace Discord.Audio Dispose(true); GC.SuppressFinalize(this); } - + protected static void CheckError(int result) { if (result < 0) diff --git a/src/Discord.Net.WebSocket/Audio/Opus/OpusCtl.cs b/src/Discord.Net.WebSocket/Audio/Opus/OpusCtl.cs index 0b6a4e37..73e06c4d 100644 --- a/src/Discord.Net.WebSocket/Audio/Opus/OpusCtl.cs +++ b/src/Discord.Net.WebSocket/Audio/Opus/OpusCtl.cs @@ -1,4 +1,4 @@ -namespace Discord.Audio +namespace Discord.Audio { //https://github.com/gcp/opus/blob/master/include/opus_defines.h internal enum OpusCtl : int diff --git a/src/Discord.Net.WebSocket/Audio/Opus/OpusDecoder.cs b/src/Discord.Net.WebSocket/Audio/Opus/OpusDecoder.cs index 41c48e1a..9423003e 100644 --- a/src/Discord.Net.WebSocket/Audio/Opus/OpusDecoder.cs +++ b/src/Discord.Net.WebSocket/Audio/Opus/OpusDecoder.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; namespace Discord.Audio @@ -19,7 +19,7 @@ namespace Discord.Audio _ptr = CreateDecoder(SamplingRate, Channels, out var error); CheckError(error); } - + public unsafe int DecodeFrame(byte[] input, int inputOffset, int inputCount, byte[] output, int outputOffset, bool decodeFEC) { int result = 0; diff --git a/src/Discord.Net.WebSocket/Audio/Opus/OpusEncoder.cs b/src/Discord.Net.WebSocket/Audio/Opus/OpusEncoder.cs index 1ff5a5d9..72639471 100644 --- a/src/Discord.Net.WebSocket/Audio/Opus/OpusEncoder.cs +++ b/src/Discord.Net.WebSocket/Audio/Opus/OpusEncoder.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; namespace Discord.Audio @@ -13,9 +13,9 @@ namespace Discord.Audio private static extern int Encode(IntPtr st, byte* pcm, int frame_size, byte* data, int max_data_bytes); [DllImport("opus", EntryPoint = "opus_encoder_ctl", CallingConvention = CallingConvention.Cdecl)] private static extern OpusError EncoderCtl(IntPtr st, OpusCtl request, int value); - + public AudioApplication Application { get; } - public int BitRate { get;} + public int BitRate { get; } public OpusEncoder(int bitrate, AudioApplication application, int packetLoss) { diff --git a/src/Discord.Net.WebSocket/Audio/Opus/OpusError.cs b/src/Discord.Net.WebSocket/Audio/Opus/OpusError.cs index d29d8b9d..20ff26dc 100644 --- a/src/Discord.Net.WebSocket/Audio/Opus/OpusError.cs +++ b/src/Discord.Net.WebSocket/Audio/Opus/OpusError.cs @@ -1,4 +1,4 @@ -namespace Discord.Audio +namespace Discord.Audio { internal enum OpusError : int { diff --git a/src/Discord.Net.WebSocket/Audio/Sodium/SecretBox.cs b/src/Discord.Net.WebSocket/Audio/Sodium/SecretBox.cs index 4187c9f0..5ace823c 100644 --- a/src/Discord.Net.WebSocket/Audio/Sodium/SecretBox.cs +++ b/src/Discord.Net.WebSocket/Audio/Sodium/SecretBox.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; namespace Discord.Audio diff --git a/src/Discord.Net.WebSocket/Audio/Streams/JitterBuffer.cs b/src/Discord.Net.WebSocket/Audio/Streams/JitterBuffer.cs index 10f842a9..5d7bb090 100644 --- a/src/Discord.Net.WebSocket/Audio/Streams/JitterBuffer.cs +++ b/src/Discord.Net.WebSocket/Audio/Streams/JitterBuffer.cs @@ -243,4 +243,4 @@ namespace Discord.Audio.Streams return Task.Delay(0); } } -}*/ \ No newline at end of file +}*/ diff --git a/src/Discord.Net.WebSocket/Audio/Streams/OpusDecodeStream.cs b/src/Discord.Net.WebSocket/Audio/Streams/OpusDecodeStream.cs index ad1c285e..0d2b220e 100644 --- a/src/Discord.Net.WebSocket/Audio/Streams/OpusDecodeStream.cs +++ b/src/Discord.Net.WebSocket/Audio/Streams/OpusDecodeStream.cs @@ -26,7 +26,7 @@ namespace Discord.Audio.Streams public override void WriteHeader(ushort seq, uint timestamp, bool missed) { if (_hasHeader) - throw new InvalidOperationException("Header received with no payload."); + throw new InvalidOperationException("Header received with no payload."); _hasHeader = true; _nextMissed = missed; diff --git a/src/Discord.Net.WebSocket/Audio/Streams/OpusEncodeStream.cs b/src/Discord.Net.WebSocket/Audio/Streams/OpusEncodeStream.cs index 05d12b49..7e30b47e 100644 --- a/src/Discord.Net.WebSocket/Audio/Streams/OpusEncodeStream.cs +++ b/src/Discord.Net.WebSocket/Audio/Streams/OpusEncodeStream.cs @@ -15,7 +15,7 @@ namespace Discord.Audio.Streams private int _partialFramePos; private ushort _seq; private uint _timestamp; - + public OpusEncodeStream(AudioStream next, int bitrate, AudioApplication application, int packetLoss) { _next = next; diff --git a/src/Discord.Net.WebSocket/Audio/Streams/OutputStream.cs b/src/Discord.Net.WebSocket/Audio/Streams/OutputStream.cs index cba4e3cb..b5ba7541 100644 --- a/src/Discord.Net.WebSocket/Audio/Streams/OutputStream.cs +++ b/src/Discord.Net.WebSocket/Audio/Streams/OutputStream.cs @@ -13,7 +13,7 @@ namespace Discord.Audio.Streams { _client = client; } - + public override void WriteHeader(ushort seq, uint timestamp, bool missed) { } //Ignore public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancelToken) { @@ -21,4 +21,4 @@ namespace Discord.Audio.Streams await _client.SendAsync(buffer, offset, count).ConfigureAwait(false); } } -} \ No newline at end of file +} diff --git a/src/Discord.Net.WebSocket/Audio/Streams/RTPReadStream.cs b/src/Discord.Net.WebSocket/Audio/Streams/RTPReadStream.cs index 1002502b..40925b13 100644 --- a/src/Discord.Net.WebSocket/Audio/Streams/RTPReadStream.cs +++ b/src/Discord.Net.WebSocket/Audio/Streams/RTPReadStream.cs @@ -29,7 +29,7 @@ namespace Discord.Audio.Streams int headerSize = GetHeaderSize(buffer, offset); - ushort seq = (ushort)((buffer[offset + 2] << 8) | + ushort seq = (ushort)((buffer[offset + 2] << 8) | (buffer[offset + 3] << 0)); uint timestamp = (uint)((buffer[offset + 4] << 24) | @@ -46,7 +46,7 @@ namespace Discord.Audio.Streams ssrc = 0; if (buffer.Length - offset < 12) return false; - + int version = (buffer[offset + 0] & 0b1100_0000) >> 6; if (version != 2) return false; @@ -71,8 +71,8 @@ namespace Discord.Audio.Streams return 12 + csics * 4; int extensionOffset = offset + 12 + (csics * 4); - int extensionLength = - (buffer[extensionOffset + 2] << 8) | + int extensionLength = + (buffer[extensionOffset + 2] << 8) | (buffer[extensionOffset + 3]); return extensionOffset + 4 + (extensionLength * 4); } diff --git a/src/Discord.Net.WebSocket/Audio/Streams/RTPWriteStream.cs b/src/Discord.Net.WebSocket/Audio/Streams/RTPWriteStream.cs index 7ecb56be..48215f5e 100644 --- a/src/Discord.Net.WebSocket/Audio/Streams/RTPWriteStream.cs +++ b/src/Discord.Net.WebSocket/Audio/Streams/RTPWriteStream.cs @@ -33,7 +33,7 @@ namespace Discord.Audio.Streams { if (_hasHeader) throw new InvalidOperationException("Header received with no payload"); - + _hasHeader = true; _nextSeq = seq; _nextTimestamp = timestamp; diff --git a/src/Discord.Net.WebSocket/Audio/Streams/SodiumEncryptStream.cs b/src/Discord.Net.WebSocket/Audio/Streams/SodiumEncryptStream.cs index fa1d34de..268dfcb4 100644 --- a/src/Discord.Net.WebSocket/Audio/Streams/SodiumEncryptStream.cs +++ b/src/Discord.Net.WebSocket/Audio/Streams/SodiumEncryptStream.cs @@ -45,7 +45,7 @@ namespace Discord.Audio.Streams if (_client.SecretKey == null) return; - + Buffer.BlockCopy(buffer, offset, _nonce, 0, 12); //Copy nonce from RTP header count = SecretBox.Encrypt(buffer, offset + 12, count - 12, buffer, 12, _nonce, _client.SecretKey); _next.WriteHeader(_nextSeq, _nextTimestamp, false); diff --git a/src/Discord.Net.WebSocket/BaseSocketClient.cs b/src/Discord.Net.WebSocket/BaseSocketClient.cs index bb2d489b..64c402e3 100644 --- a/src/Discord.Net.WebSocket/BaseSocketClient.cs +++ b/src/Discord.Net.WebSocket/BaseSocketClient.cs @@ -1,9 +1,9 @@ +using Discord.API; +using Discord.Rest; using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -using Discord.API; -using Discord.Rest; namespace Discord.WebSocket { @@ -283,7 +283,7 @@ namespace Discord.WebSocket /// A if found, otherwise . /// public abstract Task GetStickerAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); -#endregion + #endregion #region IDiscordClient /// diff --git a/src/Discord.Net.WebSocket/Commands/ShardedCommandContext.cs b/src/Discord.Net.WebSocket/Commands/ShardedCommandContext.cs index 905cd01a..0ee0cf4f 100644 --- a/src/Discord.Net.WebSocket/Commands/ShardedCommandContext.cs +++ b/src/Discord.Net.WebSocket/Commands/ShardedCommandContext.cs @@ -18,7 +18,7 @@ namespace Discord.Commands /// Gets the shard ID of the command context. private static int GetShardId(DiscordShardedClient client, IGuild guild) => guild == null ? 0 : client.GetShardIdFor(guild); -#endregion + #endregion #region ICommandContext /// diff --git a/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs b/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs index d7180873..e57e5ef8 100644 --- a/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs +++ b/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs @@ -47,7 +47,7 @@ namespace Discord.Commands User = msg.Author; Message = msg; } -#endregion + #endregion #region ICommandContext /// diff --git a/src/Discord.Net.WebSocket/ConnectionManager.cs b/src/Discord.Net.WebSocket/ConnectionManager.cs index ec5eb93e..31d85755 100644 --- a/src/Discord.Net.WebSocket/ConnectionManager.cs +++ b/src/Discord.Net.WebSocket/ConnectionManager.cs @@ -1,8 +1,8 @@ using Discord.Logging; +using Discord.Net; using System; using System.Threading; using System.Threading.Tasks; -using Discord.Net; namespace Discord { @@ -164,7 +164,8 @@ namespace Discord } private async Task DisconnectAsync(Exception ex, bool isReconnecting) { - if (State == ConnectionState.Disconnected) return; + if (State == ConnectionState.Disconnected) + return; State = ConnectionState.Disconnecting; await _logger.InfoAsync("Disconnecting").ConfigureAwait(false); diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.Events.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.Events.cs index 50230572..f01e929b 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.Events.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.Events.cs @@ -7,28 +7,28 @@ namespace Discord.WebSocket { #region General /// Fired when a shard is connected to the Discord gateway. - public event Func ShardConnected + public event Func ShardConnected { add { _shardConnectedEvent.Add(value); } remove { _shardConnectedEvent.Remove(value); } } private readonly AsyncEvent> _shardConnectedEvent = new AsyncEvent>(); /// Fired when a shard is disconnected from the Discord gateway. - public event Func ShardDisconnected + public event Func ShardDisconnected { add { _shardDisconnectedEvent.Add(value); } remove { _shardDisconnectedEvent.Remove(value); } } private readonly AsyncEvent> _shardDisconnectedEvent = new AsyncEvent>(); /// Fired when a guild data for a shard has finished downloading. - public event Func ShardReady + public event Func ShardReady { add { _shardReadyEvent.Add(value); } remove { _shardReadyEvent.Remove(value); } } private readonly AsyncEvent> _shardReadyEvent = new AsyncEvent>(); /// Fired when a shard receives a heartbeat from the Discord gateway. - public event Func ShardLatencyUpdated + public event Func ShardLatencyUpdated { add { _shardLatencyUpdatedEvent.Add(value); } remove { _shardLatencyUpdatedEvent.Remove(value); } diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs index dcee3673..45958c0a 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs @@ -2,11 +2,11 @@ using Discord.API; using Discord.Rest; using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.IO; using System.Linq; -using System.Threading.Tasks; using System.Threading; -using System.Collections.Immutable; +using System.Threading.Tasks; namespace Discord.WebSocket { @@ -170,7 +170,7 @@ namespace Discord.WebSocket await _shards[i].LoginAsync(tokenType, token); } - if(_defaultStickers.Length == 0 && _baseConfig.AlwaysDownloadDefaultStickers) + if (_defaultStickers.Length == 0 && _baseConfig.AlwaysDownloadDefaultStickers) await DownloadDefaultStickersAsync().ConfigureAwait(false); } @@ -370,7 +370,8 @@ namespace Discord.WebSocket /// is public override async Task DownloadUsersAsync(IEnumerable guilds) { - if (guilds == null) throw new ArgumentNullException(nameof(guilds)); + if (guilds == null) + throw new ArgumentNullException(nameof(guilds)); for (int i = 0; i < _shards.Length; i++) { int id = _shardIds[i]; diff --git a/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs b/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs index 465c47a1..75960b17 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs @@ -66,7 +66,7 @@ namespace Discord.API public DiscordSocketApiClient(RestClientProvider restClientProvider, WebSocketProvider webSocketProvider, string userAgent, string url = null, RetryMode defaultRetryMode = RetryMode.AlwaysRetry, JsonSerializer serializer = null, - bool useSystemClock = true, Func defaultRatelimitCallback = null) + bool useSystemClock = true, Func defaultRatelimitCallback = null) : base(restClientProvider, userAgent, defaultRetryMode, serializer, useSystemClock, defaultRatelimitCallback) { _gatewayUrl = url; @@ -275,10 +275,12 @@ namespace Discord.API if (WebSocketClient == null) throw new NotSupportedException("This client is not configured with WebSocket support."); - if (ConnectionState == ConnectionState.Disconnected) return; + if (ConnectionState == ConnectionState.Disconnected) + return; ConnectionState = ConnectionState.Disconnecting; - try { _connectCancelToken?.Cancel(false); } + try + { _connectCancelToken?.Cancel(false); } catch { } if (ex is GatewayReconnectException) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.Events.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.Events.cs index ab13d93d..68a72428 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.Events.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.Events.cs @@ -1,6 +1,6 @@ +using Discord.API; using System; using System.Threading.Tasks; -using Discord.API; namespace Discord.WebSocket { diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index cb982889..9a0f67b0 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -333,7 +333,8 @@ namespace Discord.WebSocket await heartbeatTask.ConfigureAwait(false); _heartbeatTask = null; - while (_heartbeatTimes.TryDequeue(out _)) { } + while (_heartbeatTimes.TryDequeue(out _)) + { } _lastMessageTime = 0; await _gatewayLogger.DebugAsync("Waiting for guild downloader").ConfigureAwait(false); @@ -344,7 +345,8 @@ namespace Discord.WebSocket //Clear large guild queue await _gatewayLogger.DebugAsync("Clearing large guild queue").ConfigureAwait(false); - while (_largeGuilds.TryDequeue(out _)) { } + while (_largeGuilds.TryDequeue(out _)) + { } //Raise virtual GUILD_UNAVAILABLEs await _gatewayLogger.DebugAsync("Raising virtual GuildUnavailables").ConfigureAwait(false); @@ -461,7 +463,7 @@ namespace Discord.WebSocket { var commands = (await ApiClient.GetGlobalApplicationCommandsAsync(withLocalizations, locale, options)).Select(x => SocketApplicationCommand.Create(this, x)); - foreach(var command in commands) + foreach (var command in commands) { State.AddCommand(command); } @@ -490,7 +492,7 @@ namespace Discord.WebSocket //Purge our previous commands State.PurgeCommands(x => x.IsGlobalCommand); - foreach(var entity in entities) + foreach (var entity in entities) { State.AddCommand(entity); } @@ -531,7 +533,7 @@ namespace Discord.WebSocket if (sticker != null) return sticker; - foreach(var guild in Guilds) + foreach (var guild in Guilds) { sticker = await guild.GetStickerAsync(id, CacheMode.CacheOnly).ConfigureAwait(false); @@ -544,7 +546,7 @@ namespace Discord.WebSocket var model = await ApiClient.GetStickerAsync(id, options).ConfigureAwait(false); - if(model == null) + if (model == null) return null; @@ -750,7 +752,7 @@ namespace Discord.WebSocket await _gatewayLogger.WarningAsync("You're using the GuildPresences intent without listening to the PresenceUpdate event, consider removing the intent from your config.").ConfigureAwait(false); } - if(!_gatewayIntents.HasFlag(GatewayIntents.GuildPresences) && + if (!_gatewayIntents.HasFlag(GatewayIntents.GuildPresences) && ((_shardedClient is null && _presenceUpdated.HasSubscribers) || (_shardedClient is not null && _shardedClient._presenceUpdated.HasSubscribers))) { @@ -767,7 +769,7 @@ namespace Discord.WebSocket _guildScheduledEventUserAdd.HasSubscribers; bool shardedClientHasGuildScheduledEventsSubscribers = - _shardedClient is not null && + _shardedClient is not null && (_shardedClient._guildScheduledEventCancelled.HasSubscribers || _shardedClient._guildScheduledEventUserRemove.HasSubscribers || _shardedClient._guildScheduledEventCompleted.HasSubscribers || @@ -783,7 +785,7 @@ namespace Discord.WebSocket await _gatewayLogger.WarningAsync("You're using the GuildScheduledEvents gateway intent without listening to any events related to that intent, consider removing the intent from your config.").ConfigureAwait(false); } - if(!_gatewayIntents.HasFlag(GatewayIntents.GuildScheduledEvents) && + if (!_gatewayIntents.HasFlag(GatewayIntents.GuildScheduledEvents) && ((_shardedClient is null && hasGuildScheduledEventsSubscribers) || (_shardedClient is not null && shardedClientHasGuildScheduledEventsSubscribers))) { @@ -2238,12 +2240,12 @@ namespace Discord.WebSocket await TimedInvokeAsync(_requestToSpeak, nameof(RequestToSpeak), stage, guildUser); return; } - if(before.IsSuppressed && !after.IsSuppressed) + if (before.IsSuppressed && !after.IsSuppressed) { await TimedInvokeAsync(_speakerAdded, nameof(SpeakerAdded), stage, guildUser); return; } - if(!before.IsSuppressed && after.IsSuppressed) + if (!before.IsSuppressed && after.IsSuppressed) { await TimedInvokeAsync(_speakerRemoved, nameof(SpeakerRemoved), stage, guildUser); } @@ -2349,7 +2351,7 @@ namespace Discord.WebSocket case "INTERACTION_CREATE": { await _gatewayLogger.DebugAsync("Received Dispatch (INTERACTION_CREATE)").ConfigureAwait(false); - + var data = (payload as JToken).ToObject(_serializer); var guild = data.GuildId.IsSpecified ? GetGuild(data.GuildId.Value) : null; @@ -2366,7 +2368,7 @@ namespace Discord.WebSocket : State.GetOrAddUser(data.Member.Value.User.Id, (_) => SocketGlobalUser.Create(this, State, data.Member.Value.User)); SocketChannel channel = null; - if(data.ChannelId.IsSpecified) + if (data.ChannelId.IsSpecified) { channel = State.GetChannel(data.ChannelId.Value); @@ -2507,7 +2509,7 @@ namespace Discord.WebSocket { threadChannel.Update(State, data); - if(data.ThreadMember.IsSpecified) + if (data.ThreadMember.IsSpecified) threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); } else @@ -2570,7 +2572,7 @@ namespace Discord.WebSocket var guild = State.GetGuild(data.GuildId.Value); - if(guild == null) + if (guild == null) { await UnknownGuildAsync(type, data.GuildId.Value).ConfigureAwait(false); return; @@ -2591,17 +2593,17 @@ namespace Discord.WebSocket var guild = State.GetGuild(data.GuildId); - if(guild == null) + if (guild == null) { await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false); return; } - foreach(var thread in data.Threads) + foreach (var thread in data.Threads) { var entity = guild.ThreadChannels.FirstOrDefault(x => x.Id == thread.Id); - if(entity == null) + if (entity == null) { entity = (SocketThreadChannel)guild.AddChannel(State, thread); } @@ -2610,7 +2612,7 @@ namespace Discord.WebSocket entity.Update(State, thread); } - foreach(var member in data.Members.Where(x => x.Id.Value == entity.Id)) + foreach (var member in data.Members.Where(x => x.Id.Value == entity.Id)) { var guildMember = guild.GetUser(member.Id.Value); @@ -2653,7 +2655,7 @@ namespace Discord.WebSocket var thread = (SocketThreadChannel)guild.GetChannel(data.Id); - if(thread == null) + if (thread == null) { await UnknownChannelAsync(type, data.Id); return; @@ -2671,13 +2673,13 @@ namespace Discord.WebSocket if (data.AddedMembers.IsSpecified) { List newThreadMembers = new List(); - foreach(var threadMember in data.AddedMembers.Value) + foreach (var threadMember in data.AddedMembers.Value) { SocketGuildUser guildMember; guildMember = guild.GetUser(threadMember.UserId.Value); - if(guildMember == null) + if (guildMember == null) { await UnknownGuildUserAsync("THREAD_MEMBERS_UPDATE", threadMember.UserId.Value, guild.Id); } @@ -2691,15 +2693,15 @@ namespace Discord.WebSocket if (leftUsers != null) { - foreach(var threadUser in leftUsers) + foreach (var threadUser in leftUsers) { await TimedInvokeAsync(_threadMemberLeft, nameof(ThreadMemberLeft), threadUser).ConfigureAwait(false); } } - if(joinUsers != null) + if (joinUsers != null) { - foreach(var threadUser in joinUsers) + foreach (var threadUser in joinUsers) { await TimedInvokeAsync(_threadMemberJoined, nameof(ThreadMemberJoined), threadUser).ConfigureAwait(false); } @@ -2718,7 +2720,7 @@ namespace Discord.WebSocket var guild = State.GetGuild(data.GuildId); - if(guild == null) + if (guild == null) { await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false); return; @@ -2726,7 +2728,7 @@ namespace Discord.WebSocket var stageChannel = guild.GetStageChannel(data.ChannelId); - if(stageChannel == null) + if (stageChannel == null) { await UnknownChannelAsync(type, data.ChannelId).ConfigureAwait(false); return; @@ -2792,15 +2794,16 @@ namespace Discord.WebSocket var after = guild.AddOrUpdateEvent(data); - if((before != null ? before.Status != GuildScheduledEventStatus.Completed : true) && data.Status == GuildScheduledEventStatus.Completed) + if ((before != null ? before.Status != GuildScheduledEventStatus.Completed : true) && data.Status == GuildScheduledEventStatus.Completed) { await TimedInvokeAsync(_guildScheduledEventCompleted, nameof(GuildScheduledEventCompleted), after).ConfigureAwait(false); } - else if((before != null ? before.Status != GuildScheduledEventStatus.Active : false) && data.Status == GuildScheduledEventStatus.Active) + else if ((before != null ? before.Status != GuildScheduledEventStatus.Active : false) && data.Status == GuildScheduledEventStatus.Active) { await TimedInvokeAsync(_guildScheduledEventStarted, nameof(GuildScheduledEventStarted), after).ConfigureAwait(false); } - else await TimedInvokeAsync(_guildScheduledEventUpdated, nameof(GuildScheduledEventUpdated), beforeCacheable, after).ConfigureAwait(false); + else + await TimedInvokeAsync(_guildScheduledEventUpdated, nameof(GuildScheduledEventUpdated), beforeCacheable, after).ConfigureAwait(false); } break; case "GUILD_SCHEDULED_EVENT_DELETE": @@ -2830,7 +2833,7 @@ namespace Discord.WebSocket var guild = State.GetGuild(data.GuildId); - if(guild == null) + if (guild == null) { await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false); return; @@ -2902,7 +2905,8 @@ namespace Discord.WebSocket #region Others default: - if(!SuppressUnknownDispatchWarnings) await _gatewayLogger.WarningAsync($"Unknown Dispatch ({type})").ConfigureAwait(false); + if (!SuppressUnknownDispatchWarnings) + await _gatewayLogger.WarningAsync($"Unknown Dispatch ({type})").ConfigureAwait(false); break; #endregion } diff --git a/src/Discord.Net.WebSocket/DiscordSocketRestClient.cs b/src/Discord.Net.WebSocket/DiscordSocketRestClient.cs index 5107629a..0fc870d1 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketRestClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketRestClient.cs @@ -1,6 +1,6 @@ +using Discord.Rest; using System; using System.Threading.Tasks; -using Discord.Rest; namespace Discord.WebSocket { diff --git a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs index ea4249cf..3e5f5664 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs @@ -19,20 +19,20 @@ namespace Discord.WebSocket IReadOnlyCollection CachedMessages { get; } /// - new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, + new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None); - + /// - new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, - RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, + RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None); - + /// - new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, - Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, + Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None); /// diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs index 42f0c76d..e0de685a 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs @@ -1,10 +1,10 @@ +using Discord.Rest; using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -using Discord.Rest; using Model = Discord.API.Channel; namespace Discord.WebSocket diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs index ccbf9b2b..c977993d 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs @@ -68,11 +68,20 @@ namespace Discord.WebSocket { switch (channel) { - case SocketDMChannel dmChannel: dmChannel.AddMessage(msg); break; - case SocketGroupChannel groupChannel: groupChannel.AddMessage(msg); break; - case SocketThreadChannel threadChannel: threadChannel.AddMessage(msg); break; - case SocketTextChannel textChannel: textChannel.AddMessage(msg); break; - default: throw new NotSupportedException($"Unexpected {nameof(ISocketMessageChannel)} type."); + case SocketDMChannel dmChannel: + dmChannel.AddMessage(msg); + break; + case SocketGroupChannel groupChannel: + groupChannel.AddMessage(msg); + break; + case SocketThreadChannel threadChannel: + threadChannel.AddMessage(msg); + break; + case SocketTextChannel textChannel: + textChannel.AddMessage(msg); + break; + default: + throw new NotSupportedException($"Unexpected {nameof(ISocketMessageChannel)} type."); } } /// Unexpected type. diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs index 17ab4ebe..47e92626 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs @@ -140,16 +140,16 @@ namespace Discord.WebSocket /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, - RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, + RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// /// The only valid are and . - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, - RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, + RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, @@ -158,28 +158,28 @@ namespace Discord.WebSocket /// Message content is too long, length must be less or equal to . /// The only valid are and . public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, isSpoiler, embeds, flags); /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, + => ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// /// Message content is too long, length must be less or equal to . /// The only valid are and . - public Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, - Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, - MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, + public Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, + Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, + MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) - => ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, + => ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags); /// diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs index 4f068cf8..90dfafb0 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs @@ -90,7 +90,7 @@ namespace Discord.WebSocket { throw new NotSupportedException("Voice is not yet supported for group channels."); } -#endregion + #endregion #region Messages /// diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs index 0811f223..ee1f0c95 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs @@ -184,7 +184,7 @@ namespace Discord.WebSocket public override string ToString() => Name; private string DebuggerDisplay => $"{Name} ({Id}, Guild)"; internal new SocketGuildChannel Clone() => MemberwiseClone() as SocketGuildChannel; -#endregion + #endregion #region SocketChannel /// diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs index 85990150..415792de 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs @@ -19,7 +19,7 @@ namespace Discord.WebSocket public class SocketNewsChannel : SocketTextChannel, INewsChannel { internal SocketNewsChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) - :base(discord, id, guild) + : base(discord, id, guild) { } internal new static SocketNewsChannel Create(SocketGuild guild, ClientState state, Model model) diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index 8a1b6192..13f4e669 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -120,7 +120,7 @@ namespace Discord.WebSocket var thread = (SocketThreadChannel)Guild.AddOrUpdateChannel(Discord.State, model); - if(Discord.AlwaysDownloadUsers && Discord.HasGatewayIntent(GatewayIntents.GuildMembers)) + if (Discord.AlwaysDownloadUsers && Discord.HasGatewayIntent(GatewayIntents.GuildMembers)) await thread.DownloadUsersAsync(); return thread; @@ -461,7 +461,7 @@ namespace Discord.WebSocket AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false); - + #endregion #region INestedChannel diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs index baf3e752..b9077908 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs @@ -1,5 +1,6 @@ using Discord.Rest; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; @@ -8,7 +9,6 @@ using System.Linq; using System.Threading.Tasks; using Model = Discord.API.Channel; using ThreadMember = Discord.API.ThreadMember; -using System.Collections.Concurrent; namespace Discord.WebSocket { diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs index 511b16e8..2993feda 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs @@ -128,7 +128,7 @@ namespace Discord.WebSocket { if (!IsTextInVoice) throw new NotSupportedException("This function is only supported in Text-In-Voice channels"); - return base.DeleteMessageAsync(messageId, options); + return base.DeleteMessageAsync(messageId, options); } /// This function is only supported in Text-In-Voice channels. @@ -136,7 +136,7 @@ namespace Discord.WebSocket { if (!IsTextInVoice) throw new NotSupportedException("This function is only supported in Text-In-Voice channels"); - return base.DeleteMessagesAsync(messages, options); + return base.DeleteMessagesAsync(messages, options); } /// This function is only supported in Text-In-Voice channels. @@ -144,7 +144,7 @@ namespace Discord.WebSocket { if (!IsTextInVoice) throw new NotSupportedException("This function is only supported in Text-In-Voice channels"); - return base.DeleteMessagesAsync(messageIds, options); + return base.DeleteMessagesAsync(messageIds, options); } /// This function is only supported in Text-In-Voice channels. @@ -160,7 +160,7 @@ namespace Discord.WebSocket { if (!IsTextInVoice) throw new NotSupportedException("This function is only supported in Text-In-Voice channels"); - return base.GetCachedMessage(id); + return base.GetCachedMessage(id); } /// This function is only supported in Text-In-Voice channels. @@ -192,7 +192,7 @@ namespace Discord.WebSocket { if (!IsTextInVoice) throw new NotSupportedException("This function is only supported in Text-In-Voice channels"); - return base.GetMessagesAsync(fromMessage, dir, limit, options); + return base.GetMessagesAsync(fromMessage, dir, limit, options); } /// This function is only supported in Text-In-Voice channels. @@ -232,7 +232,7 @@ namespace Discord.WebSocket { if (!IsTextInVoice) throw new NotSupportedException("This function is only supported in Text-In-Voice channels"); - return base.GetWebhooksAsync(options); + return base.GetWebhooksAsync(options); } /// This function is only supported in Text-In-Voice channels. @@ -256,7 +256,7 @@ namespace Discord.WebSocket { if (!IsTextInVoice) throw new NotSupportedException("This function is only supported in Text-In-Voice channels"); - return base.SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags); + return base.SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags); } /// This function is only supported in Text-In-Voice channels. diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index f23804fb..94be8c90 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -7,22 +7,22 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Globalization; +using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using ChannelModel = Discord.API.Channel; using EmojiUpdateModel = Discord.API.Gateway.GuildEmojiUpdateEvent; +using EventModel = Discord.API.GuildScheduledEvent; using ExtendedModel = Discord.API.Gateway.ExtendedGuild; using GuildSyncModel = Discord.API.Gateway.GuildSyncEvent; using MemberModel = Discord.API.GuildMember; using Model = Discord.API.Guild; using PresenceModel = Discord.API.Presence; using RoleModel = Discord.API.Role; +using StickerModel = Discord.API.Sticker; using UserModel = Discord.API.User; using VoiceStateModel = Discord.API.VoiceState; -using StickerModel = Discord.API.Sticker; -using EventModel = Discord.API.GuildScheduledEvent; -using System.IO; namespace Discord.WebSocket { @@ -403,7 +403,7 @@ namespace Discord.WebSocket IsAvailable = !(model.Unavailable ?? false); if (!IsAvailable) { - if(_events == null) + if (_events == null) _events = new ConcurrentDictionary(); if (_channels == null) _channels = new ConcurrentDictionary(); @@ -431,7 +431,7 @@ namespace Discord.WebSocket channels.TryAdd(channel.Id, channel); } - for(int i = 0; i < model.Threads.Length; i++) + for (int i = 0; i < model.Threads.Length; i++) { var threadChannel = SocketThreadChannel.Create(this, state, model.Threads[i]); state.AddChannel(threadChannel); @@ -987,7 +987,7 @@ namespace Discord.WebSocket Discord.State.PurgeCommands(x => !x.IsGlobalCommand && x.Guild.Id == Id); - foreach(var entity in entities) + foreach (var entity in entities) { Discord.State.AddCommand(entity); } @@ -1195,7 +1195,7 @@ namespace Discord.WebSocket var membersToKeep = Users.Where(x => !predicate.Invoke(x) || x?.Id == Discord.CurrentUser.Id); foreach (var member in membersToPurge) - if(_members.TryRemove(member.Id, out _)) + if (_members.TryRemove(member.Id, out _)) member.GlobalUser.RemoveRef(Discord); foreach (var member in membersToKeep) @@ -1347,7 +1347,7 @@ namespace Discord.WebSocket { case GuildScheduledEventType.Stage: CurrentUser.GuildPermissions.Ensure(GuildPermission.ManageEvents | GuildPermission.ManageChannels | GuildPermission.MuteMembers | GuildPermission.MoveMembers); - break; + break; case GuildScheduledEventType.Voice: CurrentUser.GuildPermissions.Ensure(GuildPermission.ManageEvents | GuildPermission.ViewChannel | GuildPermission.Connect); break; @@ -2008,7 +2008,7 @@ namespace Discord.WebSocket async Task> IGuild.GetWebhooksAsync(RequestOptions options) => await GetWebhooksAsync(options).ConfigureAwait(false); /// - async Task> IGuild.GetApplicationCommandsAsync (bool withLocalizations, string locale, RequestOptions options) + async Task> IGuild.GetApplicationCommandsAsync(bool withLocalizations, string locale, RequestOptions options) => await GetApplicationCommandsAsync(withLocalizations, locale, options).ConfigureAwait(false); /// async Task IGuild.CreateStickerAsync(string name, string description, IEnumerable tags, Image image, RequestOptions options) diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs index a86aafad..2a17143f 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs @@ -86,9 +86,9 @@ namespace Discord.WebSocket { var guildUser = Guild.GetUser(model.CreatorId.Value); - if(guildUser != null) + if (guildUser != null) { - if(model.Creator.IsSpecified) + if (model.Creator.IsSpecified) guildUser.Update(Discord.State, model.Creator.Value); Creator = guildUser; diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs index 286629ce..830a2dc8 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs @@ -1,12 +1,12 @@ +using Discord.Net.Rest; +using Discord.Rest; using System; +using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; -using Model = Discord.API.Interaction; using DataModel = Discord.API.MessageComponentInteractionData; -using Discord.Rest; -using System.Collections.Generic; -using Discord.Net.Rest; -using System.IO; +using Model = Discord.API.Interaction; namespace Discord.WebSocket { diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs index 0099ec77..b193b77f 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs @@ -1,9 +1,9 @@ using Discord.Rest; using Discord.Utils; using System; -using System.Linq; using System.Collections.Generic; using System.Collections.Immutable; +using System.Linq; using Model = Discord.API.MessageComponentInteractionData; namespace Discord.WebSocket diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs index 7b4466af..38532e51 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs @@ -27,7 +27,7 @@ namespace Discord.WebSocket var dataModel = model.Data.IsSpecified ? (DataModel)model.Data.Value : null; - + Data = new SocketModalData(dataModel, client, client.State, client.State.GetGuild(model.GuildId.GetValueOrDefault()), model.User.GetValueOrDefault()); } @@ -380,7 +380,7 @@ namespace Discord.WebSocket /// public override Task RespondWithModalAsync(Modal modal, RequestOptions options = null) => throw new NotSupportedException("You cannot respond to a modal with a modal!"); - + IModalInteractionData IModalInteraction.Data => Data; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModalData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModalData.cs index ec1fe962..52c7615b 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModalData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModalData.cs @@ -1,9 +1,9 @@ +using System; using System.Collections.Generic; using System.Linq; -using System; -using Model = Discord.API.ModalInteractionData; -using InterationModel = Discord.API.Interaction; using DataModel = Discord.API.MessageComponentInteractionData; +using InterationModel = Discord.API.Interaction; +using Model = Discord.API.ModalInteractionData; namespace Discord.WebSocket { diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs index 58afc789..e0f31e0d 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs @@ -3,8 +3,8 @@ using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -using Model = Discord.API.Interaction; using DataModel = Discord.API.AutocompleteInteractionData; +using Model = Discord.API.Interaction; namespace Discord.WebSocket { diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs index bdab128f..c9dd6555 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs @@ -269,7 +269,7 @@ namespace Discord.WebSocket return await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options); } - + /// public override async Task FollowupWithFilesAsync( IEnumerable attachments, diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index f8eb6b12..088e14a2 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -1,11 +1,11 @@ +using Discord.Net; using Discord.Rest; using System; -using System.Threading.Tasks; -using Model = Discord.API.Interaction; -using DataModel = Discord.API.ApplicationCommandInteractionData; -using System.IO; using System.Collections.Generic; -using Discord.Net; +using System.IO; +using System.Threading.Tasks; +using DataModel = Discord.API.ApplicationCommandInteractionData; +using Model = Discord.API.Interaction; namespace Discord.WebSocket { @@ -130,7 +130,7 @@ namespace Discord.WebSocket Data = model.Data.IsSpecified ? model.Data.Value : null; - + Token = model.Token; Version = model.Version; Type = model.Type; @@ -398,7 +398,7 @@ namespace Discord.WebSocket /// The request options for this request. /// A task that represents the asynchronous operation of responding to the interaction. public abstract Task RespondWithModalAsync(Modal modal, RequestOptions options = null); -#endregion + #endregion /// /// Attepts to get the channel this interaction was executed in. @@ -407,7 +407,7 @@ namespace Discord.WebSocket /// /// A task that represents the asynchronous operation of fetching the channel. /// - public async ValueTask GetChannelAsync(RequestOptions options = null) + public async ValueTask GetChannelAsync(RequestOptions options = null) { if (Channel != null) return Channel; @@ -419,10 +419,10 @@ namespace Discord.WebSocket { return (IMessageChannel)await Discord.GetChannelAsync(ChannelId.Value, options).ConfigureAwait(false); } - catch(HttpException ex) when (ex.DiscordCode == DiscordErrorCode.MissingPermissions) { return null; } // bot can't view that channel, return null instead of throwing. + catch (HttpException ex) when (ex.DiscordCode == DiscordErrorCode.MissingPermissions) { return null; } // bot can't view that channel, return null instead of throwing. } -#region IDiscordInteraction + #region IDiscordInteraction /// IUser IDiscordInteraction.User => User; @@ -452,6 +452,6 @@ namespace Discord.WebSocket async Task IDiscordInteraction.FollowupWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options) => await FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false); #endif -#endregion + #endregion } } diff --git a/src/Discord.Net.WebSocket/Entities/Messages/MessageCache.cs b/src/Discord.Net.WebSocket/Entities/Messages/MessageCache.cs index 6baf5687..90064dd3 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/MessageCache.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/MessageCache.cs @@ -48,8 +48,10 @@ namespace Discord.WebSocket /// is less than 0. public IReadOnlyCollection GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) { - if (limit < 0) throw new ArgumentOutOfRangeException(nameof(limit)); - if (limit == 0) return ImmutableArray.Empty; + if (limit < 0) + throw new ArgumentOutOfRangeException(nameof(limit)); + if (limit == 0) + return ImmutableArray.Empty; IEnumerable cachedMessageIds; if (fromMessageId == null) diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs index 197d476f..e7b09c33 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs @@ -309,7 +309,7 @@ namespace Discord.WebSocket /// public override string ToString() => Content; internal SocketMessage Clone() => MemberwiseClone() as SocketMessage; -#endregion + #endregion #region IMessage /// diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketReaction.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketReaction.cs index 32cac7d8..fe24057d 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketReaction.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketReaction.cs @@ -86,11 +86,14 @@ namespace Discord.WebSocket /// public override bool Equals(object other) { - if (other == null) return false; - if (other == this) return true; + if (other == null) + return false; + if (other == this) + return true; var otherReaction = other as SocketReaction; - if (otherReaction == null) return false; + if (otherReaction == null) + return false; return UserId == otherReaction.UserId && MessageId == otherReaction.MessageId && Emote.Equals(otherReaction.Emote); } diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs index ec22a770..f8ab8963 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs @@ -23,7 +23,7 @@ namespace Discord.WebSocket { base.Update(state, model); } - + private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})"; internal new SocketSystemMessage Clone() => MemberwiseClone() as SocketSystemMessage; } diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs index c1dc58eb..c9b16c75 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs @@ -6,9 +6,9 @@ using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -using UserModel = Discord.API.User; using MemberModel = Discord.API.GuildMember; using PresenceModel = Discord.API.Presence; +using UserModel = Discord.API.User; namespace Discord.WebSocket { diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs index 96eee47a..37a86f98 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using System.Threading.Tasks; using Model = Discord.API.ThreadMember; -using System.Collections.Immutable; namespace Discord.WebSocket { @@ -142,7 +142,7 @@ namespace Discord.WebSocket { Thread = thread; Guild = guild; - if(member is not null) + if (member is not null) GuildUser = member; } @@ -156,7 +156,7 @@ namespace Discord.WebSocket internal static SocketThreadUser Create(SocketGuild guild, SocketThreadChannel thread, SocketGuildUser owner) { // this is used for creating the owner of the thread. - var entity = new SocketThreadUser(guild, thread, owner.Id, owner); + var entity = new SocketThreadUser(guild, thread, owner.Id, owner); entity.Update(new Model { JoinTimestamp = thread.CreatedAt, @@ -167,7 +167,7 @@ namespace Discord.WebSocket internal void Update(Model model) { ThreadJoinedAt = model.JoinTimestamp; - if(model.GuildMember.IsSpecified) + if (model.GuildMember.IsSpecified) GuildUser = Guild.AddOrUpdateUser(model.GuildMember.Value); } diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs index d70e6173..b01b10ff 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs @@ -1,3 +1,4 @@ +using Discord.Rest; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -5,7 +6,6 @@ using System.Diagnostics; using System.Globalization; using System.Linq; using System.Threading.Tasks; -using Discord.Rest; using Model = Discord.API.User; using PresenceModel = Discord.API.Presence; diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs index 6c5b867b..d3818760 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs @@ -53,7 +53,7 @@ namespace Discord.WebSocket public bool IsStreaming => (_voiceStates & Flags.SelfStream) != 0; /// public bool IsVideoing => (_voiceStates & Flags.SelfVideo) != 0; - + internal SocketVoiceState(SocketVoiceChannel voiceChannel, DateTimeOffset? requestToSpeak, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isMuted, bool isDeafened, bool isSuppressed, bool isStream, bool isVideo) { diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs index 32633497..434c5afd 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs @@ -51,7 +51,7 @@ namespace Discord.WebSocket private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")}, Webhook)"; internal new SocketWebhookUser Clone() => MemberwiseClone() as SocketWebhookUser; -#endregion + #endregion #region IGuildUser /// diff --git a/src/Discord.Net.WebSocket/Interactions/ShardedInteractionContext.cs b/src/Discord.Net.WebSocket/Interactions/ShardedInteractionContext.cs index ac052417..659e43cb 100644 --- a/src/Discord.Net.WebSocket/Interactions/ShardedInteractionContext.cs +++ b/src/Discord.Net.WebSocket/Interactions/ShardedInteractionContext.cs @@ -18,13 +18,13 @@ namespace Discord.Interactions /// /// The underlying client. /// The underlying interaction. - public ShardedInteractionContext (DiscordShardedClient client, TInteraction interaction) - : base(client.GetShard(GetShardId(client, ( interaction.User as SocketGuildUser )?.Guild)), interaction) + public ShardedInteractionContext(DiscordShardedClient client, TInteraction interaction) + : base(client.GetShard(GetShardId(client, (interaction.User as SocketGuildUser)?.Guild)), interaction) { Client = client; } - private static int GetShardId (DiscordShardedClient client, IGuild guild) + private static int GetShardId(DiscordShardedClient client, IGuild guild) => guild == null ? 0 : client.GetShardIdFor(guild); } diff --git a/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs b/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs index 82079e9b..4068eaa6 100644 --- a/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs +++ b/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs @@ -87,14 +87,17 @@ namespace Discord.Net.Udp } public async Task StopInternalAsync(bool isDisposing = false) { - try { _stopCancelTokenSource.Cancel(false); } catch { } + try + { _stopCancelTokenSource.Cancel(false); } + catch { } if (!isDisposing) await (_task ?? Task.Delay(0)).ConfigureAwait(false); if (_udp != null) { - try { _udp.Dispose(); } + try + { _udp.Dispose(); } catch { } _udp = null; } diff --git a/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs b/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs index d701fa79..28ed0a60 100644 --- a/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs +++ b/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs @@ -4,7 +4,7 @@ namespace Discord.Net.Udp { public static class DefaultUdpSocketProvider { - public static readonly UdpSocketProvider Instance = () => + public static readonly UdpSocketProvider Instance = () => { try { diff --git a/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs b/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs index 82e2f057..c4d354cb 100644 --- a/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs +++ b/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs @@ -110,7 +110,8 @@ namespace Discord.Net.WebSockets { _isDisconnecting = true; - try { _disconnectTokenSource.Cancel(false); } + try + { _disconnectTokenSource.Cancel(false); } catch { } if (_client != null) @@ -118,10 +119,12 @@ namespace Discord.Net.WebSockets if (!isDisposing) { var status = (WebSocketCloseStatus)closeCode; - try { await _client.CloseOutputAsync(status, "", new CancellationToken()); } + try + { await _client.CloseOutputAsync(status, "", new CancellationToken()); } catch { } } - try { _client.Dispose(); } + try + { _client.Dispose(); } catch { } _client = null; @@ -176,7 +179,8 @@ namespace Discord.Net.WebSockets } try { - if (_client == null) return; + if (_client == null) + return; int frameCount = (int)Math.Ceiling((double)count / SendChunkSize); @@ -223,7 +227,8 @@ namespace Discord.Net.WebSockets stream.Write(buffer.Array, 0, socketResult.Count); do { - if (cancelToken.IsCancellationRequested) return; + if (cancelToken.IsCancellationRequested) + return; socketResult = await _client.ReceiveAsync(buffer, cancelToken).ConfigureAwait(false); stream.Write(buffer.Array, 0, socketResult.Count); } diff --git a/src/Discord.Net.Webhook/DiscordWebhookClient.cs b/src/Discord.Net.Webhook/DiscordWebhookClient.cs index 55633895..53f5b488 100644 --- a/src/Discord.Net.Webhook/DiscordWebhookClient.cs +++ b/src/Discord.Net.Webhook/DiscordWebhookClient.cs @@ -1,11 +1,11 @@ +using Discord.Logging; +using Discord.Rest; using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Text.RegularExpressions; using System.Threading.Tasks; -using Discord.Logging; -using Discord.Rest; namespace Discord.Webhook { @@ -18,13 +18,13 @@ namespace Discord.Webhook private readonly ulong _webhookId; internal IWebhook Webhook; internal readonly Logger _restLogger; - + internal API.DiscordRestApiClient ApiClient { get; } internal LogManager LogManager { get; } /// Creates a new Webhook Discord client. public DiscordWebhookClient(IWebhook webhook) - : this(webhook.Id, webhook.Token, new DiscordRestConfig()) { } + : this(webhook.Id, webhook.Token, new DiscordRestConfig()) { } /// Creates a new Webhook Discord client. public DiscordWebhookClient(ulong webhookId, string webhookToken) : this(webhookId, webhookToken, new DiscordRestConfig()) { } @@ -117,7 +117,7 @@ namespace Discord.Webhook /// /// A task that represents the asynchronous deletion operation. /// - public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null, ulong ? threadId = null) + public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null, ulong? threadId = null) => WebhookClientHelper.DeleteMessageAsync(this, messageId, options, threadId); /// Sends a message to the channel for this webhook with an attachment. @@ -141,7 +141,7 @@ namespace Discord.Webhook /// Returns the ID of the created message. public Task SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, IEnumerable embeds = null, string username = null, string avatarUrl = null, - RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, + RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, MessageFlags flags = MessageFlags.None, ulong? threadId = null) => WebhookClientHelper.SendFileAsync(this, attachment, text, isTTS, embeds, username, avatarUrl, allowedMentions, components, options, flags, threadId); @@ -150,7 +150,7 @@ namespace Discord.Webhook /// Returns the ID of the created message. public Task SendFilesAsync(IEnumerable attachments, string text, bool isTTS = false, IEnumerable embeds = null, string username = null, string avatarUrl = null, - RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, + RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, MessageFlags flags = MessageFlags.None, ulong? threadId = null) => WebhookClientHelper.SendFilesAsync(this, attachments, text, isTTS, embeds, username, avatarUrl, allowedMentions, components, options, flags, threadId); diff --git a/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs b/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs index 1082c431..cfde6c0d 100644 --- a/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs +++ b/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs @@ -17,7 +17,7 @@ namespace Discord.Webhook public string Name { get; private set; } public string AvatarId { get; private set; } public ulong? GuildId { get; private set; } - public ulong? ApplicationId { get; private set; } + public ulong? ApplicationId { get; private set; } public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); diff --git a/src/Discord.Net.Webhook/WebhookClientHelper.cs b/src/Discord.Net.Webhook/WebhookClientHelper.cs index 8ad74e7e..e8bc1e1a 100644 --- a/src/Discord.Net.Webhook/WebhookClientHelper.cs +++ b/src/Discord.Net.Webhook/WebhookClientHelper.cs @@ -1,10 +1,10 @@ +using Discord.API.Rest; +using Discord.Rest; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -using Discord.API.Rest; -using Discord.Rest; using ImageModel = Discord.API.Image; using WebhookModel = Discord.API.Webhook; @@ -115,18 +115,18 @@ namespace Discord.Webhook MessageComponent components, MessageFlags flags, ulong? threadId) => SendFileAsync(client, new FileAttachment(stream, filename, isSpoiler: isSpoiler), text, isTTS, embeds, username, avatarUrl, allowedMentions, components, options, flags, threadId); - public static Task SendFileAsync(DiscordWebhookClient client, FileAttachment attachment, string text, bool isTTS, - IEnumerable embeds, string username, string avatarUrl, AllowedMentions allowedMentions, + public static Task SendFileAsync(DiscordWebhookClient client, FileAttachment attachment, string text, bool isTTS, + IEnumerable embeds, string username, string avatarUrl, AllowedMentions allowedMentions, MessageComponent components, RequestOptions options, MessageFlags flags, ulong? threadId) => SendFilesAsync(client, new FileAttachment[] { attachment }, text, isTTS, embeds, username, avatarUrl, allowedMentions, components, options, flags, threadId); public static async Task SendFilesAsync(DiscordWebhookClient client, - IEnumerable attachments, string text, bool isTTS, IEnumerable embeds, string username, + IEnumerable attachments, string text, bool isTTS, IEnumerable embeds, string username, string avatarUrl, AllowedMentions allowedMentions, MessageComponent components, RequestOptions options, MessageFlags flags, ulong? threadId) { embeds ??= Array.Empty(); - + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds.Count(), 10, nameof(embeds), "A max of 10 embeds are allowed."); @@ -155,13 +155,14 @@ namespace Discord.Webhook if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds) throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds and none.", nameof(flags)); - var args = new UploadWebhookFileParams(attachments.ToArray()) + var args = new UploadWebhookFileParams(attachments.ToArray()) { - AvatarUrl = avatarUrl, - Username = username, Content = text, - IsTTS = isTTS, - Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional.Unspecified, - AllowedMentions = allowedMentions?.ToModel() ?? Optional.Unspecified, + AvatarUrl = avatarUrl, + Username = username, + Content = text, + IsTTS = isTTS, + Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional.Unspecified, + AllowedMentions = allowedMentions?.ToModel() ?? Optional.Unspecified, MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, Flags = flags }; diff --git a/test/Discord.Net.Analyzers.Tests/GuildAccessTests.cs b/test/Discord.Net.Analyzers.Tests/GuildAccessTests.cs index 4cb5cefc..e6a41077 100644 --- a/test/Discord.Net.Analyzers.Tests/GuildAccessTests.cs +++ b/test/Discord.Net.Analyzers.Tests/GuildAccessTests.cs @@ -1,7 +1,7 @@ -using System; +using Discord.Analyzers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -using Discord.Analyzers; +using System; using TestHelper; using Xunit; diff --git a/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs b/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs index 42f7b08c..1631b843 100644 --- a/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs +++ b/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs @@ -1,4 +1,4 @@ -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Simplification; diff --git a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs index 87d91549..8009f8a2 100644 --- a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs +++ b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs @@ -1,4 +1,4 @@ -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; using System; namespace TestHelper @@ -84,4 +84,4 @@ namespace TestHelper } } } -} \ No newline at end of file +} diff --git a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs index 23bb319a..c2f8f12a 100644 --- a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs +++ b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs @@ -1,13 +1,13 @@ +using Discord.Commands; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Text; using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Text; -using Discord.Commands; namespace TestHelper { diff --git a/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs b/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs index 9b0219a6..542d2a85 100644 --- a/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs +++ b/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs @@ -1,8 +1,8 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; using System.Collections.Generic; using System.Linq; using System.Text; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; //using Microsoft.VisualStudio.TestTools.UnitTesting; using Xunit; diff --git a/test/Discord.Net.Tests.Integration/DiscordRestApiClientTests.cs b/test/Discord.Net.Tests.Integration/DiscordRestApiClientTests.cs index 96b33b14..b2e23348 100644 --- a/test/Discord.Net.Tests.Integration/DiscordRestApiClientTests.cs +++ b/test/Discord.Net.Tests.Integration/DiscordRestApiClientTests.cs @@ -1,4 +1,4 @@ -using Discord.API; +using Discord.API; using Discord.API.Rest; using Discord.Net; using Discord.Rest; diff --git a/test/Discord.Net.Tests.Integration/GuildTests.cs b/test/Discord.Net.Tests.Integration/GuildTests.cs index c309b0ed..78d0ffe4 100644 --- a/test/Discord.Net.Tests.Integration/GuildTests.cs +++ b/test/Discord.Net.Tests.Integration/GuildTests.cs @@ -76,7 +76,7 @@ namespace Discord await guild.ModifyAsync(x => { x.SystemChannel = new Optional(systemChannel); }); Assert.Equal(systemChannel.Id, guild.SystemChannelId); - await Assert.ThrowsAsync( async () => + await Assert.ThrowsAsync(async () => { await guild.ModifyAsync(x => x.SystemChannel = null); }); @@ -103,7 +103,7 @@ namespace Discord await guild.ModifyAsync(x => x.AfkChannel = new Optional(afkChannel)); Assert.Equal(afkChannel.Id, guild.AFKChannelId); - await Assert.ThrowsAsync( async () => + await Assert.ThrowsAsync(async () => { await guild.ModifyAsync(x => x.AfkChannel = null); }); diff --git a/test/Discord.Net.Tests.Integration/RestGuildFixture.cs b/test/Discord.Net.Tests.Integration/RestGuildFixture.cs index 40b9ca9b..be7a7416 100644 --- a/test/Discord.Net.Tests.Integration/RestGuildFixture.cs +++ b/test/Discord.Net.Tests.Integration/RestGuildFixture.cs @@ -1,8 +1,8 @@ using Discord.Rest; using System; using System.Collections.Generic; -using System.Text; using System.Linq; +using System.Text; namespace Discord { diff --git a/test/Discord.Net.Tests.Unit/CommandBuilderTests.cs b/test/Discord.Net.Tests.Unit/CommandBuilderTests.cs index c804f21d..22df7cc3 100644 --- a/test/Discord.Net.Tests.Unit/CommandBuilderTests.cs +++ b/test/Discord.Net.Tests.Unit/CommandBuilderTests.cs @@ -1,5 +1,5 @@ -using System; using Discord; +using System; using Xunit; namespace Discord; @@ -17,7 +17,7 @@ public class CommandBuilderTests ApplicationCommandOptionType.String, "option1 description", isRequired: true, - choices: new [] + choices: new[] { new ApplicationCommandOptionChoiceProperties() { diff --git a/test/Discord.Net.Tests.Unit/GuildHelperTests.cs b/test/Discord.Net.Tests.Unit/GuildHelperTests.cs index c68f415f..b04cb9d2 100644 --- a/test/Discord.Net.Tests.Unit/GuildHelperTests.cs +++ b/test/Discord.Net.Tests.Unit/GuildHelperTests.cs @@ -1,4 +1,4 @@ -using Discord.Rest; +using Discord.Rest; using FluentAssertions; using Moq; using System; diff --git a/test/Discord.Net.Tests.Unit/MessageHelperTests.cs b/test/Discord.Net.Tests.Unit/MessageHelperTests.cs index 0c329f19..42688edf 100644 --- a/test/Discord.Net.Tests.Unit/MessageHelperTests.cs +++ b/test/Discord.Net.Tests.Unit/MessageHelperTests.cs @@ -1,5 +1,5 @@ -using Xunit; using Discord.Rest; +using Xunit; namespace Discord { diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedCategoryChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedCategoryChannel.cs index 08d3c740..5588bd67 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedCategoryChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedCategoryChannel.cs @@ -20,7 +20,7 @@ namespace Discord public DateTimeOffset CreatedAt => throw new NotImplementedException(); public ulong Id => throw new NotImplementedException(); - + public ChannelFlags Flags => throw new NotImplementedException(); public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs index b7f98f57..74dc5ee9 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs @@ -1,8 +1,8 @@ +using Discord.Audio; using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -using Discord.Audio; namespace Discord { diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs index 11737fb8..873e8df7 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs @@ -214,7 +214,7 @@ namespace Discord { throw new NotImplementedException(); } - + public Task SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => throw new NotImplementedException(); public Task SendFilesAsync(IEnumerable attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => throw new NotImplementedException(); public Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null, MessageFlags flags = MessageFlags.None) => throw new NotImplementedException(); diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs index da978e55..3373ec93 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs @@ -1,9 +1,9 @@ +using Discord.Audio; using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Threading.Tasks; -using Discord.Audio; namespace Discord {