Comments (3)
update: this was not a simple fix.
from optibot.
Currently making some better progress.
Discord handles audit log updates in a somewhat strange way. Any message deleted by a moderator gets sent to the audit log, however messages deleted by the post author does NOT get sent to the log. That's fine, just read the audit logs when a messageDelete
event is emitted. However, there's more to it than that.
Messages deleted within a short time frame will be combined into a single log entry. This doesn't sound too bad at first. As you could probably guess from my last late-night message (which I posted with much frustration)... it massively complicates matters.
In the event of deleting multiple messages by multiple different users within a short time frame, Discord will still combine log entries even if they are no longer at the top of the list. This means that entries lower in the list will still be updated if within the same time frame.
My initial idea for logging deleted messages was to simply keep the deletion count in the bots memory, and compare that to the latest audit log entry when a message is deleted. Simply put, if the count from Discords latest audit log was higher than the one in memory, it means the message was deleted by a moderator. (It's slightly more complicated than this, but still.) After further investigation of how audit logs work, this system is COMPLETELY unreliable.
I've resorted to keeping a cache of 10 complete log entries in the bots working memory at all times. Every time the bot detects a deleted message, the bot will call a couple loops to get the latest log containing the same user ID of the author of the deleted message, from both Discord and the bots memory.
I wont lie, this is an pretty heavy operation, especially compared to the other event handlers. The total computation time takes anywhere between 0.2-0.25 seconds. Unfortunately, this seems to be the only surefire and reliable way to tell if a message was deleted by a moderator or the message author. Other than that, it seems to be working. Still need to test with multiple messages and multiple authors at once.
from optibot.
Fixed in 26e4a45.
May need additional stress tests.
from optibot.
Related Issues (20)
- Have OptiBot ignore modpinging mods with the 'On Vacation' role
- !rr - Russian roulette minigame HOT 4
- More options for !exec HOT 1
- Expanded dev environment settings in config.json HOT 1
- Final Warning HOT 2
- If a time is not set for a ?mute, check with moderator first if they meant to leave the time empty HOT 4
- [Fun] @everyone Wheeze reaction HOT 9
- [Suggestion] Add ability to record user alts HOT 1
- Remove OptiFine dependency
- Per-guild Configs HOT 3
- Guild-exclusive commands
- Auto Commands: Replacement system for OptiBits
- Replace all *sync() fs methods with promises
- Hardcode so bots can not ban users with similar permissions. HOT 2
- Various enhancements for !role
- Add whitelist/blacklist toggle for channel logging to config
- ?delnote is unable to delete records if they are the first in the user's record
- idea: change server from windows to linux-based HOT 4
- Change around the way perms work? HOT 4
- !idcode - Identify unicode characters
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from optibot.