diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..696bb866
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,113 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_size = 4
+indent_style = space
+trim_trailing_whitespace = true
+
+[*.{csproj,json,md,nuspec,yml}]
+indent_size = 2
+indent_style = space
+
+[*.{sln,xml}]
+indent_style = tab
+
+[*.cs]
+dotnet_style_qualification_for_field = false:suggestion
+dotnet_style_qualification_for_property = false:suggestion
+dotnet_style_qualification_for_method = false:suggestion
+dotnet_style_qualification_for_event = false:suggestion
+
+dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
+dotnet_style_predefined_type_for_member_access = true:suggestion
+
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_explicit_tuple_names = true:suggestion
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+
+csharp_style_var_for_built_in_types = true:suggestion
+csharp_style_var_when_type_is_apparent = true:suggestion
+csharp_style_var_elsewhere = true:suggestion
+
+csharp_style_expression_bodied_methods = true:none
+csharp_style_expression_bodied_operators = true:none
+csharp_style_expression_bodied_properties = true:none
+csharp_style_expression_bodied_indexers = true:none
+csharp_style_expression_bodied_accessors = true:none
+
+csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
+csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
+csharp_style_inlined_variable_declaration = true:suggestion
+
+csharp_prefer_simple_default_expression = false:none
+
+csharp_style_throw_expression = true:none
+csharp_style_conditional_delegate_call = true:none
+csharp_prefer_braces = false:none
+
+dotnet_sort_system_directives_first = false
+
+csharp_new_line_before_open_brace = all
+csharp_new_line_before_else = true
+csharp_new_line_before_catch = true
+csharp_new_line_before_finally = true
+csharp_new_line_before_members_in_object_initializers = true
+csharp_new_line_before_members_in_anonymous_types = true
+csharp_new_line_within_query_expression_clauses = true
+
+csharp_indent_case_contents = true
+csharp_indent_switch_labels = true
+csharp_indent_labels = flush_left
+
+csharp_space_after_cast = false
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+csharp_space_between_method_call_parameter_list_parentheses = false
+
+csharp_preserve_single_line_statements = false
+csharp_preserve_single_line_blocks = true
+
+dotnet_naming_rule.all_of_const_fields_are_pascal_case.symbols = const_fields
+dotnet_naming_rule.all_of_const_fields_are_pascal_case.style = pascal_case
+dotnet_naming_rule.all_of_const_fields_are_pascal_case.severity = suggestion
+
+dotnet_naming_rule.all_of_local_fields_without_const_are_camel_case.symbols = local_fields
+dotnet_naming_rule.all_of_local_fields_without_const_are_camel_case.style = starts_with_low_line_camel_case
+dotnet_naming_rule.all_of_local_fields_without_const_are_camel_case.severity = suggestion
+
+dotnet_naming_rule.all_of_interfaces_starts_with_low_line_camel_case.symbols = interfaces
+dotnet_naming_rule.all_of_interfaces_starts_with_low_line_camel_case.style = starts_with_i_pascal_case
+dotnet_naming_rule.all_of_interfaces_starts_with_low_line_camel_case.severity = suggestion
+
+dotnet_naming_rule.default_is_pascal_case.symbols = without_interfaces_and_fields
+dotnet_naming_rule.default_is_pascal_case.style = pascal_case
+dotnet_naming_rule.default_is_pascal_case.severity = suggestion
+
+dotnet_naming_symbols.const_fields.applicable_kinds = field
+dotnet_naming_symbols.const_fields.applicable_accessibilities = *
+dotnet_naming_symbols.const_fields.required_modifiers = const
+
+dotnet_naming_symbols.interfaces.applicable_kinds = interface
+dotnet_naming_symbols.interfaces.applicable_accessibilities = *
+
+dotnet_naming_symbols.local_fields.applicable_kinds = field
+dotnet_naming_symbols.local_fields.applicable_accessibilities = internal, private, protected, protected_internal
+dotnet_naming_symbols.local_fields.required_modifiers = abstract, must_inherit, readonly, static, shared
+
+dotnet_naming_symbols.without_interfaces_and_fields.applicable_kinds = class, struct, enum, property, method, event, namespace, delegate, type_parameter
+dotnet_naming_symbols.without_interfaces_and_fields.applicable_accessibilities = *
+
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.starts_with_i_pascal_case.required_prefix = I
+dotnet_naming_style.starts_with_i_pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.starts_with_low_line_camel_case.required_prefix = _
+dotnet_naming_style.starts_with_low_line_camel_case.capitalization = camel_case
diff --git a/samples/Kook.Net.Samples.ReactionRoleBot/Configurations/KookBotConfigurations.cs b/samples/Kook.Net.Samples.ReactionRoleBot/Configurations/KookBotConfigurations.cs
index b8286ad3..3a75c84f 100644
--- a/samples/Kook.Net.Samples.ReactionRoleBot/Configurations/KookBotConfigurations.cs
+++ b/samples/Kook.Net.Samples.ReactionRoleBot/Configurations/KookBotConfigurations.cs
@@ -1,4 +1,4 @@
-using Kook.Net.Samples.ReactionRoleBot.Enums;
+using Kook.Net.Samples.ReactionRoleBot.Enums;
namespace Kook.Net.Samples.ReactionRoleBot.Configurations;
@@ -18,7 +18,7 @@ public class KookBotConfigurations
/// 角色ID列表
///
public KookRoles Roles { get; init; }
-
+
///
/// KOOK Bot运行环境
///
@@ -33,4 +33,4 @@ public class KookChannels
public class KookRoles
{
public ulong DeveloperRoleId { get; init; }
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.ReactionRoleBot/Enums/BotEnvironment.cs b/samples/Kook.Net.Samples.ReactionRoleBot/Enums/BotEnvironment.cs
index c1b6ff0c..9f49b87b 100644
--- a/samples/Kook.Net.Samples.ReactionRoleBot/Enums/BotEnvironment.cs
+++ b/samples/Kook.Net.Samples.ReactionRoleBot/Enums/BotEnvironment.cs
@@ -1,4 +1,4 @@
-using System.ComponentModel;
+using System.ComponentModel;
namespace Kook.Net.Samples.ReactionRoleBot.Enums;
@@ -15,4 +15,4 @@ public enum BotEnvironment
///
[Description("生产")]
Production,
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtension.cs b/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtension.cs
index 680c17f2..04045419 100644
--- a/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtension.cs
+++ b/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtension.cs
@@ -74,4 +74,4 @@ public Task StopAsync(CancellationToken cancellationToken)
_logger.Fatal("Kook Client Stopped!");
return Task.CompletedTask;
}
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtensionEventHandlers.cs b/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtensionEventHandlers.cs
index 8566d924..0055ead9 100644
--- a/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtensionEventHandlers.cs
+++ b/samples/Kook.Net.Samples.ReactionRoleBot/Extensions/KookBotClientExtensionEventHandlers.cs
@@ -6,12 +6,14 @@ public partial class KookBotClientExtension
{
private async Task ProcessReactionRoleAdd(Cacheable message, Cacheable channel, SocketReaction reaction)
{
- if (channel.Id != 5770952608991958) return;
- if (!reaction.Emote.Equals(Emoji.Parse(":computer:"))) return;
-
+ if (channel.Id != 5770952608991958)
+ return;
+ if (!reaction.Emote.Equals(Emoji.Parse(":computer:")))
+ return;
+
SocketRole socketRole = _kookSocketClient.GetGuild(1591057729615250).GetRole(3001653);
- SocketGuildUser socketGuildUser = (SocketGuildUser) reaction.User;
-
+ SocketGuildUser socketGuildUser = (SocketGuildUser)reaction.User;
+
await socketGuildUser.AddRoleAsync(socketRole);
SocketDMChannel dmChannel = await socketGuildUser.CreateDMChannelAsync();
@@ -24,21 +26,23 @@ private async Task ProcessReactionRoleAdd(Cacheable message,
.WithText($"已在服务器 `{socketGuildUser.Guild.Name}` 内为您授予角色 `{socketRole.Name}`", true))
.AddModule(new ContextModuleBuilder().AddElement(new KMarkdownElementBuilder()
.WithContent($"{_kookSocketClient.CurrentUser.Username} | {time}")));
-
+
await dmChannel.SendCardAsync(builder.Build());
-
- _logger.Information("{User}#{IdentifyNumber} is granted {RoleName}",
+
+ _logger.Information("{User}#{IdentifyNumber} is granted {RoleName}",
socketGuildUser.Username, socketGuildUser.IdentifyNumber, socketRole.Name);
}
private async Task ProcessReactionRoleRemove(Cacheable message, Cacheable channel, SocketReaction reaction)
{
- if (channel.Id != 5770952608991958) return;
- if (!reaction.Emote.Equals(Emoji.Parse(":computer:"))) return;
-
+ if (channel.Id != 5770952608991958)
+ return;
+ if (!reaction.Emote.Equals(Emoji.Parse(":computer:")))
+ return;
+
SocketRole socketRole = _kookSocketClient.GetGuild(1591057729615250).GetRole(3001653);
- SocketGuildUser socketGuildUser = (SocketGuildUser) reaction.User;
-
+ SocketGuildUser socketGuildUser = (SocketGuildUser)reaction.User;
+
await socketGuildUser.RemoveRoleAsync(socketRole);
SocketDMChannel dmChannel = await socketGuildUser.CreateDMChannelAsync();
@@ -51,10 +55,10 @@ private async Task ProcessReactionRoleRemove(Cacheable messa
.WithText($"已在服务器 `{socketGuildUser.Guild.Name}` 内为您撤销角色 `{socketRole.Name}`", true))
.AddModule(new ContextModuleBuilder().AddElement(new KMarkdownElementBuilder()
.WithContent($"{_kookSocketClient.CurrentUser.Username} | {time}")));
-
+
await dmChannel.SendCardAsync(builder.Build());
-
- _logger.Information("{User}#{IdentifyNumber} is revoked {RoleName}",
+
+ _logger.Information("{User}#{IdentifyNumber} is revoked {RoleName}",
socketGuildUser.Username, socketGuildUser.IdentifyNumber, socketRole.Name);
}
@@ -69,4 +73,4 @@ private async Task SendReactionCard()
.SendCardAsync(builder.Build()).ConfigureAwait(false);
await _kookSocketClient.Rest.AddReactionAsync(response.Id, Emoji.Parse(":computer:"));
}
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.ReactionRoleBot/Program.cs b/samples/Kook.Net.Samples.ReactionRoleBot/Program.cs
index edda8cc7..43614014 100644
--- a/samples/Kook.Net.Samples.ReactionRoleBot/Program.cs
+++ b/samples/Kook.Net.Samples.ReactionRoleBot/Program.cs
@@ -1,4 +1,4 @@
-using Kook;
+using Kook;
using Kook.Net.Samples.ReactionRoleBot.Configurations;
using Kook.Net.Samples.ReactionRoleBot.Extensions;
using Kook.WebSocket;
@@ -18,7 +18,7 @@ private static async Task Main(string[] args)
await host.RunAsync();
}
-
+
private static IHostBuilder CreateHostBuilder(string[] args)
{
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args)
@@ -72,4 +72,4 @@ private static void ConfigureServices(HostBuilderContext hostContext, IServiceCo
.AddHttpClient();
}
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.SimpleBot/Program.cs b/samples/Kook.Net.Samples.SimpleBot/Program.cs
index 5d1832da..a44e48a7 100644
--- a/samples/Kook.Net.Samples.SimpleBot/Program.cs
+++ b/samples/Kook.Net.Samples.SimpleBot/Program.cs
@@ -1,9 +1,9 @@
-// See https://aka.ms/new-console-template for more information
+// See https://aka.ms/new-console-template for more information
-using System.Collections.Immutable;
using Kook;
using Kook.Rest;
using Kook.WebSocket;
+using System.Collections.Immutable;
class Program
{
@@ -102,4 +102,4 @@ public async Task MainAsync()
await _client.StartAsync();
await Task.Delay(Timeout.Infinite);
}
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.TextCommands/Modules/PublicModule.cs b/samples/Kook.Net.Samples.TextCommands/Modules/PublicModule.cs
index c2e8920b..e602fb41 100644
--- a/samples/Kook.Net.Samples.TextCommands/Modules/PublicModule.cs
+++ b/samples/Kook.Net.Samples.TextCommands/Modules/PublicModule.cs
@@ -1,9 +1,9 @@
using Kook;
using Kook.Commands;
-using System.IO;
-using System.Threading.Tasks;
using Kook.Rest;
using Kook.WebSocket;
+using System.IO;
+using System.Threading.Tasks;
using TextCommandFramework.Services;
namespace TextCommandFramework.Modules;
@@ -78,9 +78,9 @@ public Task GuildOnlyCommand()
public async Task ModifyCategoryPermissions()
{
SocketUser contextUser = Context.User;
- await ((IGuildChannel) Context.Channel).AddPermissionOverwriteAsync((IGuildUser) Context.User);
- await ((SocketChannel) Context.Channel).UpdateAsync();
- await Context.Guild.GetChannel(Context.Channel.Id).ModifyPermissionOverwriteAsync((IGuildUser) Context.User,
+ await ((IGuildChannel)Context.Channel).AddPermissionOverwriteAsync((IGuildUser)Context.User);
+ await ((SocketChannel)Context.Channel).UpdateAsync();
+ await Context.Guild.GetChannel(Context.Channel.Id).ModifyPermissionOverwriteAsync((IGuildUser)Context.User,
permissions => permissions.Modify(viewChannel: PermValue.Allow, sendMessages: PermValue.Deny, attachFiles: PermValue.Allow));
}
@@ -92,4 +92,4 @@ public async Task CreateChannel()
IReadOnlyCollection readOnlyCollection = guildUserAsync.RoleIds;
}
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.TextCommands/Program.cs b/samples/Kook.Net.Samples.TextCommands/Program.cs
index 3871acee..54f71f68 100644
--- a/samples/Kook.Net.Samples.TextCommands/Program.cs
+++ b/samples/Kook.Net.Samples.TextCommands/Program.cs
@@ -70,4 +70,4 @@ private ServiceProvider ConfigureServices()
.AddSingleton()
.BuildServiceProvider();
}
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.TextCommands/Services/CommandHandlingService.cs b/samples/Kook.Net.Samples.TextCommands/Services/CommandHandlingService.cs
index f2767c3c..352349a9 100644
--- a/samples/Kook.Net.Samples.TextCommands/Services/CommandHandlingService.cs
+++ b/samples/Kook.Net.Samples.TextCommands/Services/CommandHandlingService.cs
@@ -73,4 +73,4 @@ public async Task CommandExecutedAsync(CommandInfo command, ICommandContext cont
// the command failed, let's notify the user that something happened.
await context.Channel.SendTextAsync($"error: {result}");
}
-}
\ No newline at end of file
+}
diff --git a/samples/Kook.Net.Samples.TextCommands/Services/PictureService.cs b/samples/Kook.Net.Samples.TextCommands/Services/PictureService.cs
index c7b3d48e..f09d060b 100644
--- a/samples/Kook.Net.Samples.TextCommands/Services/PictureService.cs
+++ b/samples/Kook.Net.Samples.TextCommands/Services/PictureService.cs
@@ -16,4 +16,4 @@ public async Task GetCatPictureAsync()
var resp = await _http.GetAsync("https://cataas.com/cat");
return await resp.Content.ReadAsStreamAsync();
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/AliasAttribute.cs b/src/Kook.Net.Commands/Attributes/AliasAttribute.cs
index 2c083ba7..a9c08b2e 100644
--- a/src/Kook.Net.Commands/Attributes/AliasAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/AliasAttribute.cs
@@ -37,4 +37,4 @@ public AliasAttribute(params string[] aliases)
{
Aliases = aliases;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/CommandAttribute.cs b/src/Kook.Net.Commands/Attributes/CommandAttribute.cs
index 7dcc7f22..8cd1cd13 100644
--- a/src/Kook.Net.Commands/Attributes/CommandAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/CommandAttribute.cs
@@ -37,4 +37,4 @@ public CommandAttribute(string text, bool ignoreExtraArgs)
Text = text;
IgnoreExtraArgs = ignoreExtraArgs;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/DontAutoLoadAttribute.cs b/src/Kook.Net.Commands/Attributes/DontAutoLoadAttribute.cs
index 1f9f6352..13c78060 100644
--- a/src/Kook.Net.Commands/Attributes/DontAutoLoadAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/DontAutoLoadAttribute.cs
@@ -13,4 +13,4 @@ namespace Kook.Commands;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class DontAutoLoadAttribute : Attribute
{
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/DontInjectAttribute.cs b/src/Kook.Net.Commands/Attributes/DontInjectAttribute.cs
index 8f9e0583..ebf8af42 100644
--- a/src/Kook.Net.Commands/Attributes/DontInjectAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/DontInjectAttribute.cs
@@ -27,4 +27,4 @@ namespace Kook.Commands;
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class DontInjectAttribute : Attribute
{
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/GroupAttribute.cs b/src/Kook.Net.Commands/Attributes/GroupAttribute.cs
index a236f9a7..0db7def7 100644
--- a/src/Kook.Net.Commands/Attributes/GroupAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/GroupAttribute.cs
@@ -26,4 +26,4 @@ public GroupAttribute(string prefix)
{
Prefix = prefix;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/NameAttribute.cs b/src/Kook.Net.Commands/Attributes/NameAttribute.cs
index 1ac2b147..4803bacd 100644
--- a/src/Kook.Net.Commands/Attributes/NameAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/NameAttribute.cs
@@ -22,4 +22,4 @@ public NameAttribute(string text)
{
Text = text;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/NamedArgumentTypeAttribute.cs b/src/Kook.Net.Commands/Attributes/NamedArgumentTypeAttribute.cs
index f11546a7..88840eee 100644
--- a/src/Kook.Net.Commands/Attributes/NamedArgumentTypeAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/NamedArgumentTypeAttribute.cs
@@ -7,4 +7,4 @@ namespace Kook.Commands;
/// as a collection of named arguments matching to its properties.
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
-public sealed class NamedArgumentTypeAttribute : Attribute { }
\ No newline at end of file
+public sealed class NamedArgumentTypeAttribute : Attribute { }
diff --git a/src/Kook.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs b/src/Kook.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs
index b6a01d85..2fcbb62e 100644
--- a/src/Kook.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs
@@ -43,7 +43,7 @@ public OverrideTypeReaderAttribute(Type overridenTypeReader)
{
if (!TypeReaderTypeInfo.IsAssignableFrom(overridenTypeReader.GetTypeInfo()))
throw new ArgumentException($"{nameof(overridenTypeReader)} must inherit from {nameof(TypeReader)}.");
-
+
TypeReader = overridenTypeReader;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/ParameterPreconditionAttribute.cs b/src/Kook.Net.Commands/Attributes/ParameterPreconditionAttribute.cs
index fc0ca439..f7350b5b 100644
--- a/src/Kook.Net.Commands/Attributes/ParameterPreconditionAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/ParameterPreconditionAttribute.cs
@@ -18,4 +18,4 @@ public abstract class ParameterPreconditionAttribute : Attribute
/// The raw value of the parameter.
/// The service collection used for dependency injection.
public abstract Task CheckPermissionsAsync(ICommandContext context, ParameterInfo parameter, object value, IServiceProvider services);
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/PreconditionAttribute.cs b/src/Kook.Net.Commands/Attributes/PreconditionAttribute.cs
index 88f9a975..55d74c75 100644
--- a/src/Kook.Net.Commands/Attributes/PreconditionAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/PreconditionAttribute.cs
@@ -35,4 +35,4 @@ public abstract class PreconditionAttribute : Attribute
/// The command being executed.
/// The service collection used for dependency injection.
public abstract Task CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services);
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/Preconditions/RequireBotPermissionAttribute.cs b/src/Kook.Net.Commands/Attributes/Preconditions/RequireBotPermissionAttribute.cs
index 1167cd0e..5a523347 100644
--- a/src/Kook.Net.Commands/Attributes/Preconditions/RequireBotPermissionAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/Preconditions/RequireBotPermissionAttribute.cs
@@ -82,4 +82,4 @@ public override async Task CheckPermissionsAsync(ICommandCon
return PreconditionResult.FromSuccess();
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/Preconditions/RequireContextAttribute.cs b/src/Kook.Net.Commands/Attributes/Preconditions/RequireContextAttribute.cs
index bd4e30b5..8c49cb16 100644
--- a/src/Kook.Net.Commands/Attributes/Preconditions/RequireContextAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/Preconditions/RequireContextAttribute.cs
@@ -64,4 +64,4 @@ public override Task CheckPermissionsAsync(ICommandContext c
else
return Task.FromResult(PreconditionResult.FromError(ErrorMessage ?? $"Invalid context for command; accepted contexts: {Contexts}."));
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserAttribute.cs b/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserAttribute.cs
index 4ba7b7ad..f845fd76 100644
--- a/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserAttribute.cs
@@ -32,7 +32,7 @@ namespace Kook.Commands;
public class RequireUserAttribute : PreconditionAttribute
{
private readonly ulong _userId;
-
+
public RequireUserAttribute(ulong userId)
{
_userId = userId;
@@ -42,7 +42,7 @@ public RequireUserAttribute(IUser user)
{
_userId = user.Id;
}
-
+
///
public override string ErrorMessage { get; set; }
@@ -53,4 +53,4 @@ public override Task CheckPermissionsAsync(ICommandContext c
? PreconditionResult.FromError(ErrorMessage ?? $"Command can only be run by the specified user with identifier {_userId}.")
: PreconditionResult.FromSuccess());
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs b/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs
index 974fb560..280a705f 100644
--- a/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs
@@ -61,7 +61,7 @@ public override Task CheckPermissionsAsync(ICommandContext c
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}."));
}
@@ -80,4 +80,4 @@ public override Task CheckPermissionsAsync(ICommandContext c
return Task.FromResult(PreconditionResult.FromSuccess());
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/PriorityAttribute.cs b/src/Kook.Net.Commands/Attributes/PriorityAttribute.cs
index f8a06319..a0794dcb 100644
--- a/src/Kook.Net.Commands/Attributes/PriorityAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/PriorityAttribute.cs
@@ -20,4 +20,4 @@ public PriorityAttribute(int priority)
{
Priority = priority;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/RemainderAttribute.cs b/src/Kook.Net.Commands/Attributes/RemainderAttribute.cs
index bca45c82..6c4b2c5d 100644
--- a/src/Kook.Net.Commands/Attributes/RemainderAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/RemainderAttribute.cs
@@ -8,4 +8,4 @@ namespace Kook.Commands;
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public class RemainderAttribute : Attribute
{
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/RemarksAttribute.cs b/src/Kook.Net.Commands/Attributes/RemarksAttribute.cs
index bc491636..8fb85392 100644
--- a/src/Kook.Net.Commands/Attributes/RemarksAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/RemarksAttribute.cs
@@ -15,4 +15,4 @@ public RemarksAttribute(string text)
{
Text = text;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Attributes/SummaryAttribute.cs b/src/Kook.Net.Commands/Attributes/SummaryAttribute.cs
index c21c6429..778e6c36 100644
--- a/src/Kook.Net.Commands/Attributes/SummaryAttribute.cs
+++ b/src/Kook.Net.Commands/Attributes/SummaryAttribute.cs
@@ -15,4 +15,4 @@ public SummaryAttribute(string text)
{
Text = text;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Builders/CommandBuilder.cs b/src/Kook.Net.Commands/Builders/CommandBuilder.cs
index 4a91a88f..b9077c61 100644
--- a/src/Kook.Net.Commands/Builders/CommandBuilder.cs
+++ b/src/Kook.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 Kook.Commands.Builders;
@@ -145,4 +145,4 @@ internal CommandInfo Build(ModuleInfo info, CommandService service)
return new CommandInfo(this, info, service);
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Builders/ModuleBuilder.cs b/src/Kook.Net.Commands/Builders/ModuleBuilder.cs
index 4c4a0512..ff5b8b81 100644
--- a/src/Kook.Net.Commands/Builders/ModuleBuilder.cs
+++ b/src/Kook.Net.Commands/Builders/ModuleBuilder.cs
@@ -20,7 +20,9 @@ public class ModuleBuilder
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);
@@ -145,4 +147,4 @@ private ModuleInfo BuildImpl(CommandService service, IServiceProvider services,
internal ModuleInfo Build(CommandService service, IServiceProvider services, ModuleInfo parent) => BuildImpl(service, services, parent);
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Builders/ModuleClassBuilder.cs b/src/Kook.Net.Commands/Builders/ModuleClassBuilder.cs
index f17b5652..aab36fa6 100644
--- a/src/Kook.Net.Commands/Builders/ModuleClassBuilder.cs
+++ b/src/Kook.Net.Commands/Builders/ModuleClassBuilder.cs
@@ -1,11 +1,10 @@
+using Kook.Commands.Builders;
using System;
-using System.Linq;
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
-using Kook.Commands.Builders;
-
namespace Kook.Commands;
internal static class ModuleClassBuilder
@@ -80,11 +79,11 @@ private static void BuildSubTypes(ModuleBuilder builder, IEnumerable s
{
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 @@ private static void BuildModule(ModuleBuilder builder, TypeInfo typeInfo, Comman
foreach (var method in validCommands)
{
- builder.AddCommand((command) =>
+ builder.AddCommand((command) =>
{
BuildCommand(command, typeInfo, method, service, services);
});
@@ -149,7 +148,7 @@ private static void BuildModule(ModuleBuilder builder, TypeInfo typeInfo, Comman
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 @@ private static void BuildCommand(CommandBuilder builder, TypeInfo typeInfo, Meth
int pos = 0, count = parameters.Length;
foreach (var paramInfo in parameters)
{
- builder.AddParameter((parameter) =>
+ builder.AddParameter((parameter) =>
{
BuildParameter(parameter, paramInfo, pos++, count, service, serviceprovider);
});
@@ -313,4 +312,4 @@ private static bool IsValidCommandDefinition(MethodInfo methodInfo)
!methodInfo.IsStatic &&
!methodInfo.IsGenericMethod;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/Builders/ParameterBuilder.cs b/src/Kook.Net.Commands/Builders/ParameterBuilder.cs
index e5dba641..c715b82f 100644
--- a/src/Kook.Net.Commands/Builders/ParameterBuilder.cs
+++ b/src/Kook.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 Kook.Commands.Builders;
public class ParameterBuilder
@@ -137,4 +136,4 @@ internal ParameterInfo Build(CommandInfo info)
return new ParameterInfo(this, info, Command.Module.Service);
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/CommandContext.cs b/src/Kook.Net.Commands/CommandContext.cs
index df401aa6..5d200f05 100644
--- a/src/Kook.Net.Commands/CommandContext.cs
+++ b/src/Kook.Net.Commands/CommandContext.cs
@@ -30,4 +30,4 @@ public CommandContext(IKookClient client, IUserMessage msg)
User = msg.Author;
Message = msg;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/CommandError.cs b/src/Kook.Net.Commands/CommandError.cs
index 0e180a91..1055f115 100644
--- a/src/Kook.Net.Commands/CommandError.cs
+++ b/src/Kook.Net.Commands/CommandError.cs
@@ -47,4 +47,4 @@ public enum CommandError
/// Thrown when the command is not successfully executed on runtime.
///
Unsuccessful
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/CommandException.cs b/src/Kook.Net.Commands/CommandException.cs
index b3bfb3df..c771968a 100644
--- a/src/Kook.Net.Commands/CommandException.cs
+++ b/src/Kook.Net.Commands/CommandException.cs
@@ -26,4 +26,4 @@ public CommandException(CommandInfo command, ICommandContext context, Exception
Command = command;
Context = context;
}
-}
\ No newline at end of file
+}
diff --git a/src/Kook.Net.Commands/CommandMatch.cs b/src/Kook.Net.Commands/CommandMatch.cs
index 3947fcb1..3197e944 100644
--- a/src/Kook.Net.Commands/CommandMatch.cs
+++ b/src/Kook.Net.Commands/CommandMatch.cs
@@ -25,4 +25,4 @@ public Task ExecuteAsync(ICommandContext context, IEnumerable