From 87dbb07dece13adbcfb8f19394506d5073f72f9b Mon Sep 17 00:00:00 2001
From: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Date: Sat, 12 Aug 2023 23:19:07 +0300
Subject: [PATCH] EventEarlyNotification timestamp bugfix and other changes
 (#84)

This PR fixes EventEarlyNotification timestamp not displaying correctly
and also has some other changes:
- Add xmldocs for `/settingslist`'s `page` option in
SettingsCommandGroup.cs
- Add option description for `index` for `/delreminder`
- Some corrections of grammatical errors in Messages.tt-ru.resx
- Fix `ArgumentOutOfRangeException` in `/settingslist` that appears if
the user uses a negative integer in `page`

---------

Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
---
 locale/Messages.tt-ru.resx                       |  8 ++++----
 src/Commands/RemindCommandGroup.cs               |  4 +++-
 src/Commands/SettingsCommandGroup.cs             |  7 +++++--
 .../Update/ScheduledEventUpdateService.cs        | 16 +++-------------
 4 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx
index 212ad16..ec1c886 100644
--- a/locale/Messages.tt-ru.resx
+++ b/locale/Messages.tt-ru.resx
@@ -253,11 +253,11 @@
     <value>оъмъомоъемъъео((((</value>
   </data>
     <data name="EventCancelled" xml:space="preserve">
-    <value>движуха "{0}" отменен!</value>
-  </data>
+        <value>движуха "{0}" отменена!</value>
+    </data>
     <data name="EventCompleted" xml:space="preserve">
-    <value>движуха "{0}" завершен!</value>
-  </data>
+        <value>движуха "{0}" завершена!</value>
+    </data>
     <data name="Ever" xml:space="preserve">
     <value>всегда</value>
   </data>
diff --git a/src/Commands/RemindCommandGroup.cs b/src/Commands/RemindCommandGroup.cs
index d5110e0..8e8b820 100644
--- a/src/Commands/RemindCommandGroup.cs
+++ b/src/Commands/RemindCommandGroup.cs
@@ -153,7 +153,9 @@ public class RemindCommandGroup : CommandGroup
     [RequireContext(ChannelContext.Guild)]
     [UsedImplicitly]
     public async Task<Result> ExecuteDeleteReminderAsync(
-        [MinValue(0)] int index)
+        [Description("Index of reminder to delete")]
+        [MinValue(0)]
+        int index)
     {
         if (!_context.TryGetContextIDs(out var guildId, out _, out var userId))
         {
diff --git a/src/Commands/SettingsCommandGroup.cs b/src/Commands/SettingsCommandGroup.cs
index ad0d7f4..61be402 100644
--- a/src/Commands/SettingsCommandGroup.cs
+++ b/src/Commands/SettingsCommandGroup.cs
@@ -62,8 +62,9 @@ public class SettingsCommandGroup : CommandGroup
     }
 
     /// <summary>
-    ///     A slash command that lists current per-guild GuildSettings.
+    ///     A slash command that sends a page from the list of current GuildSettings.
     /// </summary>
+    /// <param name="page">The number of the page to send.</param>
     /// <returns>
     ///     A feedback sending result which may or may not have succeeded.
     /// </returns>
@@ -75,7 +76,9 @@ public class SettingsCommandGroup : CommandGroup
     [Description("Shows settings list for this server")]
     [UsedImplicitly]
     public async Task<Result> ExecuteSettingsListAsync(
-        [Description("Settings list page")] int page)
+        [Description("Settings list page")]
+        [MinValue(1)]
+        int page)
     {
         if (!_context.TryGetContextIDs(out var guildId, out _, out _))
         {
diff --git a/src/Services/Update/ScheduledEventUpdateService.cs b/src/Services/Update/ScheduledEventUpdateService.cs
index faa8bab..24b68da 100644
--- a/src/Services/Update/ScheduledEventUpdateService.cs
+++ b/src/Services/Update/ScheduledEventUpdateService.cs
@@ -19,18 +19,15 @@ public sealed class ScheduledEventUpdateService : BackgroundService
     private readonly IDiscordRestGuildScheduledEventAPI _eventApi;
     private readonly GuildDataService _guildData;
     private readonly ILogger<ScheduledEventUpdateService> _logger;
-    private readonly IDiscordRestUserAPI _userApi;
     private readonly UtilityService _utility;
 
     public ScheduledEventUpdateService(IDiscordRestChannelAPI channelApi, IDiscordRestGuildScheduledEventAPI eventApi,
-        GuildDataService guildData, ILogger<ScheduledEventUpdateService> logger, IDiscordRestUserAPI userApi,
-        UtilityService utility)
+        GuildDataService guildData, ILogger<ScheduledEventUpdateService> logger, UtilityService utility)
     {
         _channelApi = channelApi;
         _eventApi = eventApi;
         _guildData = guildData;
         _logger = logger;
-        _userApi = userApi;
         _utility = utility;
     }
 
@@ -345,12 +342,6 @@ public sealed class ScheduledEventUpdateService : BackgroundService
     private async Task<Result> SendEarlyEventNotificationAsync(
         IGuildScheduledEvent scheduledEvent, GuildData data, CancellationToken ct)
     {
-        var currentUserResult = await _userApi.GetCurrentUserAsync(ct);
-        if (!currentUserResult.IsDefined(out var currentUser))
-        {
-            return Result.FromError(currentUserResult);
-        }
-
         var contentResult = await _utility.GetEventNotificationMentions(
             scheduledEvent, data.Settings, ct);
         if (!contentResult.IsDefined(out var content))
@@ -359,11 +350,10 @@ public sealed class ScheduledEventUpdateService : BackgroundService
         }
 
         var earlyResult = new EmbedBuilder()
-            .WithSmallTitle(
+            .WithDescription(
                 string.Format(Messages.EventEarlyNotification, scheduledEvent.Name,
-                    Markdown.Timestamp(scheduledEvent.ScheduledStartTime, TimestampStyle.RelativeTime)), currentUser)
+                    Markdown.Timestamp(scheduledEvent.ScheduledStartTime, TimestampStyle.RelativeTime)))
             .WithColour(ColorsList.Default)
-            .WithCurrentTimestamp()
             .Build();
 
         if (!earlyResult.IsDefined(out var earlyBuilt))