diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/info/guildInfo.ts | 2 | ||||
-rw-r--r-- | src/commands/info/snowflake.ts | 2 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 6 | ||||
-rw-r--r-- | src/commands/moderation/modlog.ts | 2 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClientUtil.ts | 8 |
5 files changed, 12 insertions, 8 deletions
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index f70b741..f1db783 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -105,7 +105,7 @@ export default class GuildInfoCommand extends BushCommand { guildAbout.push( `**Owner:** ${guild.members.cache.get(guild.ownerId)?.user.tag}`, - `**Created** ${guild.createdAt.toLocaleString()} (${util.dateDelta(guild.createdAt)})`, + `**Created** ${util.timestamp(guild.createdAt)} (${util.dateDelta(guild.createdAt)})`, `**Members:** ${guild.memberCount.toLocaleString() ?? 0} (${util.emojis.onlineCircle} ${ guild.approximatePresenceCount?.toLocaleString() ?? 0 }, ${util.emojis.offlineCircle} ${(guild.memberCount - (guild.approximatePresenceCount ?? 0)).toLocaleString() ?? 0})`, diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index 8d6129b..df11bce 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -139,7 +139,7 @@ export default class SnowflakeCommand extends BushCommand { const deconstructedSnowflake: DeconstructedSnowflake = SnowflakeUtil.deconstruct(snowflake); const snowflakeInfo = [ `**Timestamp:** ${deconstructedSnowflake.timestamp}`, - `**Created:** ${deconstructedSnowflake.date.toLocaleString()}`, + `**Created:** ${util.timestamp(deconstructedSnowflake.date)}`, `**Worker ID:** ${deconstructedSnowflake.workerId}`, `**Process ID:** ${deconstructedSnowflake.processId}`, `**Increment:** ${deconstructedSnowflake.increment}` diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 745dcf0..98ef3ae 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -85,11 +85,11 @@ export default class UserInfoCommand extends BushCommand { else if (member?.permissions.has('ADMINISTRATOR')) emojis.push(client.consts.mappings.otherEmojis.ADMIN); if (member?.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.BOOSTER); - const createdAt = user.createdAt.toLocaleString(), + const createdAt = util.timestamp(user.createdAt), createdAtDelta = util.dateDelta(user.createdAt), - joinedAt = member?.joinedAt?.toLocaleString(), + joinedAt = util.timestamp(member?.joinedAt), joinedAtDelta = member && member.joinedAt ? util.dateDelta(member.joinedAt, 2) : undefined, - premiumSince = member?.premiumSince?.toLocaleString(), + premiumSince = util.timestamp(member?.premiumSince), premiumSinceDelta = member && member.premiumSince ? util.dateDelta(member.premiumSince, 2) : undefined; // General Info diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index d1a3900..c72ff39 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -53,7 +53,7 @@ export default class ModlogCommand extends BushCommand { modLog.push(`**Moderator**: <@!${log.moderator}>`); if (log.duration) modLog.push(`**Duration**: ${util.humanizeDuration(log.duration)}`); modLog.push(`**Reason**: ${trim(log.reason ?? 'No Reason Specified.')}`); - modLog.push(`**Date**: ${log.createdAt.toLocaleString()}`); + modLog.push(`**Date**: ${util.timestamp(log.createdAt)}`); if (log.evidence) modLog.push(`**Evidence:** ${trim(log.evidence)}`); return modLog.join(`\n`); } 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) { |