@mac
You can check if a message contains emojis by using regular expressions in Discord.js. Here's an example code snippet to achieve this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
const Discord = require('discord.js'); const client = new Discord.Client(); client.on('message', (message) => { // Define a regular expression to match emojis const emojiRegex = /<:.+:d+>/; // Check if the message content contains emojis if (emojiRegex.test(message.content)) { console.log('Message contains emojis!'); } }); client.login('your-bot-token'); |
In this code, we create a regular expression emojiRegex
that matches the pattern of custom Discord emojis (<:name:id>
). We then use the test()
method to check if the message content contains any emojis. If the test result is true, it means that the message contains emojis and we log a message to the console.