Skip to content

Commit

Permalink
chore: move accents and discord timestamp formats
Browse files Browse the repository at this point in the history
  • Loading branch information
N3aar committed Jun 23, 2024
1 parent f9a6c05 commit 6bebb40
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/shared/handlers/JumbleGameHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
type TranslationKey,
discordTimestampFormats,
embedColors,
translations,
} from "@/utils/contants.js";
Expand All @@ -21,6 +20,7 @@ import {
type InteractionCollector,
type Message,
} from "discord.js";
import { discordTimestampFormats } from "../types/discordTypes.js";
import type { ArtistData } from "../types/musicBrainzTypes.js";

export type JumbleField = "points" | "bestTime" | "plays";
Expand Down
10 changes: 10 additions & 0 deletions src/shared/types/discordTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
export enum discordTimestampFormats {
SHORT_TIME = "t",
LONG_TIME = "T",
SHORT_DATE = "d",
LONG_DATE = "D",
SHORT_DATE_TIME = "f",
LONG_DATE_TIME = "F",
RELATIVE_TIME = "R",
}

export type DiscordUser = {
banner: string | null;
};
63 changes: 0 additions & 63 deletions src/utils/contants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ export enum periods {
NIGHT = "NIGHT",
}

export enum discordTimestampFormats {
SHORT_TIME = "t",
LONG_TIME = "T",
SHORT_DATE = "d",
LONG_DATE = "D",
SHORT_DATE_TIME = "f",
LONG_DATE_TIME = "F",
RELATIVE_TIME = "R",
}

export const urlFixers = {
"https://www.youtube.com/shorts/": "https://youtu.be/",
"https://www.youtube.com/watch?v=": "https://youtu.be/",
Expand Down Expand Up @@ -111,56 +101,3 @@ export const expValues = {
max: 25,
cooldown: 60 * 1000,
};

export const accents = {
á: "a",
à: "a",
ã: "a",
â: "a",
ä: "a",
Á: "A",
À: "A",
Ã: "A",
Â: "A",
Ä: "A",
é: "e",
è: "e",
ê: "e",
ë: "e",
É: "E",
È: "E",
Ê: "E",
Ë: "E",
í: "i",
ì: "i",
î: "i",
ï: "i",
Í: "I",
Ì: "I",
Î: "I",
Ï: "I",
ó: "o",
ò: "o",
õ: "o",
ô: "o",
ö: "o",
Ó: "O",
Ò: "O",
Õ: "O",
Ô: "O",
Ö: "O",
ú: "u",
ù: "u",
û: "u",
ü: "u",
Ú: "U",
Ù: "U",
Û: "U",
Ü: "U",
ç: "c",
Ç: "C",
ñ: "n",
Ñ: "N",
};

export type AccentKey = keyof typeof accents;
2 changes: 1 addition & 1 deletion src/utils/dateFormat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { discordTimestampFormats } from "@/shared/types/discordTypes.js";
import dayjs from "dayjs";
import type { discordTimestampFormats } from "./contants.js";

type DateObject = {
day?: number;
Expand Down
54 changes: 53 additions & 1 deletion src/utils/stringFormat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,59 @@
import levenshtein from "js-levenshtein";
import { type AccentKey, accents } from "./contants.js";
import { shuffle } from "./random.js";

const accents = {
á: "a",
à: "a",
ã: "a",
â: "a",
ä: "a",
Á: "A",
À: "A",
Ã: "A",
Â: "A",
Ä: "A",
é: "e",
è: "e",
ê: "e",
ë: "e",
É: "E",
È: "E",
Ê: "E",
Ë: "E",
í: "i",
ì: "i",
î: "i",
ï: "i",
Í: "I",
Ì: "I",
Î: "I",
Ï: "I",
ó: "o",
ò: "o",
õ: "o",
ô: "o",
ö: "o",
Ó: "O",
Ò: "O",
Õ: "O",
Ô: "O",
Ö: "O",
ú: "u",
ù: "u",
û: "u",
ü: "u",
Ú: "U",
Ù: "U",
Û: "U",
Ü: "U",
ç: "c",
Ç: "C",
ñ: "n",
Ñ: "N",
};

type AccentKey = keyof typeof accents;

export function capitalize(text: string) {
return text
?.split(" ")
Expand Down

0 comments on commit 6bebb40

Please sign in to comment.