Skip to content
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

[V3/Bank] Change withdraw to accept 0. #1937

Merged
merged 2 commits into from
Jul 25, 2018
Merged

[V3/Bank] Change withdraw to accept 0. #1937

merged 2 commits into from
Jul 25, 2018

Conversation

Redjumpman
Copy link
Member

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

This change makes it so withdraw_credits will accept 0 for the amount. It currently raises a ValueError. When a cog requires credits to be used for some functionality an additional check has to be added for 0 (Essentially when someone wants to make it free). For example:

if amount == 0:
    return True

 try:
    await bank.withdraw_credits(member, amount)
except ValueError:
    return False
else:
    return True

This change will eliminate that leading if statement. This won't adversely effect someone's balance, because under the operation is only subtracting 0. Zero is the identity element in subtraction.

@Kowlin Kowlin added the V3 label Jul 21, 2018
@Kowlin Kowlin merged commit f6823ea into Cog-Creators:V3/develop Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants