diff --git a/src/commands/guild/info.ts b/src/commands/guild/info.ts index 8d9fe0d..1950528 100644 --- a/src/commands/guild/info.ts +++ b/src/commands/guild/info.ts @@ -1,7 +1,7 @@ import { ChatInputCommandInteraction } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" import { IGuildData } from "~/interfaces" -import { numberFormatter } from "~/utils/Functions/intlFormaters.js" +import { dateTimeFormatter, numberFormatter } from "~/utils/Functions/intlFormaters.js" import { getGuild, getIGN, getPlayer, getUUID, guildLevel } from "~/utils/Hypixel.js" export default async function guildInfo(interaction: ChatInputCommandInteraction): Promise { @@ -111,7 +111,7 @@ export default async function guildInfo(interaction: ChatInputCommandInteraction const guildExp = numberFormatter.format(guildExpUnformatted) const guildLvl = guildLevel(guildExpUnformatted) const guildMembers = guild!.members - const guildCreatedTime = guildCreated.toLocaleString("hr-HR", {}) + const guildCreatedTime = dateTimeFormatter.format(guildCreated) const guildOwner = guildMembers.find(m => m.rank === "Guild Master")!.uuid const guildOwnerName = await getIGN(guildOwner) diff --git a/src/commands/guild/member.ts b/src/commands/guild/member.ts index 29a2602..ce6ea1a 100644 --- a/src/commands/guild/member.ts +++ b/src/commands/guild/member.ts @@ -1,6 +1,6 @@ import { ChatInputCommandInteraction } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" -import { numberFormatter } from "~/utils/Functions/intlFormaters.js" +import { dateTimeFormatter, numberFormatter } from "~/utils/Functions/intlFormaters.js" import { getGuild, getHeadURL, getPlayer, getUUID } from "~/utils/Hypixel.js" export default async function guildMember(interaction: ChatInputCommandInteraction): Promise { @@ -112,7 +112,7 @@ export default async function guildMember(interaction: ChatInputCommandInteracti const guildMemberJoinMS = guildMember!.joined const guildMemberJoinTime = new Date(guildMemberJoinMS) - const guildMemberJoin = guildMemberJoinTime.toLocaleString("hr-HR", {}) + const guildMemberJoin = dateTimeFormatter.format(guildMemberJoinTime) await interaction.editReply({ embeds: [{ diff --git a/src/events/server/guildMemberAdd/logNewJoins.ts b/src/events/server/guildMemberAdd/logNewJoins.ts index dff033c..8857b94 100644 --- a/src/events/server/guildMemberAdd/logNewJoins.ts +++ b/src/events/server/guildMemberAdd/logNewJoins.ts @@ -1,17 +1,18 @@ -import { GuildMember, userMention } from "discord.js" +import { userMention } from "discord.js" import { embedColor } from "~/config/options.js" import { IEvent } from "~/interfaces" +import { dateTimeFormatter } from "~/utils/Functions/intlFormaters" import logToChannel from "~/utils/Functions/logtochannel.js" export default { event: "guildMemberAdd", - execute(member: GuildMember) { + execute(member) { if (process.env.NODE_ENV === "dev") return logToChannel("bot", { embeds: [{ title: "New Member", description: userMention(member.id) + " has joined the server.\n" + - "Account created: " + member.user.createdAt.toLocaleString(), + "Account created: " + dateTimeFormatter.format(member.user.createdAt), color: embedColor, thumbnail: { url: member.user.avatarURL() || "" diff --git a/src/utils/Functions/intlFormaters.ts b/src/utils/Functions/intlFormaters.ts index ba12015..7d42823 100644 --- a/src/utils/Functions/intlFormaters.ts +++ b/src/utils/Functions/intlFormaters.ts @@ -1,3 +1,12 @@ const numberFormatter = new Intl.NumberFormat("en-US") -export { numberFormatter } +const dateTimeFormatter = new Intl.DateTimeFormat("hr-HR", { + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + second: "numeric" +}) + +export { dateTimeFormatter, numberFormatter }