From fe22ba4f32940f8c7ea612b2051b2bec9d34df09 Mon Sep 17 00:00:00 2001 From: Ske Date: Sun, 4 Aug 2019 13:43:56 +0200 Subject: [PATCH] Truncate member profile in long system list --- PluralKit.Bot/Commands/SystemCommands.cs | 5 +++-- PluralKit.Core/Utils.cs | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/PluralKit.Bot/Commands/SystemCommands.cs b/PluralKit.Bot/Commands/SystemCommands.cs index f7c3720d..e77fc485 100644 --- a/PluralKit.Bot/Commands/SystemCommands.cs +++ b/PluralKit.Bot/Commands/SystemCommands.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using Discord; using Discord.Commands; +using Humanizer; using NodaTime; using NodaTime.Text; using NodaTime.TimeZones; @@ -174,7 +175,7 @@ namespace PluralKit.Bot.Commands var embedTitle = system.Name != null ? $"Members of {system.Name} (`{system.Hid}`)" : $"Members of `{system.Hid}`"; await Context.Paginate( members.OrderBy(m => m.Name).ToList(), - 10, + 5, embedTitle, (eb, ms) => { foreach (var m in ms) { @@ -183,7 +184,7 @@ namespace PluralKit.Bot.Commands if (m.Birthday != null) profile += $"\n**Birthdate**: {m.BirthdayString}"; if (m.Prefix != null || m.Suffix != null) profile += $"\n**Proxy tags**: {m.ProxyString}"; if (m.Description != null) profile += $"\n\n{m.Description}"; - eb.AddField(m.Name, profile); + eb.AddField(m.Name, profile.Truncate(1024)); } } ); diff --git a/PluralKit.Core/Utils.cs b/PluralKit.Core/Utils.cs index 49bf0842..a9609d15 100644 --- a/PluralKit.Core/Utils.cs +++ b/PluralKit.Core/Utils.cs @@ -41,11 +41,6 @@ namespace PluralKit return Convert.ToBase64String(buf); } - public static string Truncate(this string str, int maxLength, string ellipsis = "...") { - if (str.Length < maxLength) return str; - return str.Substring(0, maxLength - ellipsis.Length) + ellipsis; - } - public static bool IsLongerThan(this string str, int length) { if (str != null) return str.Length > length;