From 373d816f95945ea97274beb4a860351d1089e879 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sat, 9 Sep 2023 16:54:21 +1000 Subject: [PATCH] Format DOTY in a proper way --- src/funcs/ResponseSystem.ts | 3 ++- src/helpers/FormatDOTY.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/helpers/FormatDOTY.ts diff --git a/src/funcs/ResponseSystem.ts b/src/funcs/ResponseSystem.ts index 0dde8dd..b03ddf3 100644 --- a/src/funcs/ResponseSystem.ts +++ b/src/funcs/ResponseSystem.ts @@ -1,5 +1,6 @@ import Discord from 'discord.js'; import TClient from '../client.js'; +import FormatDOTY from '../helpers/FormatDOTY.js'; /* function ResponseMadeBy(id:string){ <-- Will be enabled once autoresponse suggestion comes in. return `╰ *Response made by <@${id}>*`; @@ -31,7 +32,7 @@ export default class Response { `Good grief, is it Monday already? Anyways, morning ${PersonnyMcPerson}..`, `This time I can shout! So here we go! 1..2..3\n*inhales*\nMORNING ${PersonnyMcPerson.toUpperCase()}!`, 'Gooooood morning to you!', `Good morning to you! You know what else is good? A segue to our sponsor, breakfast!\nGet started with getting out of the bed and have some breakfast!`, `## Morning ${PersonnyMcPerson}!`, '### Have a wonderful day ahead of you!', `Here, have some pancakes for breakfast, ${PersonnyMcPerson}`, 'Is it Friday yet? This week is getting boring already!', - `You have reached ${client.moment.utc().dayOfYear().toLocaleString('en-US')}th day of the year, also good morning to you as well!`, 'Good morning! Have a cookie to start your day with. :cookie:', + `You have reached ${FormatDOTY(client.moment.utc().dayOfYear())} day of the year, also good morning to you as well!`, 'Good morning! Have a cookie to start your day with. :cookie:', 'https://tenor.com/view/rambo-family-rambo-rise-and-shine-wake-up-gif-22012440' ], afternoon: [ diff --git a/src/helpers/FormatDOTY.ts b/src/helpers/FormatDOTY.ts new file mode 100644 index 0000000..7c986ed --- /dev/null +++ b/src/helpers/FormatDOTY.ts @@ -0,0 +1,5 @@ +export default (number:number)=>{ + const suffixes = ['th', 'st', 'nd', 'rd']; + const suffix = number % 100; + return number + (suffixes[(suffix - 20) % 10] || suffixes[suffix] || suffixes[0]); +}