Skip to content

Commit

Permalink
Applies code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gehongyan committed Feb 14, 2023
1 parent f6bcc89 commit bff75ed
Show file tree
Hide file tree
Showing 640 changed files with 4,106 additions and 3,816 deletions.
113 changes: 113 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Kook.Net.Samples.ReactionRoleBot.Enums;
using Kook.Net.Samples.ReactionRoleBot.Enums;

namespace Kook.Net.Samples.ReactionRoleBot.Configurations;

Expand All @@ -18,7 +18,7 @@ public class KookBotConfigurations
/// 角色ID列表
/// </summary>
public KookRoles Roles { get; init; }

/// <summary>
/// KOOK Bot运行环境
/// </summary>
Expand All @@ -33,4 +33,4 @@ public class KookChannels
public class KookRoles
{
public ulong DeveloperRoleId { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;

namespace Kook.Net.Samples.ReactionRoleBot.Enums;

Expand All @@ -15,4 +15,4 @@ public enum BotEnvironment
/// </summary>
[Description("生产")]
Production,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ public Task StopAsync(CancellationToken cancellationToken)
_logger.Fatal("Kook Client Stopped!");
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ public partial class KookBotClientExtension
{
private async Task ProcessReactionRoleAdd(Cacheable<IUserMessage, Guid> message, Cacheable<IMessageChannel, ulong> 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();
Expand All @@ -24,21 +26,23 @@ private async Task ProcessReactionRoleAdd(Cacheable<IUserMessage, Guid> 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<IUserMessage, Guid> message, Cacheable<IMessageChannel, ulong> 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();
Expand All @@ -51,10 +55,10 @@ private async Task ProcessReactionRoleRemove(Cacheable<IUserMessage, Guid> 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);
}

Expand All @@ -69,4 +73,4 @@ private async Task SendReactionCard()
.SendCardAsync(builder.Build()).ConfigureAwait(false);
await _kookSocketClient.Rest.AddReactionAsync(response.Id, Emoji.Parse(":computer:"));
}
}
}
6 changes: 3 additions & 3 deletions samples/Kook.Net.Samples.ReactionRoleBot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Kook;
using Kook;
using Kook.Net.Samples.ReactionRoleBot.Configurations;
using Kook.Net.Samples.ReactionRoleBot.Extensions;
using Kook.WebSocket;
Expand All @@ -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)
Expand Down Expand Up @@ -72,4 +72,4 @@ private static void ConfigureServices(HostBuilderContext hostContext, IServiceCo

.AddHttpClient();
}
}
}
6 changes: 3 additions & 3 deletions samples/Kook.Net.Samples.SimpleBot/Program.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -102,4 +102,4 @@ public async Task MainAsync()
await _client.StartAsync();
await Task.Delay(Timeout.Infinite);
}
}
}
12 changes: 6 additions & 6 deletions samples/Kook.Net.Samples.TextCommands/Modules/PublicModule.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
}

Expand All @@ -92,4 +92,4 @@ public async Task CreateChannel()
IReadOnlyCollection<uint> readOnlyCollection = guildUserAsync.RoleIds;
}

}
}
2 changes: 1 addition & 1 deletion samples/Kook.Net.Samples.TextCommands/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ private ServiceProvider ConfigureServices()
.AddSingleton<PictureService>()
.BuildServiceProvider();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public async Task<Stream> GetCatPictureAsync()
var resp = await _http.GetAsync("https://cataas.com/cat");
return await resp.Content.ReadAsStreamAsync();
}
}
}
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/AliasAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public AliasAttribute(params string[] aliases)
{
Aliases = aliases;
}
}
}
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/CommandAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public CommandAttribute(string text, bool ignoreExtraArgs)
Text = text;
IgnoreExtraArgs = ignoreExtraArgs;
}
}
}
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/DontAutoLoadAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ namespace Kook.Commands;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class DontAutoLoadAttribute : Attribute
{
}
}
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/DontInjectAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ namespace Kook.Commands;
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class DontInjectAttribute : Attribute
{
}
}
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/GroupAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public GroupAttribute(string prefix)
{
Prefix = prefix;
}
}
}
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/NameAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public NameAttribute(string text)
{
Text = text;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ namespace Kook.Commands;
/// as a collection of named arguments matching to its properties.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class NamedArgumentTypeAttribute : Attribute { }
public sealed class NamedArgumentTypeAttribute : Attribute { }
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public abstract class ParameterPreconditionAttribute : Attribute
/// <param name="value">The raw value of the parameter.</param>
/// <param name="services">The service collection used for dependency injection.</param>
public abstract Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, ParameterInfo parameter, object value, IServiceProvider services);
}
}
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/PreconditionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public abstract class PreconditionAttribute : Attribute
/// <param name="command">The command being executed.</param>
/// <param name="services">The service collection used for dependency injection.</param>
public abstract Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services);
}
}
Loading

0 comments on commit bff75ed

Please sign in to comment.