mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
NadekoBot Patronage system, Search commands improvements + fixes
This commit is contained in:
39
src/NadekoBot/Modules/Utility/Patronage/PatronExtensions.cs
Normal file
39
src/NadekoBot/Modules/Utility/Patronage/PatronExtensions.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace NadekoBot.Modules.Utility.Patronage;
|
||||
|
||||
public static class PatronExtensions
|
||||
{
|
||||
public static DateOnly ToDateOnly(this DateTime dateTime)
|
||||
=> DateOnly.FromDateTime(dateTime);
|
||||
|
||||
public static bool IsBeforeToday(this DateTime date)
|
||||
=> date < DateTime.UtcNow.Date;
|
||||
|
||||
public static string ToFullName(this PatronTier tier)
|
||||
=> tier switch
|
||||
{
|
||||
_ => $"Patron Tier {tier}",
|
||||
};
|
||||
|
||||
public static string ToFullName(this QuotaPer per)
|
||||
=> per.Humanize(LetterCasing.LowerCase);
|
||||
|
||||
public static DateTime DayOfNextMonth(this DateTime date, int day)
|
||||
{
|
||||
var nextMonth = date.AddMonths(1);
|
||||
var dt = DateTime.SpecifyKind(new(nextMonth.Year, nextMonth.Month, day), DateTimeKind.Utc);
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static DateTime FirstOfNextMonth(this DateTime date)
|
||||
=> date.DayOfNextMonth(1);
|
||||
|
||||
public static DateTime SecondOfNextMonth(this DateTime date)
|
||||
=> date.DayOfNextMonth(2);
|
||||
|
||||
public static string ToShortAndRelativeTimestampTag(this DateTime date)
|
||||
{
|
||||
var fullResetStr = TimestampTag.FromDateTime(date, TimestampTagStyles.ShortDateTime);
|
||||
var relativeResetStr = TimestampTag.FromDateTime(date, TimestampTagStyles.Relative);
|
||||
return $"{fullResetStr}\n{relativeResetStr}";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user