diff options
Diffstat (limited to 'src/lib/extensions/discord-akairo')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClientUtil.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 77ded3b..c15ca1c 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -1267,8 +1267,12 @@ export class BushClientUtil extends ClientUtil { * - **F**: Long Date/Time * - **R**: Relative Time */ - public timestamp(date: Date, style: 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R' = 'f'): string { - return `<t:${Math.round(date.getTime() / 1000)}:${style}>`; + public timestamp<D extends Date | undefined | null>( + date: D, + style: 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R' = 'f' + ): D extends Date ? string : undefined { + if (!date) return date as unknown as D extends Date ? string : undefined; + return `<t:${Math.round(date.getTime() / 1000)}:${style}>` as unknown as D extends Date ? string : undefined; } public dateDelta(date: Date, largest?: number) { |