Fixed some string replacements not working (fixed default help string). Removed some references to nsfw stuff

This commit is contained in:
Toastie (DCS Team) 2024-09-14 00:49:35 +12:00
parent 892eed4196
commit 81a6171526
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
2 changed files with 23 additions and 24 deletions

View file

@ -175,8 +175,6 @@ public sealed partial class Help : EllieModule<HelpService>
return strs.module_description_gambling; return strs.module_description_gambling;
case "music": case "music":
return strs.module_description_music; return strs.module_description_music;
case "nsfw":
return strs.module_description_nsfw;
case "permissions": case "permissions":
return strs.module_description_permissions; return strs.module_description_permissions;
case "xp": case "xp":
@ -211,8 +209,6 @@ public sealed partial class Help : EllieModule<HelpService>
return "💰"; return "💰";
case "music": case "music":
return "🎶"; return "🎶";
case "nsfw":
return "😳";
case "permissions": case "permissions":
return "🚓"; return "🚓";
case "xp": case "xp":

View file

@ -9,8 +9,8 @@ public sealed partial class Replacer
private readonly IEnumerable<RegexReplacementInfo> _regexReps; private readonly IEnumerable<RegexReplacementInfo> _regexReps;
private readonly object[] _inputData; private readonly object[] _inputData;
[GeneratedRegex(@"\%[\p{L}\p{N}\._]*[\p{L}\p{N}]+[\p{L}\p{N}\._]*\%")] // [GeneratedRegex(@"\%[\p{L}\p{N}\._]*[\p{L}\p{N}]+[\p{L}\p{N}\._]*\%")]
private static partial Regex TokenExtractionRegex(); // private static partial Regex TokenExtractionRegex();
public Replacer(IEnumerable<ReplacementInfo> reps, IEnumerable<RegexReplacementInfo> regexReps, object[] inputData) public Replacer(IEnumerable<ReplacementInfo> reps, IEnumerable<RegexReplacementInfo> regexReps, object[] inputData)
{ {
@ -24,10 +24,10 @@ public sealed partial class Replacer
if (string.IsNullOrWhiteSpace(input)) if (string.IsNullOrWhiteSpace(input))
return input; return input;
var matches = TokenExtractionRegex().IsMatch(input); // var matches = TokenExtractionRegex().IsMatch(input);
if (matches) // if (matches)
{ // {
foreach (var rep in _reps) foreach (var rep in _reps)
{ {
if (input.Contains(rep.Token, StringComparison.InvariantCulture)) if (input.Contains(rep.Token, StringComparison.InvariantCulture))
@ -36,7 +36,7 @@ public sealed partial class Replacer
input = input.Replace(rep.Token, await rep.GetValueAsync(objs), StringComparison.InvariantCulture); input = input.Replace(rep.Token, await rep.GetValueAsync(objs), StringComparison.InvariantCulture);
} }
} }
} // }
foreach (var rep in _regexReps) foreach (var rep in _regexReps)
{ {
@ -93,14 +93,16 @@ public sealed partial class Replacer
Embeds = await embedArr.Embeds.Map(async e => await ReplaceAsync(e) with Embeds = await embedArr.Embeds.Map(async e => await ReplaceAsync(e) with
{ {
Color = e.Color Color = e.Color
}).WhenAll(), })
.WhenAll(),
Content = await ReplaceAsync(embedArr.Content) Content = await ReplaceAsync(embedArr.Content)
}; };
private async ValueTask<SmartPlainText> ReplaceAsync(SmartPlainText plain) private async ValueTask<SmartPlainText> ReplaceAsync(SmartPlainText plain)
=> await ReplaceAsync(plain.Text); => await ReplaceAsync(plain.Text);
private async Task<T> ReplaceAsync<T>(T embedData) where T : SmartEmbedTextBase, new() private async Task<T> ReplaceAsync<T>(T embedData)
where T : SmartEmbedTextBase, new()
{ {
var newEmbedData = new T var newEmbedData = new T
{ {
@ -123,7 +125,8 @@ public sealed partial class Replacer
Name = await ReplaceAsync(f.Name), Name = await ReplaceAsync(f.Name),
Value = await ReplaceAsync(f.Value), Value = await ReplaceAsync(f.Value),
Inline = f.Inline Inline = f.Inline
}) ?? []), })
?? []),
Footer = embedData.Footer is null Footer = embedData.Footer is null
? null ? null
: new() : new()