From 6a2fed4571da3419c1a5ad0aca841fd2f28e30f2 Mon Sep 17 00:00:00 2001 From: Macintosh II Date: Tue, 3 Oct 2023 00:45:59 +0300 Subject: [PATCH] Use TimestampStyles Signed-off-by: Macintosh II --- src/Commands/ToolsCommandGroup.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs index 49027c5..8ba3dda 100644 --- a/src/Commands/ToolsCommandGroup.cs +++ b/src/Commands/ToolsCommandGroup.cs @@ -324,9 +324,9 @@ public class ToolsCommandGroup : CommandGroup private async Task SendRandomNumberAsync(TimeSpan? offset, IUser user, CancellationToken ct) { - var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds().ToString(); + var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds(); - var description = new StringBuilder().Append("# ").AppendLine(timestamp); + var description = new StringBuilder().Append("# ").AppendLine(timestamp.ToString()); if (offset is not null) { @@ -334,11 +334,21 @@ public class ToolsCommandGroup : CommandGroup Messages.TimestampOffset, Markdown.InlineCode(offset.ToString() ?? string.Empty))).AppendLine(); } - string[] options = { "d", "D", "t", "T", "f", "F", "R" }; - foreach (var option in options) + TimestampStyle[] allStyles = { - description.Append("- ").Append(Markdown.InlineCode($"")) - .Append(" — ").AppendLine($""); + TimestampStyle.ShortDate, + TimestampStyle.LongDate, + TimestampStyle.ShortTime, + TimestampStyle.LongTime, + TimestampStyle.ShortDateTime, + TimestampStyle.LongDateTime, + TimestampStyle.RelativeTime + }; + + foreach (var style in allStyles) + { + description.Append("- ").Append(Markdown.InlineCode(Markdown.Timestamp(timestamp, style))) + .Append(" — ").AppendLine(Markdown.Timestamp(timestamp, style)); } var embed = new EmbedBuilder().WithSmallTitle(