<repo_name>chickenfan/Chickens-Amazing-Discord-Bot<file_sep>/CommandHandling/BaseCommand.ts
import {Permissions, GuildMember, Message} from 'discord.js'

export default abstract class BaseCommand {
  private command: String;
  private perm: number;

  constructor(command: String, perm: number) {
    this.command = command;
    this.perm = perm;
  }

  public getCommand(withPrefix: boolean): String {
    if(withPrefix) 
      return '!' + this.command;
    else 
      return this.command;
  }
  public getPerm(): number {
    return this.perm;
  }

  public abstract execute(member: GuildMember, args: String[], msg: Message): void;
}<file_sep>/CommandHandling/CommandManager.ts
import BaseCommand from "./BaseCommand"
import {ShutdownCommand} from "./Commands/ShutdownCommand"
import {HelloCommand} from "./Commands/HelloCommand"

export default class CommandManager {
  private commands: Array<BaseCommand>;

  private addCommand(command: BaseCommand): void {
    this.commands.push(command);
  }

  public getCommands(): Array<BaseCommand> {
    return this.commands;
  }

  constructor() {
    this.commands  = [new ShutdownCommand()];
    this.addCommand(new HelloCommand());
  }
}<file_sep>/CommandHandling/Commands/ShutdownCommand.ts
import BaseCommand from "../BaseCommand"
import Lib from "../Lib"

import {Permissions, GuildMember, Message} from 'discord.js'


export class ShutdownCommand extends BaseCommand {
constructor() {
    super('shutdown', Permissions.FLAGS.ADMINISTRATOR); 
  }

  execute(member: GuildMember, args: String[], msg: Message): void {
    var lib = new Lib();
    
    if (member.guild.me!.hasPermission(this.getPerm()))
      lib.getUtility().getClient().destroy();
  }
}<file_sep>/CommandHandling/Commands/HelloCommand.ts
import {Permissions, GuildMember, Message} from 'discord.js'
import BaseCommand from "../BaseCommand"

export class HelloCommand extends BaseCommand {
  constructor() {
    super('hello', Permissions.FLAGS.SEND_MESSAGES);
  }

  public execute(member: GuildMember, args: String[], msg: Message): void {
    msg.channel.send('Hello ' + member.displayName);
  }
}<file_sep>/CommandHandling/Lib.ts
import Utility from "../Index"

export default class Lib {
  getUtility(): Utility {
    return new Utility;
  }
}<file_sep>/Index.ts
import {Client, GuildMember} from 'discord.js';

import CommandManager from "./CommandHandling/CommandManager"

const client = new Client();

var cmdManager: CommandManager;
var utils: Utility;

export default class Utility {
  getClient(): Client {
    return client;
  }

  equalsIgnoreCase(string1: String, string2: String): boolean {
    if (string1.toString().toLowerCase() == string2.toString().toLowerCase())
      return true;
    else
      return false;
  }
}

client.on('ready', () => {
  console.log('Bot up!');
  cmdManager = new CommandManager();
  utils = new Utility();
});

client.on('message', msg => {
  cmdManager.getCommands().forEach(cmd => {
    if(utils.equalsIgnoreCase(msg.toString(), cmd.getCommand(true)))
      cmd.execute(msg.member as GuildMember, [''], msg);
  });
});

client.login(process.env.TOKEN);