Add rules command tests

This commit is contained in:
Ethan Lane 2022-01-22 15:01:41 +00:00
parent e46e1c3d8b
commit f5640f6082
Signed by: Vylpes
GPG key ID: EED233CC06D12504
3 changed files with 132 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import { existsSync, readFileSync } from "fs";
import { ICommandContext } from "../contracts/ICommandContext";
import ICommandReturnContext from "../contracts/ICommandReturnContext";
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
import PublicEmbed from "../helpers/embeds/PublicEmbed";
import { Command } from "../type/command";
@ -21,11 +22,15 @@ export default class Rules extends Command {
];
}
public override execute(context: ICommandContext) {
if (!existsSync(process.env.COMMANDS_RULES_FILE!)) {
public override execute(context: ICommandContext): ICommandReturnContext {
if (!existsSync(`${process.cwd()}/${process.env.COMMANDS_RULES_FILE!}`)) {
const errorEmbed = new ErrorEmbed(context, "Rules file doesn't exist");
errorEmbed.SendToCurrentChannel();
return;
return {
commandContext: context,
embeds: [errorEmbed]
};
}
const rulesFile = readFileSync(`${process.cwd()}/${process.env.COMMANDS_RULES_FILE}`).toString();
@ -43,5 +48,10 @@ export default class Rules extends Command {
});
embeds.forEach(x => x.SendToCurrentChannel());
return {
commandContext: context,
embeds: embeds
};
}
}