[V3 Cleanup] refactor internals #2013
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!2013
Loading…
Reference in a new issue
No description provided.
Delete branch "cleanup-oneshot"
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?
Type
Description of the changes
Per discussion with @Tobotimus in discord, an alt to #1980 , #2006 , #2007 since deprecating the current usage shouldn't be necessary.
This reverts the hotfix #2004 , and refactors
get_messages_for_deletion. This also adds a note in the doc string about the unsafe usage case no core code uses, and how to handle that case should we care about it in the future, rather than apply any special casing here.On #1980 you stated this:
I agree we should remove ctx and I like that change. However discord's time being out of sync with the system time can still cause problems, see this example, simply achieved by changing my PC's system time:

To be honest I'm not too concerned about it, but it could be resolved by adding an optional
nowparameter toget_messages_for_deletionfor callers to pass inctx.message.created_at, but falls back todatetime.utcnow()if not provided.You're right, the timedelta still gets compared to a snowflake, which isn't isolated, I think a better solution is if the first message the bot receives seems more than 2 minutes out of sync (
discord.utils.snowflake_time, compared todatetime.utcnow()) to raise a warning. It shouldn't be a burden for each time sensitive piece of code to handle, but we can still take steps to alert users to that issue.@Tobotimus I still don't believe that handling bad system clock times should be handled here, and have opened up #2036 to handle this instead.
Will give the tick of approval after this change
This still needs to be in a try/except