Skip to content

Commit

Permalink
Merge branch 'main' into dev/LocalizationSystem
Browse files Browse the repository at this point in the history
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
  • Loading branch information
Sella-GH authored Jan 2, 2025
2 parents 8466c89 + da21088 commit 542c940
Show file tree
Hide file tree
Showing 81 changed files with 231 additions and 54 deletions.
53 changes: 38 additions & 15 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ generated_code = true

# C# files
[*.cs]
# C# 10 features
csharp_style_namespace_declarations=file_scoped:warning

# New line preferences
csharp_new_line_before_open_brace = all
Expand Down Expand Up @@ -85,21 +83,45 @@ dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

# Code style defaults
csharp_using_directive_placement = outside_namespace:warning
dotnet_sort_system_directives_first = true
csharp_prefer_braces = when_multiline:warning
csharp_preserve_single_line_blocks = true:warning
csharp_preserve_single_line_statements = false:warning
csharp_prefer_static_anonymous_function = true:warning
csharp_prefer_static_local_function = true:warning
csharp_prefer_simple_using_statement = false:warning
csharp_prefer_simple_using_statement = true:warning
csharp_prefer_system_threading_lock = true:warning
csharp_preserve_single_line_blocks = true:warning
csharp_preserve_single_line_statements = false:warning
csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
csharp_style_namespace_declarations=file_scoped:warning
csharp_style_prefer_extended_property_pattern = true:warning
csharp_style_prefer_local_over_anonymous_function = true:warning
csharp_style_prefer_method_group_conversion = true:warning
csharp_style_prefer_null_check_over_type_check = true:warning
csharp_style_prefer_primary_constructors = true:warning
csharp_style_prefer_readonly_struct = true:warning
csharp_style_prefer_readonly_struct_member = true:warning
csharp_style_prefer_switch_expression = true:warning
csharp_style_prefer_top_level_statements = false:warning
csharp_style_prefer_tuple_swap = true:warning
csharp_style_prefer_utf8_string_literals = true:warning
csharp_style_unused_value_assignment_preference = discard_variable:warning
csharp_style_unused_value_expression_statement_preference = discard_variable:warning
csharp_using_directive_placement = outside_namespace:warning
dotnet_separate_import_directive_groups = true:warning
dotnet_sort_system_directives_first = true:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_namespace_match_folder = true:warning
dotnet_style_prefer_compound_assignment = true:warning
dotnet_style_prefer_foreach_explicit_cast_in_source = always:warning
dotnet_style_prefer_simplified_boolean_expressions = true:warning
dotnet_style_prefer_simplified_interpolation = true:warning
dotnet_style_readonly_field = true:warning
dotnet_style_require_accessibility_modifiers = true:warning

# Expression-level preferences
csharp_prefer_simple_default_expression = true:warning
dotnet_style_object_initializer = true:warning
dotnet_style_collection_initializer = true:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
Expand All @@ -108,8 +130,7 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_prefer_conditional_expression_over_assignment = true:warning
dotnet_style_prefer_conditional_expression_over_return = true:warning
dotnet_style_prefer_collection_expression = when_types_exactly_match
csharp_prefer_simple_default_expression = true:warning
dotnet_style_prefer_collection_expression = when_types_loosely_match:warning

# Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:warning
Expand All @@ -122,18 +143,21 @@ csharp_style_expression_bodied_lambdas = true:warning
csharp_style_expression_bodied_local_functions = true:warning

# Pattern matching
csharp_style_inlined_variable_declaration = true:warning
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_inlined_variable_declaration = true:warning
csharp_style_prefer_not_pattern = true:warning
csharp_style_prefer_pattern_matching = true:warning

# Null checking preferences
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning

# Other features
csharp_style_prefer_index_operator = false:warning
csharp_style_prefer_range_operator = false:warning
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_pattern_local_over_anonymous_function = false:warning
dotnet_code_quality_unused_parameters = all:warning

# Space preferences
csharp_space_after_cast = false
Expand Down Expand Up @@ -199,7 +223,6 @@ roslynator_blank_line_after_file_scoped_namespace_declaration = true
roslynator_blank_line_between_closing_brace_and_switch_section = true
roslynator_blank_line_between_single_line_accessors = false
roslynator_blank_line_between_switch_sections = include
roslynator_blank_line_between_using_directives = never
roslynator_block_braces_style = single_line_when_empty
roslynator_body_style = expression
roslynator_conditional_operator_condition_parentheses_style = include
Expand Down Expand Up @@ -265,7 +288,7 @@ dotnet_diagnostic.rcs0012.severity = none
dotnet_diagnostic.rcs0013.severity = none

## Add/remove blank line between using directives
dotnet_diagnostic.rcs0015.severity = warning
dotnet_diagnostic.rcs0015.severity = none

## Put attribute list on its own line
dotnet_diagnostic.rcs0016.severity = warning
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.0
### Dependencies
- Updated [NCronJob](https://github.com/NCronJob-Dev/NCronJob) to version 4.0.2

## 2.2.0 - 2024-12-23
### BREAKING CHANGES
- The settings file structure changed and will require a migration!
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageVersion Include="Lavalink4NET.DSharpPlus.Nightly" Version="4.0.26-preview.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageVersion Include="NCronJob" Version="3.3.8" />
<PackageVersion Include="NCronJob" Version="4.0.2" />
<PackageVersion Include="Npgsql" Version="9.0.2" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
<PackageVersion Include="NReco.Logging.File" Version="1.2.2" />
Expand Down
3 changes: 3 additions & 0 deletions src/AzzyBot.Bot/Commands/AdminCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AzzyBot.Bot.Commands.Autocompletes;
using AzzyBot.Bot.Commands.Choices;
using AzzyBot.Bot.Localization;
Expand All @@ -18,13 +19,15 @@
using AzzyBot.Core.Utilities;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands;
using DSharpPlus.Commands.ArgumentModifiers;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Commands.Processors.SlashCommands.Localization;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

using AzzyBot.Bot.Services;
using AzzyBot.Bot.Services.Modules;
using AzzyBot.Bot.Utilities.Records;
Expand All @@ -13,9 +14,11 @@
using AzzyBot.Core.Utilities.Encryption;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands.Autocompletes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;

using AzzyBot.Bot.Services;
using AzzyBot.Bot.Services.Modules;
using AzzyBot.Bot.Utilities.Records.AzuraCast;
Expand All @@ -13,9 +14,11 @@
using AzzyBot.Core.Utilities.Enums;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands.Autocompletes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AzzyBot.Bot.Services;
using AzzyBot.Bot.Services.Modules;
using AzzyBot.Bot.Utilities.Records.AzuraCast;
using AzzyBot.Core.Logging;
using AzzyBot.Core.Utilities.Encryption;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands.Autocompletes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;

using AzzyBot.Bot.Services;
using AzzyBot.Bot.Services.Modules;
using AzzyBot.Bot.Utilities.Records.AzuraCast;
Expand All @@ -12,9 +13,11 @@
using AzzyBot.Core.Utilities.Enums;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands.Autocompletes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

using AzzyBot.Bot.Services;
using AzzyBot.Bot.Services.Modules;
using AzzyBot.Bot.Utilities.Records.AzuraCast;
using AzzyBot.Core.Logging;
using AzzyBot.Core.Utilities.Encryption;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands.Autocompletes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using AzzyBot.Bot.Settings;
using AzzyBot.Bot.Utilities;
using AzzyBot.Bot.Utilities.Records;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;

using Microsoft.Extensions.Options;

namespace AzzyBot.Bot.Commands.Autocompletes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;

using AzzyBot.Core.Utilities;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;
Expand Down
3 changes: 3 additions & 0 deletions src/AzzyBot.Bot/Commands/Autocompletes/GuildsAutocomplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

using AzzyBot.Bot.Services;
using AzzyBot.Bot.Settings;

using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Commands.Processors.SlashCommands.ArgumentModifiers;
using DSharpPlus.Entities;

using Microsoft.Extensions.Options;

namespace AzzyBot.Bot.Commands.Autocompletes;
Expand Down
5 changes: 4 additions & 1 deletion src/AzzyBot.Bot/Commands/AzuraCastCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

using AzzyBot.Bot.Commands.Autocompletes;
using AzzyBot.Bot.Commands.Checks;
using AzzyBot.Bot.Commands.Choices;
Expand All @@ -25,6 +26,7 @@
using AzzyBot.Core.Utilities.Helpers;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands;
Expand All @@ -33,6 +35,7 @@
using DSharpPlus.EventArgs;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands;
Expand Down Expand Up @@ -872,7 +875,7 @@ public async ValueTask GetSongHistoryAsync
return;
}

IEnumerable<AzuraStationHistoryExportRecord> exportHistory = history.Select(h => new AzuraStationHistoryExportRecord() { Date = dateString, PlayedAt = Converter.ConvertFromUnixTime(h.PlayedAt), Song = h.Song, SongRequest = h.IsRequest, Streamer = h.Streamer, Playlist = h.Playlist }).Reverse().ToList();
IEnumerable<AzuraStationHistoryExportRecord> exportHistory = [.. history.Select(h => new AzuraStationHistoryExportRecord() { Date = dateString, PlayedAt = Converter.ConvertFromUnixTime(h.PlayedAt), Song = h.Song, SongRequest = h.IsRequest, Streamer = h.Streamer, Playlist = h.Playlist }).Reverse()];
string fileName = $"{ac.GuildId}-{ac.Id}-{acStation.Id}-{acStation.StationId}_SongHistory_{dateStringFile}.csv";
string filePath = await FileOperations.CreateCsvFileAsync(exportHistory, fileName);
await using FileStream fileStream = new(filePath, FileMode.Open, FileAccess.Read);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

using AzzyBot.Core.Logging;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands.Checks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;

using DSharpPlus.Commands.ContextChecks;

namespace AzzyBot.Bot.Commands.Checks;
Expand Down
5 changes: 4 additions & 1 deletion src/AzzyBot.Bot/Commands/Checks/AzuraCastDiscordPermCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

using AzzyBot.Bot.Utilities.Enums;
using AzzyBot.Core.Logging;
using AzzyBot.Data.Entities;
using AzzyBot.Data.Services;

using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities;

using Microsoft.Extensions.Logging;

namespace AzzyBot.Bot.Commands.Checks;
Expand Down Expand Up @@ -81,7 +84,7 @@ public class AzuraCastDiscordPermCheck(ILogger<AzuraCastDiscordPermCheck> logger
IEnumerable<DiscordRole> userRoles = context.Member.Roles;
foreach (AzuraCastDiscordPerm perm in attribute.Perms)
{
result = CheckPermission(perm, guildRoles, azuraCast, station, userRoles.ToList(), context.Command.FullName);
result = CheckPermission(perm, guildRoles, azuraCast, station, [.. userRoles], context.Command.FullName);
if (result is not null)
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;

using AzzyBot.Bot.Utilities.Enums;

using DSharpPlus.Commands.ContextChecks;

namespace AzzyBot.Bot.Commands.Checks;
Expand Down
Loading

0 comments on commit 542c940

Please sign in to comment.