Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider 7aef5012 rédigé par Sorunome's avatar Sorunome
Parcourir les fichiers

Merge remote-tracking branch 'origin/soru/command-processor' into develop

parents fe7bf8c9 289b857d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -268,7 +268,11 @@ export class Util {
}
return reply;
}
if (Object.keys(actions).length === 0) {
return "No commands found";
}
reply += "Available Commands:\n";
let commandsHavePermission = 0;
for (const actionKey of Object.keys(actions)) {
const action = actions[actionKey];
if (action.permission !== undefined && permissionCheck) {
......@@ -277,12 +281,16 @@ export class Util {
continue;
}
}
commandsHavePermission++;
reply += ` - \`${prefix} ${actionKey}`;
for (const param of action.params) {
reply += ` <${param}>`;
}
reply += `\`: ${action.description}\n`;
}
if (!commandsHavePermission) {
return "No commands found";
}
reply += "\nParameters:\n";
for (const parameterKey of Object.keys(parameters)) {
const parameter = parameters[parameterKey];
......
......@@ -86,6 +86,16 @@ describe("Util", () => {
},
};
describe("HandleHelpCommand", () => {
it("handles empty commands", async () => {
const {command, args} = Util.MsgToArgs("!fox help", "!fox");
const retStr = await Util.HandleHelpCommand(
"!fox",
{} as any,
{} as any,
args,
);
expect(retStr).to.equal("No commands found");
});
it("parses general help message", async () => {
const {command, args} = Util.MsgToArgs("!fox help", "!fox");
const retStr = await Util.HandleHelpCommand(
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter