From 62709d927be7dcbd19ffe32d03c2a6e77ccf88b9 Mon Sep 17 00:00:00 2001 From: Macintxsh <95250141+mctaylors@users.noreply.github.com> Date: Sun, 17 Mar 2024 16:46:53 +0300 Subject: [PATCH] Add time format example to the description of commands that use TimeSpan. (#267) This PR was made to help users who are trying /remind for the first time by showing an example of the correct time format in the description. --------- Signed-off-by: Macintxsh <95250141+mctaylors@users.noreply.github.com> Signed-off-by: mctaylors --- locale/Messages.resx | 3 +++ locale/Messages.ru.resx | 3 +++ locale/Messages.tt-ru.resx | 3 +++ src/Commands/BanCommandGroup.cs | 4 +++- src/Commands/MuteCommandGroup.cs | 3 ++- src/Commands/RemindCommandGroup.cs | 4 +++- src/Commands/ToolsCommandGroup.cs | 1 + src/Messages.Designer.cs | 6 ++++++ 8 files changed, 24 insertions(+), 3 deletions(-) diff --git a/locale/Messages.resx b/locale/Messages.resx index b881996..ca48fba 100644 --- a/locale/Messages.resx +++ b/locale/Messages.resx @@ -654,4 +654,7 @@ Very doubtful + + Example of a valid input: `1h30m` + diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx index cb318cd..7423347 100644 --- a/locale/Messages.ru.resx +++ b/locale/Messages.ru.resx @@ -654,4 +654,7 @@ Весьма сомнительно + + Пример правильного ввода: `1ч30м` + diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx index f0b80a7..dc3bb6f 100644 --- a/locale/Messages.tt-ru.resx +++ b/locale/Messages.tt-ru.resx @@ -654,4 +654,7 @@ чот сомневаюсь + + правильно пишут так: `1h30m` + diff --git a/src/Commands/BanCommandGroup.cs b/src/Commands/BanCommandGroup.cs index 6dbf9b9..c350729 100644 --- a/src/Commands/BanCommandGroup.cs +++ b/src/Commands/BanCommandGroup.cs @@ -76,7 +76,8 @@ public class BanCommandGroup : CommandGroup [Description("User to ban")] IUser target, [Description("Ban reason")] [MaxLength(256)] string reason, - [Description("Ban duration")] string? duration = null) + [Description("Ban duration (e.g. 1h30m)")] + string? duration = null) { if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId)) { @@ -116,6 +117,7 @@ public class BanCommandGroup : CommandGroup { var failedEmbed = new EmbedBuilder() .WithSmallTitle(Messages.InvalidTimeSpan, bot) + .WithDescription(Messages.TimeSpanExample) .WithColour(ColorsList.Red) .Build(); diff --git a/src/Commands/MuteCommandGroup.cs b/src/Commands/MuteCommandGroup.cs index 788eb2c..c2542e8 100644 --- a/src/Commands/MuteCommandGroup.cs +++ b/src/Commands/MuteCommandGroup.cs @@ -73,7 +73,7 @@ public class MuteCommandGroup : CommandGroup [Description("Member to mute")] IUser target, [Description("Mute reason")] [MaxLength(256)] string reason, - [Description("Mute duration")] [Option("duration")] + [Description("Mute duration (e.g. 1h30m)")] [Option("duration")] string stringDuration) { if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId)) @@ -111,6 +111,7 @@ public class MuteCommandGroup : CommandGroup { var failedEmbed = new EmbedBuilder() .WithSmallTitle(Messages.InvalidTimeSpan, bot) + .WithDescription(Messages.TimeSpanExample) .WithColour(ColorsList.Red) .Build(); diff --git a/src/Commands/RemindCommandGroup.cs b/src/Commands/RemindCommandGroup.cs index c270f30..f9c006e 100644 --- a/src/Commands/RemindCommandGroup.cs +++ b/src/Commands/RemindCommandGroup.cs @@ -120,7 +120,7 @@ public class RemindCommandGroup : CommandGroup [RequireContext(ChannelContext.Guild)] [UsedImplicitly] public async Task ExecuteReminderAsync( - [Description("After what period of time mention the reminder")] + [Description("After what period of time mention the reminder (e.g. 1h30m)")] [Option("in")] string timeSpanString, [Description("Reminder text")] [MaxLength(512)] @@ -151,6 +151,7 @@ public class RemindCommandGroup : CommandGroup { var failedEmbed = new EmbedBuilder() .WithSmallTitle(Messages.InvalidTimeSpan, bot) + .WithDescription(Messages.TimeSpanExample) .WithColour(ColorsList.Red) .Build(); @@ -264,6 +265,7 @@ public class RemindCommandGroup : CommandGroup { var failedEmbed = new EmbedBuilder() .WithSmallTitle(Messages.InvalidTimeSpan, bot) + .WithDescription(Messages.TimeSpanExample) .WithColour(ColorsList.Red) .Build(); diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs index 3c16232..ea91e1e 100644 --- a/src/Commands/ToolsCommandGroup.cs +++ b/src/Commands/ToolsCommandGroup.cs @@ -461,6 +461,7 @@ public class ToolsCommandGroup : CommandGroup { var failedEmbed = new EmbedBuilder() .WithSmallTitle(Messages.InvalidTimeSpan, bot) + .WithDescription(Messages.TimeSpanExample) .WithColour(ColorsList.Red) .Build(); diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs index 9597bcd..ca460cf 100644 --- a/src/Messages.Designer.cs +++ b/src/Messages.Designer.cs @@ -1178,5 +1178,11 @@ namespace Octobot { return ResourceManager.GetString("EightBallNegative5", resourceCulture); } } + + internal static string TimeSpanExample { + get { + return ResourceManager.GetString("TimeSpanExample", resourceCulture); + } + } } }