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

This commit is contained in:
Toastie 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;
case "music":
return strs.module_description_music;
case "nsfw":
return strs.module_description_nsfw;
case "permissions":
return strs.module_description_permissions;
case "xp":
@ -211,8 +209,6 @@ public sealed partial class Help : EllieModule<HelpService>
return "💰";
case "music":
return "🎶";
case "nsfw":
return "😳";
case "permissions":
return "🚓";
case "xp":

View file

@ -9,8 +9,8 @@ public sealed partial class Replacer
private readonly IEnumerable<RegexReplacementInfo> _regexReps;
private readonly object[] _inputData;
[GeneratedRegex(@"\%[\p{L}\p{N}\._]*[\p{L}\p{N}]+[\p{L}\p{N}\._]*\%")]
private static partial Regex TokenExtractionRegex();
// [GeneratedRegex(@"\%[\p{L}\p{N}\._]*[\p{L}\p{N}]+[\p{L}\p{N}\._]*\%")]
// private static partial Regex TokenExtractionRegex();
public Replacer(IEnumerable<ReplacementInfo> reps, IEnumerable<RegexReplacementInfo> regexReps, object[] inputData)
{
@ -24,10 +24,10 @@ public sealed partial class Replacer
if (string.IsNullOrWhiteSpace(input))
return input;
var matches = TokenExtractionRegex().IsMatch(input);
// var matches = TokenExtractionRegex().IsMatch(input);
if (matches)
{
// if (matches)
// {
foreach (var rep in _reps)
{
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);
}
}
}
// }
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
{
Color = e.Color
}).WhenAll(),
})
.WhenAll(),
Content = await ReplaceAsync(embedArr.Content)
};
private async ValueTask<SmartPlainText> ReplaceAsync(SmartPlainText plain)
=> 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
{
@ -123,7 +125,8 @@ public sealed partial class Replacer
Name = await ReplaceAsync(f.Name),
Value = await ReplaceAsync(f.Value),
Inline = f.Inline
}) ?? []),
})
?? []),
Footer = embedData.Footer is null
? null
: new()