This is how the below code works...If a user tags another user to negotiate with them, the bot sends the tagged user a message (the bot tags them) and then shows a yes or no emoji reaction. If the tagged user clicks yes, then the bot tells the user that tagged the other user that he/she wants to negotiate. (vice versa if tagged user clicks no).
const yesEmoji = '?';
const noEmoji = '?';
let mention = negotiate.mentions.users.first();
if(mention.id === negotiate.author.id) return message.channel.send("You cannot tag yourself!");
let msg = await negotiate.channel.send(`${mention} do you want to negotiate with ${negotiate.author}`);
var negotiating = false;
await msg.react(yesEmoji);
await msg.react(noEmoji);
const filter = (reaction, member) => {
return (member.id === mention.id && reaction.emoji.name === yesEmoji) || (member.id === mention.id && reaction.emoji.name === noEmoji);
};
msg.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === yesEmoji) {
negotiating = true;
negotiate.channel.send('The mentioned user is okay to negotiate with you!');
}
else if (reaction.emoji.name === noEmoji) return negotiate.channel.send('The mentioned user is not okay to negotiate with you...')
}).catch(err => {
if(err) return message.channel.send(`${mention} did not react within the 10 seconds!`);
})
However, I want to establish a basic trading system after the tagged user clicks no. You don't need to worry about user objects, cash objects, and etc. because I already did them previously.
Expected Sample output:
!negotiate with @taggedUser
@taggedUser do you want to negotiate with @userThatTagged
if ? --> @userThatTagged The mentioned user agreed to negotiate with you!
if ? --> @userThatTagged The mentioned user did not agree to negotiate with you.
(works until this)
!transfer 500 cash @userThatTagged
!transfer 400 cash @taggedUser
@userThatTagged, @taggeddUser confirm transaction ?
if ? --> Transaction completed!
(Both users have to transfer. The bot shouldn't immediately transfer cash because of scamming issues. Instead, the bot should display a confirmation message with this emoji ? kind of like before). The bot should only transfer cash if both users confirm. Again, you do not need to worry about adding cash I will take care of that :)
question from:
https://stackoverflow.com/questions/65623364/trade-system-in-discord-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…