[Bank] Dispatch events for account events #5325
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!5325
Loading…
Reference in a new issue
No description provided.
Delete branch "bank-events"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds some event dispatches to Bank
red_bank_set_global
red_bank_set_balance
red_bank_transfer_credits
red_bank_wipe
red_bank_prune_accounts
Resolves #5141
@ -1085,3 +1120,24 @@ def cost(amount: int):return coro_or_commandThe type annotation for
pruned_usersshould beUnion[List[int], Dict[str, List[int]]]instead ofUnion(List[int], Dict[str, List[int]])Would it be possible it to make these payload classes into NamedTuples instead? That should be a free performance improvement since these classes don't need to be modified after they're created.
Initial design feedback.
@ -7,0 +13,4 @@.. py:method:: red_bank_set_balance(payload: redbot.core.bank.BankSetBalanceInformation)Dispatched when a user has their balance changed.The documented events that dispatch custom objects should link to those objects in some way. It might make sense to use a similar format as the autogenerated API descriptions for methods, which have a "parameters" section describing each of the parameters in detail.
@ -7,0 +21,4 @@.. py:method:: red_bank_wipe(guild_id: int)Dispatched when the Bank gets wiped. :code:`guild_id` will be the ID of the Guild that was wiped, 0 if all Guilds were wiped (Bank is Local), or -1 if all Users were wiped (Bank is Global)Having both 0 and -1 as special values seems a bit smelly. Is there a meaningful difference for the CC to account for that makes differentiating between wiping guilds or users something that needs to happen? If so, I think it would be neater to just have a second argument, whether or not the bank was global at the time of wiping.
I would say the CC can just check if the bank is global or not to get the same value, but that only applies for
[p]bankset reset.[p]bankset toggleglobalalso implicitly results in this being called, since it clears the bank during the process of swapping scope. Trying to test for it at that time would likely result in an incorrect value due to race conditions.It's more typical for
guildlike attributes to beOptionaland useNoneas the value to represent non-guild actions (IE,message.guild). If it is consistently possible to provide the full user/guild object rather than an ID, I also think that would be preferred.Leftover print?
tmpis only defined whenuser_id is None. This errors if a particular user is pruned.(I do think the conditionally defined variables in this function are smelly, making this sort of error very easy to make)
These objects should be added to
__all__, since they are part of the public API. They also need to be documented, which may or may not happen automatically after doing so.Forgot to hit submit on the comment I was writing here....
Doing it like this loses the ability to know what guild was being pruned. Unless there is some reason to differentiate between specifically pruning a member and a single member happening to be the only invalid member from a bulk prune, the signature of this event object would likely be better as:
guild: Optional[discord.Guild], pruned_user_ids: List[int]It would seem that this got superseded by #6339 - we'll definitely make sure that you are listed as one of the authors before the merge.
Pull request closed