mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +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;
|
if (!msg.guild) return false;
|
||||||
const search = value.toLowerCase();
|
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) return false;
|
||||||
if (emojis.length === 1) return true;
|
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
|
return emojis.length <= 15
|
||||||
? `${util.disambiguation(emojis.map(emoji => escapeMarkdown(emoji.name)), 'emojis', null)}\n`
|
? `${util.disambiguation(emojis.map(emoji => escapeMarkdown(emoji.name)), 'emojis', null)}\n`
|
||||||
: 'Multiple emojis found. Please be more specific.';
|
: 'Multiple emojis found. Please be more specific.';
|
||||||
@@ -24,12 +27,13 @@ class EmojiArgumentType extends ArgumentType {
|
|||||||
|
|
||||||
parse(value, msg) {
|
parse(value, msg) {
|
||||||
const matches = value.match(/^(?:<:([a-zA-Z0-9_]+):)?([0-9]+)>?$/);
|
const matches = value.match(/^(?:<:([a-zA-Z0-9_]+):)?([0-9]+)>?$/);
|
||||||
if (matches) return msg.client.emojis.get(matches[2]);
|
if (matches) return msg.client.emojis.get(matches[2]) || null;
|
||||||
if (!msg.guild) return null;
|
|
||||||
const search = value.toLowerCase();
|
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) return null;
|
||||||
if (emojis.length === 1) return emojis[0];
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user