-
Is there a way to "react" to another button? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I managed to do something. Basically, what I need to do is click on a button that has an emoji on it. But the problem is that it's not that easy: The emoji can vary and so can the position of the button (there are three buttons, in a row, i.e. it can be the first, second, third)
Is there any way to fix or skip this obstacle? Here's a snippet of the code const emojiRegex = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g
const matches = embed.description.match(emojiRegex);
if (matches) {
for(let match of matches) {
console.log(`Emojis found: ${match}`)
await message.clickButton(match)
}
} else {
console.log('No emojis found!')
} |
Beta Was this translation helpful? Give feedback.
-
Fixed! const emojiRegex = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g
const matches = embed.description.match(emojiRegex);
if (matches) {
for(let match of matches) {
console.log(`Emojis found: ${match}`)
if (message.components && message.components.length > 0) {
const button = message.components.find((component) => {
if (component.type === 'BUTTON') {
return component.customId === match;
}
return false;
})
if (button) {
await button.click();
} else {
console.log('Not found any button to click!')
}
} |
Beta Was this translation helpful? Give feedback.
Fixed!