Skip to content
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

Refactor command-related code #2

Closed
kylrs opened this issue May 12, 2020 · 0 comments · Fixed by #5
Closed

Refactor command-related code #2

kylrs opened this issue May 12, 2020 · 0 comments · Fixed by #5
Assignees
Labels
c:commands Category: Commands p:high Priority: High s:done Stage: Done t:change-request Type: Change Request

Comments

@kylrs
Copy link
Owner

kylrs commented May 12, 2020

Description

This issue proposes the simplification of command-related code, and the implementation of a better, more object-oriented solution to command loading and parsing.

Why?

The current code for loading and parsing commands makes use of a number of "-er" classes, e.g. CommandLoader, CommandParser. Such classes tend to behave simply as collections of functionality, rather than definitions for proper objects.

Implementation Details

A single Command class that serves two functions:

  • As a template for commands defined within modules, e.g.
class PingCommand extends Command {
    constructor(client) {
        super(client);
    }

    execute(message, args) {
        ping    
    }
}
  • To contain static functions relating to commands in general, not just specific instances, e.g. a getCommand(msg: Message) method that identified a command by checking for a prefix and a valid command name, and returning the name of the command to be executed, if any.
@kylrs kylrs added c:commands Category: Commands p:high Priority: High t:change-request Type: Change Request s:waiting Stage: Waiting to be started labels May 12, 2020
@kylrs kylrs self-assigned this May 14, 2020
@kylrs kylrs added s:in-progress Stage: In Progress and removed s:waiting Stage: Waiting to be started labels May 14, 2020
@kylrs kylrs linked a pull request May 21, 2020 that will close this issue
@kylrs kylrs closed this as completed in #5 May 21, 2020
@kylrs kylrs added s:done Stage: Done and removed s:in-progress Stage: In Progress labels May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:commands Category: Commands p:high Priority: High s:done Stage: Done t:change-request Type: Change Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant