Aerglos

Untitled

May 1st, 2021
120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //What the classes look like
  2.  
  3. //HandledCommand.ts
  4. export default abstract class HandledCommand {
  5.     abstract commandName: string;
  6.     abstract commandDescription: string;
  7.     abstract requiresArguments: boolean;
  8.     aliases?: string[];
  9.     abstract usage: string;
  10.     abstract execute(message: Message, args: string[]): void
  11.     cooldownData?: {
  12.         userCooldown?: number,
  13.         serverCooldown?: number
  14.     }
  15.     async executeSafely(message: Message, args: string[]): Promise<boolean> {
  16.         try {
  17.             await this.execute(message, args);
  18.             return true;
  19.         } catch (e) {
  20.             return false;
  21.         }
  22.     }
  23. }
  24.  
  25. //PingCommand.ts
  26. export default class PingCommand extends HandledCommand {
  27.     commandName = "ping";
  28.     commandDescription = "Ping a user or the bot";
  29.     requiresArguments = false;
  30.     usage = "ping [user]";
  31.     cooldownData = {
  32.         userCooldown: 1
  33.     }
  34.     execute(message: Message, args: string[]): void {
  35.         if(message.mentions.users.first()) {
  36.             message.channel.send(`Ping ${message.mentions.users.first()}!`);
  37.             return;
  38.         } else {
  39.             message.channel.send(`Ping!`);
  40.         }
  41.     }
  42.  
  43. }
RAW Paste Data