-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ Lot of analyser fixes #399
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,15 +33,15 @@ public ModerationCommands(IWarningService warningService, ILogger<ModerationComm | |
public async Task WarnMenuAsync(ContextMenuContext ctx) | ||
{ | ||
string modalId = $"warn-{ctx.User.Id}-{ctx.TargetUser.Id}"; | ||
string reasonId = "id-reason"; | ||
const string reasonId = "id-reason"; | ||
|
||
var response = new DiscordInteractionResponseBuilder() | ||
.WithTitle($"New Warning for {ctx.TargetMember.DisplayName}") | ||
.WithCustomId(modalId) | ||
.AddComponents(new TextInputComponent("Reason:", reasonId, required: true)); | ||
await ctx.CreateResponseAsync(InteractionResponseType.Modal, response); | ||
|
||
var numberOfWarnings = await _warningService.GetNumberOfWarnings(ctx.TargetUser.Id); | ||
int numberOfWarnings = await _warningService.GetNumberOfWarnings(ctx.TargetUser.Id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same goes here link |
||
|
||
var interactivity = ctx.Client.GetInteractivity(); | ||
var modalReason = await interactivity.WaitForModalAsync(modalId, TimeSpan.FromMinutes(10)); | ||
|
@@ -104,9 +104,9 @@ await buttonResponse.Result.Interaction.CreateResponseAsync(InteractionResponseT | |
[SlashCommand("show", "Show moderation entry with provided Id.")] | ||
public async Task ShowCommandAsync( | ||
InteractionContext ctx, | ||
[Option("Id", "Id of the entry to show")] long entryid) | ||
[Option("Id", "Id of the entry to show")] long entryId) | ||
{ | ||
Warning? warning = await _warningService.GetWarningAsync((int) entryid); | ||
Warning? warning = await _warningService.GetWarningAsync((int) entryId); | ||
|
||
if (warning is null) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using DSharpPlus.Entities; | ||
using DSharpPlus.Exceptions; | ||
|
@@ -36,26 +35,29 @@ public static string RemoveDiscordMentions( | |
private static async Task<string> MentionEvaluateAsync(Match match, DiscordGuild? guild) | ||
{ | ||
// Invalidate ID pings, replacing them with their name (only in guilds) | ||
if (guild is not null && match.Groups.TryGetValue("2", out Group? idMention) && idMention.Value != "") | ||
if (guild is null || !match.Groups.TryGetValue("2", out Group? idMention) || idMention.Value == "") | ||
{ | ||
ulong snowflakeId = ulong.Parse(idMention.Value); | ||
return match.Value.Replace("@", | ||
"@" + char.ConvertFromUtf32(int.Parse("200b", System.Globalization.NumberStyles.HexNumber))); | ||
} | ||
|
||
if (match.Groups.TryGetValue("1", out Group? idType) && idType.Value == "&") | ||
{ | ||
DiscordRole mentionedRole = guild.GetRole(snowflakeId); | ||
if (mentionedRole is not null) | ||
return mentionedRole.Name.RemoveDiscordMentions(); | ||
} | ||
else | ||
ulong snowflakeId = ulong.Parse(idMention.Value); | ||
|
||
if (match.Groups.TryGetValue("1", out Group? idType) && idType.Value == "&") | ||
{ | ||
DiscordRole mentionedRole = guild.GetRole(snowflakeId); | ||
if (mentionedRole is not null) | ||
return mentionedRole.Name.RemoveDiscordMentions(); | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
try | ||
{ | ||
DiscordMember mentionedMember = await guild.GetMemberAsync(snowflakeId); | ||
return mentionedMember.DisplayName.RemoveDiscordMentions(); | ||
} | ||
catch (NotFoundException) | ||
{} | ||
DiscordMember mentionedMember = await guild.GetMemberAsync(snowflakeId); | ||
return mentionedMember.DisplayName.RemoveDiscordMentions(); | ||
} | ||
catch (NotFoundException) | ||
{} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if this change increases readability. There is also duplicite code now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Github changed it... This review was for the changes in the whole file StringExtensions.cs |
||
|
||
// Invalidate @everyone, @here, or pings which have correct ID format, but no name was found for them | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,7 +127,7 @@ public async Task DeleteAllUnusedVoiceChannelsAsync() | |
private string? ConvertStringToValidState(string? input, string? defaultValue = null) | ||
{ | ||
input = Regex.Replace(input ?? "", @"\p{C}+", string.Empty); | ||
return input.Trim().Length == 0 ? defaultValue : input.Substring(0, Math.Min(input.Length, 30)); | ||
return input.Trim().Length == 0 ? defaultValue : input[..Math.Min(input.Length, 30)]; | ||
Comment on lines
129
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really cool. Feels like python :D |
||
} | ||
|
||
private async Task EditChannelAsync(bool isEdit, DiscordChannel? channel, string? name, long? limit, | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You marked this change as inconsistent in PR #317 (here)