<commit_before>import PacketTypes from 'dimensions/packettypes';
import * as _ from 'lodash';
import Client from 'dimensions/client';
import RoutingInformation from 'dimensions/routinginformation';
import PacketWriter from 'dimensions/packets/packetwriter';

export interface Command {
  name: string;
  args: string[];
}

/**
 * Handles commands before they go to any terraria servers
 */
export class ClientCommandHandler {
  /**
   * Turns a message into a command object, splitting the command name
   * from its arguments.
   * 
   * @param message The message to convert into a command object
   * @return The command object created
   */
  parseCommand(message: string): Command {
    let args: string[] = message.split(' ');
    let name: string = message.substr(1, args[0].length - 1);
    
    // Remove first arg as it is the command name
    args.splice(0, 1);
    return { name: name.toLowerCase(), args: args };
  }

  /**
   * Handles any matching command from the client
   * 
   * @param command The command object with the name and args
   * @param client The client that is trying to use the command
   * @return whether or not the command was handled
   */
  handle(command: Command, client: Client): boolean {
    let handled: boolean = false;
    if (client.servers[command.name]) {
      if (client.server.name == command.name) {<commit_msg>Add check for client being connected<commit_after>import PacketTypes from 'dimensions/packettypes';
import * as _ from 'lodash';
import Client from 'dimensions/client';
import RoutingInformation from 'dimensions/routinginformation';
import PacketWriter from 'dimensions/packets/packetwriter';

export interface Command {
  name: string;
  args: string[];
}

/**
 * Handles commands before they go to any terraria servers
 */
export class ClientCommandHandler {
  /**
   * Turns a message into a command object, splitting the command name
   * from its arguments.
   * 
   * @param message The message to convert into a command object
   * @return The command object created
   */
  parseCommand(message: string): Command {
    let args: string[] = message.split(' ');
    let name: string = message.substr(1, args[0].length - 1);
    
    // Remove first arg as it is the command name
    args.splice(0, 1);
    return { name: name.toLowerCase(), args: args };
  }

  /**
   * Handles any matching command from the client
   * 
   * @param command The command object with the name and args
   * @param client The client that is trying to use the command
   * @return whether or not the command was handled
   */
  handle(command: Command, client: Client): boolean {
    let handled: boolean = false;
    if (client.servers[command.name]) {
      if (client.server.name == command.name && client.connected) {
{'fraction_non_alphanumeric': 0.09779862865391556, 'fraction_numerical': 0.003608805485384338, 'mean_word_length': 3.5073170731707317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '363305', 'n_tokens_mistral': 760, 'n_tokens_neox': 753, 'n_words': 300}