Skip to content

Commit

Permalink
Bump WOM utils to allow GB constituents (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
psikoi authored May 26, 2024
1 parent 3fc3f9d commit 63c4463
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wise-old-man-bot",
"version": "1.4.4",
"version": "1.4.5",
"description": "A Discord bot for the Wise Old Man projects (https://github.com/wise-old-man/wise-old-man/)",
"author": "Psikoi",
"license": "ISC",
Expand Down Expand Up @@ -46,7 +46,7 @@
"@sapphire/discord.js-utilities": "^7.1.6",
"@sentry/node": "^7.28.0",
"@sentry/tracing": "^7.28.0",
"@wise-old-man/utils": "^3.2.1",
"@wise-old-man/utils": "^3.3.1",
"canvas": "^2.6.1",
"cors": "^2.8.5",
"discord.js": "^14.14.1",
Expand Down
18 changes: 6 additions & 12 deletions src/utils/flags.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Country } from '@wise-old-man/utils';

// offset between uppercase ascii and regional indicator symbols
const OFFSET = 127397;

export function countryCodeEmoji(cc: string): string {
if (cc === 'USA') return countryCodeEmoji('US');
if (cc === 'UK') return countryCodeEmoji('GB');
export function countryCodeEmoji(cc: Country): string {
if (cc === Country.GB_SCT) return '🏴󠁧󠁢󠁳󠁣󠁴󠁿';
if (cc === Country.GB_WLS) return '🏴󠁧󠁢󠁷󠁬󠁳󠁿';
if (cc === Country.GB_NIR) return '🇬🇧';

if (!/^[a-z]{2}$/i.test(cc)) {
return '';
Expand All @@ -13,13 +16,4 @@ export function countryCodeEmoji(cc: string): string {
return String.fromCodePoint(...codePoints);
}

export function emojiCountryCode(flag: string): string {
if (flag.length !== 4) {
return '';
}

const codePoints = [...flag].map(c => (c.codePointAt(0) || 0) - OFFSET);
return String.fromCodePoint(...codePoints);
}

export default countryCodeEmoji;

0 comments on commit 63c4463

Please sign in to comment.