Add localizations#152
Draft
Sella-GH wants to merge 35 commits into
Draft
Conversation
Signed-off-by: Sellara <147769367+Sella-GH@users.noreply.github.com>
Signed-off-by: Sellara <147769367+Sella-GH@users.noreply.github.com>
Signed-off-by: Sellara <147769367+Sella-GH@users.noreply.github.com>
Comment on lines
+85
to
+89
| foreach (string excluded in excludedCommands) | ||
| { | ||
| if (fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase)) | ||
| return true; | ||
| } |
Check notice
Code scanning / CodeQL
Missed opportunity to use Where Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the issue, replace the foreach loop that checks for a matching excluded entry with a single LINQ expression using .Any(). Specifically, change:
foreach (string excluded in excludedCommands)
{
if (fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase))
return true;
}to:
if (excludedCommands.Any(excluded => fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase)))
return true;You may need to ensure that System.Linq is imported at the top of the file to allow usage of .Any(). No other logic or structure in the file needs to be changed.
Suggested changeset
1
src/AzzyBot.Bot/Localization/CommandLocalizer.cs
| @@ -5,6 +5,7 @@ | ||
| using System.Globalization; | ||
| using System.Resources; | ||
| using System.Threading.Tasks; | ||
| using System.Linq; | ||
| using DSharpPlus.Commands.Processors.SlashCommands.Localization; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| @@ -82,11 +83,8 @@ | ||
| ArgumentException.ThrowIfNullOrWhiteSpace(fullSymbolName); | ||
|
|
||
| string[] excludedCommands = ["core.stats"]; | ||
| foreach (string excluded in excludedCommands) | ||
| { | ||
| if (fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase)) | ||
| return true; | ||
| } | ||
| if (excludedCommands.Any(excluded => fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase))) | ||
| return true; | ||
|
|
||
| return false; | ||
| } |
Copilot is powered by AI and may make mistakes. Always verify output.
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
|
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




No description provided.