Closed samarmeena closed 3 years ago
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;
};
Reason: package is not maintained regularly.
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 issueit returns
comic
for all commandName for defined commands in this class such as forqr
it will return commandNamecomic
.https://discordapp.com/channels/693401527494377482/693401527494377485/718265975283122216