1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-30 02:59:54 +03:00

Do not allow setting reminders without specifying a valid TimeSpan

Fixes #19

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-02-02 21:37:12 +05:00
parent 8f9c71edf1
commit a97341f9a9
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
7 changed files with 39 additions and 15 deletions

View file

@ -8,9 +8,14 @@ public sealed class RemindCommand : ICommand {
public Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
// TODO: actually make this good
var remindIn = CommandProcessor.GetTimeSpan(args, 0);
if (remindIn.TotalSeconds < 1) {
cmd.Reply(Messages.InvalidRemindIn, ReplyEmojis.InvalidArgument);
return Task.CompletedTask;
}
var reminderText = cmd.GetRemaining(cleanArgs, 1, "ReminderText");
var reminderOffset = DateTimeOffset.Now.Add(remindIn);
if (reminderText is not null) {
var reminderOffset = DateTimeOffset.Now.Add(remindIn);
GuildData.Get(cmd.Context.Guild).MemberData[cmd.Context.User.Id].Reminders.Add(
new Reminder {
RemindAt = reminderOffset,