This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
OctobotStealth/Commands/RemindCommand.cs
Octol1ttle a97341f9a9
Do not allow setting reminders without specifying a valid TimeSpan
Fixes #19

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-02-02 21:37:12 +05:00

34 lines
1.3 KiB
C#

using Boyfriend.Data;
namespace Boyfriend.Commands;
public sealed class RemindCommand : ICommand {
public string[] Aliases { get; } = { "remind", "reminder", "remindme", "напомни", "напомнить", "напоминание" };
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");
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,
ReminderText = reminderText,
ReminderChannel = cmd.Context.Channel.Id
});
cmd.ConfigWriteScheduled = true;
var feedback = string.Format(Messages.FeedbackReminderAdded, reminderOffset.ToUnixTimeSeconds().ToString());
cmd.Reply(feedback, ReplyEmojis.Reminder);
}
return Task.CompletedTask;
}
}