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

Template Encourages too much Redundancy #56

Open
Kaisarion opened this issue Nov 18, 2022 · 2 comments
Open

Template Encourages too much Redundancy #56

Kaisarion opened this issue Nov 18, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@Kaisarion
Copy link

start-bot.ts requires the importation of command classes through the index.ts.

then, there is a command array created:

 let commands: Command[] = [
        // Commands
       // Chat Commands
       // _Admin
        new CreateRoleCommand(),
        new DeleteRoleCommand(),

        // _Info
        new CreditsCommand(),
        new AddBotCommand(),

        // _Moderation
        new AssignRoleCommand(),
        new BanCommand(),

        new HelpCommand(),
        new StatusCommand(),

        // Message Context Commands
        new ViewDateSent(),

        // User Context Commands
        new ViewDateJoined(),

       // TODO: Add new commands here
    ]

You can see the problem if we have over 100 commands, the file would turn into 400-500 lines easily.

Any future dynamic solution to this? It leaves our hands tied.

@MagicPotato21
Copy link

MagicPotato21 commented Dec 11, 2022

@Kaisarion
One possible solution to this issue would be to organize the commands into different categories or modules, and then import each module separately. This would make the code more organized and easier to read and maintain. For example:

// Chat Commands
import * as chatCommands from './chat-commands';

// Message Context Commands
import * as messageCommands from './message-commands';

// User Context Commands
import * as userCommands from './user-commands';

let commands: Command[] = [
// Chat Commands
...chatCommands.adminCommands,
...chatCommands.infoCommands,
...chatCommands.moderationCommands,

// Message Context Commands
...messageCommands.all,

// User Context Commands
...userCommands.all,

// TODO: Add new commands here

];

Alternatively, you could use an object to store the commands, where the keys represent the different categories or modules and the values are arrays of commands. This would allow you to easily access and use the commands in different parts of your code.

@KevinNovak KevinNovak added the enhancement New feature or request label Jan 4, 2023
@techguydave
Copy link

It would be nice to have it organized into modules. There's a lot of locations where things need to be added just to add a new command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants