1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00

stashed changes my beloved

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2023-12-31 13:58:22 +03:00
parent 76e353ef66
commit 97d19973b5
Signed by: mctaylors
GPG key ID: 7181BEBE676903C1
2 changed files with 7 additions and 10 deletions

View file

@ -111,7 +111,7 @@ public class RemindCommandGroup : CommandGroup
/// <summary> /// <summary>
/// A slash command that schedules a reminder with the specified text. /// A slash command that schedules a reminder with the specified text.
/// </summary> /// </summary>
/// <param name="stringTimeSpan">The period of time which must pass before the reminder will be sent.</param> /// <param name="timeSpanString">The period of time which must pass before the reminder will be sent.</param>
/// <param name="text">The text of the reminder.</param> /// <param name="text">The text of the reminder.</param>
/// <returns>A feedback sending result which may or may not have succeeded.</returns> /// <returns>A feedback sending result which may or may not have succeeded.</returns>
[Command("remind")] [Command("remind")]
@ -122,7 +122,7 @@ public class RemindCommandGroup : CommandGroup
public async Task<Result> ExecuteReminderAsync( public async Task<Result> ExecuteReminderAsync(
[Description("After what period of time mention the reminder")] [Description("After what period of time mention the reminder")]
[Option("in")] [Option("in")]
string stringTimeSpan, string timeSpanString,
[Description("Reminder text")] [MaxLength(512)] [Description("Reminder text")] [MaxLength(512)]
string text) string text)
{ {
@ -146,7 +146,7 @@ public class RemindCommandGroup : CommandGroup
var data = await _guildData.GetData(guildId, CancellationToken); var data = await _guildData.GetData(guildId, CancellationToken);
Messages.Culture = GuildSettings.Language.Get(data.Settings); Messages.Culture = GuildSettings.Language.Get(data.Settings);
var parseResult = TimeSpanParser.TryParse(stringTimeSpan); var parseResult = TimeSpanParser.TryParse(timeSpanString);
if (!parseResult.IsDefined(out var timeSpan)) if (!parseResult.IsDefined(out var timeSpan))
{ {
var failedEmbed = new EmbedBuilder() var failedEmbed = new EmbedBuilder()

View file

@ -15,14 +15,11 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
private static readonly Regex Pattern = ParseRegex(); private static readonly Regex Pattern = ParseRegex();
/// <summary> /// <summary>
/// Parses <see cref="TimeSpan"/> from <see cref="string"/>. /// Parses a <see cref="TimeSpan"/> from the <paramref name="timeSpanString"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// Parsed <see cref="TimeSpan"/>. /// The parsed <see cref="TimeSpan"/>, or <see cref="ArgumentInvalidError"/> if parsing failed.
/// </returns> /// </returns>
/// <remarks>
/// If parse wasn't successful, <see cref="TimeSpanParser"/> will return <see cref="ArgumentInvalidError"/>.
/// </remarks>
public static Result<TimeSpan> TryParse(string timeSpanString) public static Result<TimeSpan> TryParse(string timeSpanString)
{ {
if (timeSpanString.StartsWith('-')) if (timeSpanString.StartsWith('-'))
@ -44,7 +41,7 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
return ParseFromRegex(matches); return ParseFromRegex(matches);
} }
private static TimeSpan ParseFromRegex(MatchCollection matches) private static Result<TimeSpan> ParseFromRegex(MatchCollection matches)
{ {
var timeSpan = TimeSpan.Zero; var timeSpan = TimeSpan.Zero;
@ -59,7 +56,7 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
if (!double.TryParse(groupValue, out var parsedGroupValue) || if (!double.TryParse(groupValue, out var parsedGroupValue) ||
!int.TryParse(groupValue, out var parsedIntegerValue)) !int.TryParse(groupValue, out var parsedIntegerValue))
{ {
return TimeSpan.Zero; return new ArgumentInvalidError(nameof(groupValue), "The input value encountered a parsing error.");
} }
var now = DateTimeOffset.UtcNow; var now = DateTimeOffset.UtcNow;