feat: ignore user commands

This commit is contained in:
sam 2024-10-29 00:06:39 +01:00
parent a50a8567dd
commit b52df95b65
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
4 changed files with 143 additions and 3 deletions

View file

@ -44,4 +44,28 @@ public static class DiscordUtils
description,
new Embed(Title: title, Colour: Purple)
);
public static List<Embed> PaginateStrings(
IEnumerable<string> strings,
Optional<string> title = default,
int stringsPerPage = 20
)
{
var pages = strings.ToArray().Split(stringsPerPage);
return pages
.Select(p => new Embed(
Title: title,
Colour: Purple,
Description: string.Join("\n", p.Select((row, i) => $"{i + 1}. {row}"))
))
.ToList();
}
private static IEnumerable<IEnumerable<T>> Split<T>(this T[] arr, int size)
{
for (var i = 0; i < arr.Length / size + 1; i++)
{
yield return arr.Skip(i * size).Take(size);
}
}
}