mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Improve emoji flow
This commit is contained in:
+8
-4
@@ -14,9 +14,12 @@ class EmojiArgumentType extends ArgumentType {
|
||||
}
|
||||
if (!msg.guild) return false;
|
||||
const search = value.toLowerCase();
|
||||
const emojis = msg.guild.emojis.filterArray(emoji => emoji.name.toLowerCase() === search);
|
||||
let emojis = msg.guild.emojis.filterArray(emoji => emoji.name.toLowerCase().includes(search));
|
||||
if (!emojis.length) return false;
|
||||
if (emojis.length === 1) return true;
|
||||
const exactEmojis = msg.guild.emojis.filterArray(emoji => emoji.name.toLowerCase() === search);
|
||||
if (exactEmojis.length === 1) return true;
|
||||
if (exactEmojis.length > 0) emojis = exactEmojis;
|
||||
return emojis.length <= 15
|
||||
? `${util.disambiguation(emojis.map(emoji => escapeMarkdown(emoji.name)), 'emojis', null)}\n`
|
||||
: 'Multiple emojis found. Please be more specific.';
|
||||
@@ -24,12 +27,13 @@ class EmojiArgumentType extends ArgumentType {
|
||||
|
||||
parse(value, msg) {
|
||||
const matches = value.match(/^(?:<:([a-zA-Z0-9_]+):)?([0-9]+)>?$/);
|
||||
if (matches) return msg.client.emojis.get(matches[2]);
|
||||
if (!msg.guild) return null;
|
||||
if (matches) return msg.client.emojis.get(matches[2]) || null;
|
||||
const search = value.toLowerCase();
|
||||
const emojis = msg.guild.emojis.filterArray(emoji => emoji.name.toLowerCase() === search);
|
||||
const emojis = msg.guild.emojis.filterArray(emoji => emoji.name.toLowerCase().includes(search));
|
||||
if (!emojis.length) return null;
|
||||
if (emojis.length === 1) return emojis[0];
|
||||
const exactEmojis = msg.guild.emojis.filterArray(emoji => emoji.name.toLowerCase() === search);
|
||||
if (exactEmojis.length === 1) return exactEmojis[0];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user