rework ReminderModule
This commit is contained in:
25
Budet-cho-bot/Utility.cs
Normal file
25
Budet-cho-bot/Utility.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Discord_Bot;
|
||||
|
||||
public static class Utility
|
||||
{
|
||||
public static string ParseMessage(string message)
|
||||
{
|
||||
var time = message.Split(":");
|
||||
if (time.Length != 2)
|
||||
{
|
||||
throw new ArgumentException("Время неправильное. Хуйня твоё время");
|
||||
return null;
|
||||
}
|
||||
|
||||
var now = DateTime.Now;
|
||||
var date = new DateTime(now.Year, now.Month, now.Day, int.Parse(time[0]), int.Parse(time[1]), 0);
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(date);
|
||||
}
|
||||
|
||||
public static DateTime ParseTime(string token)
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<DateTime>(token);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user