Skip to content

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 16 commits into from
Feb 20, 2018
Merged

Controller Cleanup Project #104

merged 16 commits into from
Feb 20, 2018

Conversation

LukeBillington
Copy link
Collaborator

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.

LukeBillington and others added 16 commits January 17, 2018 16:50
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.
@MWLangenhorst88
Copy link

Looks fantastic. Good work, team!! 😃 👍

@LevanceWam
Copy link

looks Great I approve great job

@reactivepixel reactivepixel merged commit c4a358b into dev Feb 20, 2018
@reactivepixel reactivepixel deleted the controller-fix branch August 21, 2019 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants