Skip to content

Commit

Permalink
chore: it's 2016; why are we using coldfusion?!
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Jan 10, 2022
1 parent 48670a6 commit 924558b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/lib/resolvers/emoji.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { EmojiRegex, TwemojiRegex } from '@sapphire/discord-utilities';
import { Util } from 'discord.js';
import { Identifiers } from '../errors/Identifiers';
import { err, ok } from '../parsers/Result';
import { Err, err, Ok, ok } from '../parsers/Result';

export function resolveEmoji(parameter: string) {
export function resolveEmoji(parameter: string): Ok<EmojiObject> | Err<Identifiers> {
const twemoji = TwemojiRegex.exec(parameter)?.[0] ?? null;

if (twemoji) {
return ok(twemoji);
return ok({
name: twemoji,
id: null
});
}

const emojiId = EmojiRegex.exec(parameter)?.groups?.id;
const emojiId = EmojiRegex.test(parameter);

if (emojiId) {
const resolved = Util.parseEmoji(emojiId) as EmojiObject;
const resolved = Util.parseEmoji(parameter) as EmojiObject | null;

if (resolved) {
return ok(resolved);
Expand Down

0 comments on commit 924558b

Please sign in to comment.