-
Notifications
You must be signed in to change notification settings - Fork 1
Poc db updated #19
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
Open
kmatsumari
wants to merge
4
commits into
poc-database
Choose a base branch
from
poc-db-updated
base: poc-database
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Poc db updated #19
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added try/catch for errors in the dbConnectionManager.
Also, beautified some of the code to be better nested (some areas were horribly indented out of haste and differing tabulation settings), and redefined some variable names to be more appropriately named that specifically reference an Object defined in the Discord.js API. Still have more to go, it's a WIP.
Still using Discord.js API v12 at the moment, no need to update to v13 as of yet, so mind the notices where v13 makes breaking changes to our bot that calls outdated methods.
Made some function updates and inclusions:
guildService.getRole() modified - now checks if the fetched roleObj ends up being null. roleObj is set to an object with properties id, name, and members when valid, null otherwise, then the function returns roleObj.
guildService.isBypassingGMU() added - many areas of the bot were originally supposed to validate that the triggering user isn't a bypassing user (now includes roles), but the check was only made in guildService.getExecutorForRoleChangeFromAuditLog() and that method was only being called to see if the drunktankRole was being manipulated manually. bypassGMU was intended to allow this bot to flat out ignore everything done by a user (or user with the included role) from being able to trigger anything with this bot. This new method of guildService can now be called from any event or service while passing the guildMember Object, and allows the caller to simply return out when this method returns true.
main.js -> client.on("message") now calls guildService.injectGuild() when the message isn't a DM (valid guild) and before it checks anything else (originally ensured it wasn't responding to itself), in order to give proper access guildService.isBypassingGMU(), which will be checked against the author guildMember Object for bypassing member, and will fall back with no response if true. This updated approach will still ignore its own messages so long as the bot user as a guildMember is a bypassing member by its own client.id or a roleID is in bypassGMU.
dbManager.Query() now logs connection issues if the Promise encounters an error or rejection. All calls to the dbManager.Query() should now check for a null row result to indicate an error was encountered.
bufferService allows unhandled PromiseRejections because we already have the info we need, so we only log that it happened and show the query object that was built.
checkTankCommand
if a tanked user has served their time, the text saying so is now in bold to draw better attention.
if a user has been banned, and their record was not closed due to not being caught by the guildMemberDelete event (either they left before they got banned, or the audit log entry for their ban got held up), their tank record is closed the way it is handled in memberLeaveEvent, and they are not mentioned in checktank command output.
if a user is not currently in the server (left or kicked, not banned), it is explicitly mentioned.
Until age-verification is handled differently without drunktanking, there will be no auto-untanking for time served, as many botUsers manually tank or fail to specify longer durations for users that are being made to wait until some non-time condition is met.
memberUpdateEvent has it's .catch() block uncommented to handle exceptions again. This does not catch unhandled promise rejections we explicitly cause for bypassing users.
All loaded services, commands, events, etc., are now dynamically loaded in their corresponding directories, and a new function in main.js allows for the reloading of these modules. There is also a new directory called "developer" which has one command currently inside it: reloadcommands.
main.js now holds all services, commands, events, helpers, and managers (only one manager atm) as globals, whereby the namespace is all uppercase of their directory followed by their filename without extension. Commands have been renamed to reflect their expected lowercase command handle.
Moved commandParser.js to /services where it actually should have been put all along, and renamed it to commandService.js
commands are now handled by calling COMMANDS[<command>].handle(), where <command> is both a command.js file in the /commands directory AND the command string exists in the switch statement in commandService.js - anything not found there will fall under the default case, and not get handled, which is a great way to enable/disable a particular command if need be.
Added a new service dmService.js.
Whenever a user DM's the bot, the bot will respond (originally was just a retort and was handled within main.js).
If the user's ID is included in the developers array on line 4, that user can invoke commands found in the /developers directory (otherwise you get a retort).
All command files now have a help function that gets called by the help.js command.
Now you don't have to update help.js when you make changes to other commands, just update the command's help function return value.
All instances of "DEPRECATED" functions have been completely removed.
Various other little tweaks (I've lost track of the small tweaks that were causing issues).
This branch will be getting updates published after they have been applied as patches/hotfixes/ninjafixes to the live druncord bot, 'TankCommander', until such a time that all currently existing functionality is working as intended and there are no more cases of unhandled promise rejections in the code. This is not ideal, and is not an easy decision, but this newest chunk of changes comes at a time when there are so many things that could not be viably tested and as such so many problems still exist that need attention, all whilst still needing the bot to run; a database for better/stable data collection, some necessary tweaks to unforeseeable issues, and with so many fixes/patches looming ahead, a way to update the bot without stopping/restarting it is an extremely valuable thing to have.
full explanation of the new changes and tweaks, as well as the more recent overhaul where everything short of main.js can be created/modified/removed on the fly without restarting the bot.
Line 34 contained a reference to "drunktankService" instead of "drunkTankService" (Capital T in Tank is necessary, due to case-sensitive filenames as object keys. Also fixing the incorrectly named file in ../services, so the tank can actually work again.
Incorrectly named, and would not be properly referenced due to case-sensitive matching between loaded services filenames and their indexes held in the SERVICES object.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New changes were made over the past couple months that handles some previously unknown issues. More issues were found (will bug report them properly at a later time), so it was deemed necessary to overhaul the bot again so it could be more easily hotfixed without restarting it.
There are massive alteration in how the services, events, commands, etc are all called, but all for the better I do believe.