Migrate clear command

This commit is contained in:
Ethan Lane 2021-11-29 11:46:16 +00:00
parent ecf9c5e4fc
commit be329d709f
Signed by: Vylpes
GPG key ID: EED233CC06D12504
4 changed files with 38 additions and 60 deletions

36
src/commands/clear.ts Normal file
View file

@ -0,0 +1,36 @@
import { Command, ICommandContext } from "vylbot-core";
import ErrorEmbed from "../helpers/ErrorEmbed";
import { TextChannel } from "discord.js";
import PublicEmbed from "../helpers/PublicEmbed";
export default class Clear extends Command {
constructor() {
super();
super._category = "Moderation";
super._roles = [
process.env.ROLES_MODERATOR!
];
}
public override async execute(context: ICommandContext) {
if (context.args.length == 0) {
const errorEmbed = new ErrorEmbed(context, "Please specify an amount between 1 and 100");
errorEmbed.SendToCurrentChannel();
return;
}
const totalToClear = Number.parseInt(context.args[0]);
if (!totalToClear || totalToClear <= 0 || totalToClear > 100) {
const errorEmbed = new ErrorEmbed(context, "Please specify an amount between 1 and 100");
errorEmbed.SendToCurrentChannel();
return;
}
await (context.message.channel as TextChannel).bulkDelete(totalToClear);
const embed = new PublicEmbed(context, "", `${totalToClear} message(s) were removed`);
embed.SendToCurrentChannel();
}
}

View file

@ -9,7 +9,7 @@ export default class LogEmbed extends MessageEmbed {
constructor(context: ICommandContext, title: string) {
super();
super.setColor(process.env.ERROR_EMBED!);
super.setColor(process.env.EMBED_COLOUR!);
super.setTitle(title);
this._context = context;

View file

@ -7,7 +7,7 @@ export default class PublicEmbed extends MessageEmbed {
constructor(context: ICommandContext, title: string, description: string) {
super();
super.setColor(process.env.ERROR_EMBED!);
super.setColor(process.env.EMBED_COLOUR!);
super.setTitle(title);
super.setDescription(description);