Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

commandName bug #16

Closed
vijayymmeena opened this issue Jun 17, 2020 · 2 comments
Closed

commandName bug #16

vijayymmeena opened this issue Jun 17, 2020 · 2 comments
Labels
bug Something isn't working v4 Issue related to v4 (@Command)

Comments

@vijayymmeena
Copy link
Contributor

vijayymmeena commented Jun 17, 2020

command.commandName return last command name inside a class. This happens when you define multiple commands under single class using decorator. Below this the example code of this issue

export abstract class Fun {

    @Command("cats")
    async catfaces(command: CommandMessage, client: Client) {
    }

    @Command("joke")
    async joke(command: CommandMessage, client: Client) {
    }

    @Command("qr")
    async qr(command: CommandMessage, client: Client) {
    }

    @Command("comic")
    async comic(command: CommandMessage, client: Client) {
    }

}

it returns comic for all commandName for defined commands in this class such as for qr it will return commandName comic.

https://discordapp.com/channels/693401527494377482/693401527494377485/718265975283122216

@owengombas owengombas added bug Something isn't working todo 🗒️ labels Jun 17, 2020
@tonyeung
Copy link
Contributor

Not sure if this is related.. but in a guard, the message.commandName always returns the first command called... issue can be replicated with this throttle guard outlined below.

For the full project, see my repo at https://github.com/tonyeung/statics.bot. Please note that the throttle guard I have in the project has a working version where I pass the command name into the guard as a workaround.

import { ArgsOf, GuardFunction } from "@typeit/discord";


export const Throttle = (): GuardFunction => {    
    const guard: GuardFunction = async ([message]: ArgsOf<"commandMessage">, client, next) => {
        console.log("inside throttle, called " + message.commandName);
        console.log("commands called: " + process.env.commands);

        if (process.env.commands.indexOf(message.commandName) == -1) {
            console.log(message.commandName + " not found");
            process.env.commands += message.commandName;
            await next();
        }
        else {
            console.log(message.commandName + " found");
            message.reply("already executed command");
        }        
    };

    return guard;
};

@owengombas owengombas added v4 Issue related to v4 (@Command) and removed todo 🗒️ labels Jun 2, 2021
@vijayymmeena
Copy link
Contributor Author

Closed

Reason: package is not maintained regularly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working v4 Issue related to v4 (@Command)
Projects
None yet
Development

No branches or pull requests

3 participants