'What to do after this to compare interaction.customId
I am trying to create a Multiplayer RPS in discord using Buttons but i cant seem to find a way to compare inteaction.customId of both collectors to get the result. The challenger and the Member who is challenged have to respond in their DMs.
Please tell me a way to get inteaction.customId from these two colletectors or a way through which i can determine Results.
This is the collector for challenger
acollector.on('collect', async (interaction) => {
if (interaction.customId === 'rock') {
RPSbuttons.components.forEach(e => e.setDisabled(true))
interaction.update({emebes: [RPSembed], components: [RPSbuttons]})
interaction.user.send('You Choose **Rock**!')
} else if (interaction.customId === 'paper') {
RPSbuttons.components.forEach(e => e.setDisabled(true))
interaction.update({emebes: [RPSembed], components: [RPSbuttons]})
interaction.user.send('You Choose **Paper**!')
} else if (interaction.customId === 'scissor') {
RPSbuttons.components.forEach(e => e.setDisabled(true))
interaction.update({emebes: [RPSembed], components: [RPSbuttons]})
interaction.user.send('You Choose **Scissors**!')
}
})
This is the collector for The member who is being challenged:
ocollector.on('collect', async (interaction) => {
if (interaction.customId === 'rock') {
RPSbuttons.components.forEach(e => e.setDisabled(true))
interaction.update({emebes: [RPSembed], components: [RPSbuttons]})
interaction.user.send('You Choose **Rock**!')
} else if (interaction.customId === 'paper') {
RPSbuttons.components.forEach(e => e.setDisabled(true))
interaction.update({emebes: [RPSembed], components: [RPSbuttons]})
interaction.user.send('You Choose **Paper**!')
} else if (interaction.customId === 'scissor') {
RPSbuttons.components.forEach(e => e.setDisabled(true))
interaction.update({emebes: [RPSembed], components: [RPSbuttons]})
interaction.user.send('You Choose **Scissors**!')
}
})```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
