emoji-regex

This commit is contained in:
Dragon Fire
2024-03-19 22:34:25 -04:00
parent 655096d4af
commit 5dd6946f99
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../framework/Command'); const Command = require('../../framework/Command');
const { Connect4AI } = require('connect4-ai'); const { Connect4AI } = require('connect4-ai');
const { stripIndents } = require('common-tags'); const { stripIndents } = require('common-tags');
const emojiRegex = require('emoji-regex/RGI_Emoji.js'); const emojiRegex = require('emoji-regex');
const { verify, list } = require('../../util/Util'); const { verify, list } = require('../../util/Util');
const { LOADING_EMOJI_ID } = process.env; const { LOADING_EMOJI_ID } = process.env;
const blankEmoji = '⚪'; const blankEmoji = '⚪';
@@ -36,7 +36,7 @@ module.exports = class ConnectFourCommand extends Command {
prompt: `What color do you want to be? Either an emoji or one of ${list(Object.keys(colors), 'or')}.`, prompt: `What color do you want to be? Either an emoji or one of ${list(Object.keys(colors), 'or')}.`,
type: 'default-emoji|custom-emoji|string', type: 'default-emoji|custom-emoji|string',
validate: (color, msg) => { validate: (color, msg) => {
const hasEmoji = new RegExp(`^(?:${emojiRegex().source})$`).test(color); const hasEmoji = new RegExp(`^(?:${emojiRegex().toString()})$`).test(color);
const hasCustom = color.match(customEmojiRegex); const hasCustom = color.match(customEmojiRegex);
if (hasCustom && !msg.guild) return 'You can only use custom emoji in a server.'; if (hasCustom && !msg.guild) return 'You can only use custom emoji in a server.';
if (hasCustom && msg.guild && !msg.guild.emojis.cache.has(hasCustom[2])) { if (hasCustom && msg.guild && !msg.guild.emojis.cache.has(hasCustom[2])) {
+2 -2
View File
@@ -1,10 +1,10 @@
const ArgumentType = require('../ArgumentType'); const ArgumentType = require('../ArgumentType');
const emojiRegex = require('emoji-regex/RGI_Emoji.js'); const emojiRegex = require('emoji-regex');
module.exports = class DefaultEmojiArgumentType extends ArgumentType { module.exports = class DefaultEmojiArgumentType extends ArgumentType {
constructor(client) { constructor(client) {
super(client, 'default-emoji'); super(client, 'default-emoji');
this.regex = new RegExp(`^(?:${emojiRegex().source})$`); this.regex = new RegExp(`^(?:${emojiRegex().toString()})$`);
} }
validate(value) { validate(value) {