Untitled
unknown
plain_text
19 days ago
1.9 kB
5
Indexable
Never
const Discord = require('discord.js'); const client = new Discord.Client(); client.on('message', async (message) => { if (message.author.id === 'Mudae's ID') { const content = message.content; const regex = /\b\w{3}\b/g; const match = content.match(regex); if (match) { const threeLetterWord = match[0]; const foundWord = findSuitableWord(threeLetterWord); // Call your function here if (foundWord) { const row = new Discord.MessageActionRow() .addComponents( new Discord.MessageButton() .setCustomId('seekHelp') .setLabel('Seek Help!') .setStyle('PRIMARY'), ); const msg = await message.channel.send({ content: 'Seek help!', components: [row], }); const filter = (interaction) => interaction.customId === 'seekHelp'; const collector = msg.createMessageComponentCollector({ filter, time: 60000 }); // 1 minute timeout collector.on('collect', async (interaction) => { await interaction.reply({ content: `The answer is: ${foundWord}`, ephemeral: true, }); }); // Disable the button when Mudae sends another message const mudaeMessageFilter = (m) => m.author.id === 'Mudae's ID' && m.content.includes('something'); const mudaeMessageCollector = message.channel.createMessageCollector({ filter: mudaeMessageFilter, time: 60000 }); // 1 minute timeout mudaeMessageCollector.on('collect', () => { row.components[0].setDisabled(true); msg.edit({ components: [row] }); }); } } } }); // Your function to find a suitable word function findSuitableWord(threeLetterWord) { // Your implementation here // Return a suitable word or null if none found }
Leave a Comment