2023-01-18 17:39:24 +03:00
|
|
|
|
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);
|
2023-02-02 19:37:12 +03:00
|
|
|
|
if (remindIn.TotalSeconds < 1) {
|
|
|
|
|
cmd.Reply(Messages.InvalidRemindIn, ReplyEmojis.InvalidArgument);
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-18 17:39:24 +03:00
|
|
|
|
var reminderText = cmd.GetRemaining(cleanArgs, 1, "ReminderText");
|
2023-02-02 07:48:18 +03:00
|
|
|
|
if (reminderText is not null) {
|
2023-02-02 19:37:12 +03:00
|
|
|
|
var reminderOffset = DateTimeOffset.Now.Add(remindIn);
|
2023-02-02 07:48:18 +03:00
|
|
|
|
GuildData.Get(cmd.Context.Guild).MemberData[cmd.Context.User.Id].Reminders.Add(
|
|
|
|
|
new Reminder {
|
|
|
|
|
RemindAt = reminderOffset,
|
|
|
|
|
ReminderText = reminderText,
|
|
|
|
|
ReminderChannel = cmd.Context.Channel.Id
|
|
|
|
|
});
|
2023-01-18 17:39:24 +03:00
|
|
|
|
|
2023-02-02 07:48:18 +03:00
|
|
|
|
cmd.ConfigWriteScheduled = true;
|
|
|
|
|
|
|
|
|
|
var feedback = string.Format(Messages.FeedbackReminderAdded, reminderOffset.ToUnixTimeSeconds().ToString());
|
|
|
|
|
cmd.Reply(feedback, ReplyEmojis.Reminder);
|
|
|
|
|
}
|
2023-01-18 17:39:24 +03:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|