Collector

collector.on('collect', async i => {
const selected = i.values[0];
await i.update(`You selected ${selected}!`)
if (selected === 'DM') {
await i.editReply({content: 'The prompt has been sent to your DMs. Please continute there.', components: [] })
const DMMsg = await i.user.send('bla').catch(async (err) => { return await i.editReply('I was unable to send you a Direct Message. Please ensure you have your DMs enabled.')})
} else if (selected === 'S') {
await i.editReply('nice work!');
}
});
collector.on('end', collected => {
console.log(`Collected ${collected.size} interactions.`);
});

const DMcollector = DMMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, time: 15000 })
collector.on('collect', async i => {
const selected = i.values[0];
await i.update(`You selected ${selected}!`)
if (selected === 'DM') {
await i.editReply({content: 'The prompt has been sent to your DMs. Please continute there.', components: [] })
const DMMsg = await i.user.send('bla').catch(async (err) => { return await i.editReply('I was unable to send you a Direct Message. Please ensure you have your DMs enabled.')})
} else if (selected === 'S') {
await i.editReply('nice work!');
}
});
collector.on('end', collected => {
console.log(`Collected ${collected.size} interactions.`);
});

const DMcollector = DMMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, time: 15000 })
5 Replies
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Baconburger998
Baconburger99816mo ago
How would I be able to get the DMMsg as it is within the if statement. (moving from main channel b/c im probs gonna be back)
monbrey
monbrey16mo ago
In this case I think you can nest it, but you need to be careful that you're not duplicating collectors Does the first one end when you move to DMs?
Baconburger998
Baconburger99816mo ago
they both end after a selection, as a button collector will come after with a message, then there will be a followUp question if they confirm, then if they press that button a Modal will show up. @monbrey When you say duplicating do you mean the name or the type?
monbrey
monbrey16mo ago
If you only need one response, awaitMessage might be better You can just resolve one promise and then proceed