Trade: Add TradeStore and trade flow

Adding a TradeStore to keep track of active trades and their states.
Also implements the core trade flow and embed logic.
This commit is contained in:
2022-11-23 17:35:29 +01:00
parent 78fe0857e8
commit c866bc08eb
3 changed files with 188 additions and 56 deletions

View File

@@ -17,6 +17,14 @@ module.exports = {
async getTradeByUser(userId) {
return this.activeTrades.find(trade => trade.user1.id === userId || trade.user2.id === userId);
},
States: {
OPEN: 0,
LOCKED: 1,
ACCEPTED: 2,
CANCELLED: 3,
EXPIRED: 4
},
Trade: class Trade {
constructor(id, user1, user2) {
@@ -26,8 +34,11 @@ module.exports = {
this.embed = null;
this.user1Cards = [];
this.user2Cards = [];
this.user1Accept = false;
this.user2Accept = false;
this.user1Locked = false;
this.user2Locked = false;
this.user1Accepted = false;
this.user2Accepted = false;
this.state = 0;
}
}
}