I hate English. This fixes ordinal numbers in the birthday message using wrong suffix.
This commit is contained in:
parent
e95b63c24b
commit
a4b12c4b51
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using DeukBot4.MessageHandlers.CommandHandler;
|
||||
using DeukBot4.Utilities;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace DeukBot4.Database
|
||||
|
@ -140,7 +141,8 @@ namespace DeukBot4.Database
|
|||
var eb = EmbedFactory.GetStandardEmbedBuilder();
|
||||
eb.Title = $":confetti_ball::confetti_ball: Happy Birthday! :confetti_ball::confetti_ball: ";
|
||||
var age = Years(birthday, today);
|
||||
eb.Description = $"It's <@!{guildUser.Id}>'s {age}th birthday!! Have a good one!";
|
||||
string ageString = EnglishNumberParser.GetShortOrdinalNumber(age);
|
||||
eb.Description = $"It's <@!{guildUser.Id}>'s {ageString} birthday!! Have a good one!";
|
||||
eb.ThumbnailUrl = guildUser.GetAvatarUrl();
|
||||
|
||||
guild.SystemChannel.SendMessageAsync("", embed: eb.Build());
|
||||
|
|
|
@ -83,5 +83,23 @@ namespace DeukBot4.Utilities
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static string GetShortOrdinalNumber(int number)
|
||||
{
|
||||
var tensDigit = number % 100 / 10;
|
||||
if (tensDigit == 1) return $"{number}th";
|
||||
switch (number % 10)
|
||||
{
|
||||
case 1:
|
||||
return $"{number}st";
|
||||
case 2:
|
||||
return $"{number}nd";
|
||||
case 3:
|
||||
return $"{number}rd";
|
||||
default:
|
||||
return $"{number}th";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue