Migrate clear command
This commit is contained in:
parent
ecf9c5e4fc
commit
be329d709f
4 changed files with 38 additions and 60 deletions
36
src/commands/clear.ts
Normal file
36
src/commands/clear.ts
Normal 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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue