mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
Beep
This commit is contained in:
+4
-4
@@ -7,14 +7,14 @@ class EmojiArgumentType extends ArgumentType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validate(value, msg) {
|
validate(value, msg) {
|
||||||
const matches = value.match(/<:([a-zA-Z0-9_]+):(\d+)>/);
|
const matches = value.match(/^(?:<:([a-zA-Z0-9_]+):)?([0-9]+)>?$/);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
const emoji = msg.client.emojis.get(matches[2]);
|
const emoji = msg.client.emojis.get(matches[2]);
|
||||||
if (emoji) return true;
|
if (emoji) return true;
|
||||||
}
|
}
|
||||||
if (!msg.guild) return false;
|
if (!msg.guild) return false;
|
||||||
const search = value.toLowerCase();
|
const search = value.toLowerCase();
|
||||||
const emojis = msg.guild.emojis.filter(emoji => emoji.name.toLowerCase() === search || emoji.id === search);
|
const emojis = msg.guild.emojis.filter(emoji => emoji.name.toLowerCase() === search);
|
||||||
if (!emojis.length) return false;
|
if (!emojis.length) return false;
|
||||||
if (emojis.length === 1) return true;
|
if (emojis.length === 1) return true;
|
||||||
return emojis.length <= 15
|
return emojis.length <= 15
|
||||||
@@ -23,11 +23,11 @@ class EmojiArgumentType extends ArgumentType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse(value, msg) {
|
parse(value, msg) {
|
||||||
const matches = value.match(/<:([a-zA-Z0-9_]+):(\d+)>/);
|
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]);
|
||||||
if (!msg.guild) return null;
|
if (!msg.guild) return null;
|
||||||
const search = value.toLowerCase();
|
const search = value.toLowerCase();
|
||||||
const emojis = msg.guild.emojis.filter(emoji => emoji.name.toLowerCase() === search || emoji.id === search);
|
const emojis = msg.guild.emojis.filter(emoji => emoji.name.toLowerCase() === 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];
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user