-
Notifications
You must be signed in to change notification settings - Fork 12
Controller Cleanup Project #104
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
Merged
Merged
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 a class for a base command, the class helps standardizes commands, this class is currently in here temporarily, but should be extracted later.
Moved the BaseCommand class out of roles into separate file, renamed as Command in Role controller, cleaned up ctrl array.
Controllers now extend from BaseController. Most commands work.
Cleaned up excess code comments. Old code comments
Added controllerUtils.js, contains a random code generation method. Aforementioned used in verify.js.
There was an issue accessing "this" from controller actions. This is now fixed by binding the controller. Cleaned up client.js and index.js to be more semantic and have better comments.
Spread commands array out one item per line, added more semantic comments.
Fixed export for codeGenerator.
Set showWithHelp in command to false to hide command from help menu.
Commands can now be admin-only. Admin roles are defined in baseController.js.
controllerUtils.js is now botUtils.js, a new isAdmin util can check if a guild member object is an admin. The help command now hides admin-only commands from non-admin users.
Made sure formatting was consistent across all command information. Added formatting and hints for required and optional items.
Test on `roles.js` checked for # of functions, controller file now uses a class, rendering test ineffective.
Looks fantastic. Good work, team!! 😃 👍 |
looks Great I approve great job |
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.
This project has quite a few fundamental changes:
Individual commands within controllers have been modified from JSON-style object notation into their own BaseCommand class stored within
bot/baseCommand.js
, various command properties have been renamed to be more semantic. Action logic has been moved to individual methods within the controller.Each controller has now been migrated from a functional structure to a class, that inherits from BaseController, stored in
bot/baseController.js
. The controller is instantiated within the constructor and then commands are executed via the inherited run method from the super. Again, all command logic is stored via methods in their respective controllers.Special controller functionality was restored, including middleware that expands the Discord message object to include a
.parsed
property that tokenizes the message string. Success and error messages now catch issues including unresponsive commands, and messages intended to invoked in a channel.A new utility file -
bot/botUtils.js
- was created to store reusable logic such as generating random strings (for email verification codes) and for checking if a user is an admin.The
client.js
file now automatically generates the !help command. Admin-only commands will only be displayed to admin users. Commands with displayInHelp disabled will not be shown, even to admin users.