-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue# 307 Add Receiver Confirmation to Coin Transfer #456
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work - just some comments.
src/components/coin.ts
Outdated
new MessageButton() | ||
.setCustomId(`transfer-check-${this.transferId}`) | ||
.setLabel(getEmojiFromSign(TransferSign.Accept)) | ||
.setStyle('SECONDARY'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for this we should set the success style to be SUCCESS And the failure style to be FAILURE. Then we can just change the button contents to be "Accept" and "Reject" respectively.
src/components/coin.ts
Outdated
await adjustCoinBalanceByUserId( | ||
this.state.receiver.id, | ||
this.state.amount, | ||
UserCoinEvent.AdminCoinAdjust, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be AdminCoinAdjust. Maybe make a new enum value UserCoinEvent.CoinTransferAcceptor
for this?
src/interaction-handlers/transfer.ts
Outdated
if (transfer.transferMessage instanceof Message) { | ||
transfer.transferMessage.edit(<MessagePayload>message); | ||
} else if (transfer.transferMessage instanceof CommandInteraction) { | ||
transfer.transferMessage.editReply(<MessagePayload>message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think extract this functionality into a helper function in utils
for editing a SapphireSentMessageType and use that here.
src/components/coin.ts
Outdated
await adjustCoinBalanceByUserId( | ||
this.state.sender.id, | ||
<number>(-1 * this.state.amount), | ||
UserCoinEvent.AdminCoinAdjust, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be AdminCoinAdjust. Maybe make a new enum value UserCoinEvent.CoinTransferReceiver for this?
src/components/coin.ts
Outdated
return this.transfers.get(id); | ||
} | ||
|
||
runFuncOnGame(transferId: string, func: (transfer: Transfer) => void): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this method call into something else, since I think a Game
does not make sense in this context. Maybe runFuncOnTransfer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small comment.
src/components/coin.ts
Outdated
@@ -380,7 +381,7 @@ export class Transfer { | |||
await adjustCoinBalanceByUserId( | |||
this.state.receiver.id, | |||
this.state.amount, | |||
UserCoinEvent.AdminCoinAdjust, | |||
UserCoinEvent.CoinTransferAcceptor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be CoinTransferReceiver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary of Changes
Add confirmation to existing transfer feature via interaction handler.
Related Issues
Resolves Issue#-307
Demonstration of Changes
Further Information and Comments
Implementation is meant to be mimicked from that of rps.
Added transfer interaction handler as well as Transfer and TransferTracker classes to components/coin.ts
Added updateMessageEmbed to utils/embed.ts, changed rps interaction handler to use updateMessageEmbed
Added UserCoinEvent.CoinTransferSender, UserCoinEvent.CoinTransferReceiver enum values