old_contents: const AbstractHandler = require('./AbstractHandler');
  const Constants = require('../../../../util/Constants');
  
  class TypingStartHandler extends AbstractHandler {
    handle(packet) {
      const client = this.packetManager.client;
      const data = packet.d;
      const channel = client.channels.get(data.channel_id);
      const user = client.users.get(data.user_id);
      const timestamp = new Date(data.timestamp * 1000);
  
      if (channel && user) {
        if (channel.type === 'voice') {
          return client.emit('warn', `Discord sent a typing packet to voice channel ${channel.id}`);
        }
        if (channel._typing.has(user.id)) {
          const typing = channel._typing.get(user.id);
          typing.lastTimestamp = timestamp;
          typing.resetTimeout(tooLate(channel, user));
        } else {
          channel._typing.set(user.id, new TypingData(timestamp, timestamp, tooLate(channel, user)));
          client.emit(Constants.Events.TYPING_START, channel, user);
        }
      }
    }
  }
  
  class TypingData {
    constructor(since, lastTimestamp, _timeout) {
      this.since = since;
      this.lastTimestamp = lastTimestamp;
      this._timeout = _timeout;
    }
  
    resetTimeout(_timeout) {
      clearTimeout(this._timeout);
      this._timeout = _timeout;
    }
  
    get elapsedTime() {
      return Date.now() - this.since;
    }
  }
  
  function tooLate(channel, user) {
    return channel.client.setTimeout(() => {
      channel.client.emit(Constants.Events.TYPING_STOP, channel, user, channel._typing.get(user.id));
      channel._typing.delete(user.id);
    }, 6000);
  }
  
  /**
   * Emitted whenever a user starts typing in a channel
   * @event Client#typingStart
   * @param {Channel} channel The channel the user started typing in
   * @param {User} user The user that started typing
   */
  
  /**
   * Emitted whenever a user stops typing in a channel
   * @event Client#typingStop
   * @param {Channel} channel The channel the user stopped typing in
   * @param {User} user The user that stopped typing
   */
  
  module.exports = TypingStartHandler;
  
new_contents: const AbstractHandler = require('./AbstractHandler');
  const Constants = require('../../../../util/Constants');
  
  class TypingStartHandler extends AbstractHandler {
    handle(packet) {
      const client = this.packetManager.client;
      const data = packet.d;
      const channel = client.channels.get(data.channel_id);
      const user = client.users.get(data.user_id);
      const timestamp = new Date(data.timestamp * 1000);
  
      if (channel && user) {
        if (channel.type === 'voice') {
          client.emit('warn', `Discord sent a typing packet to voice channel ${channel.id}`);
          return;
        }
        if (channel._typing.has(user.id)) {
          const typing = channel._typing.get(user.id);
          typing.lastTimestamp = timestamp;
          typing.resetTimeout(tooLate(channel, user));
        } else {
          channel._typing.set(user.id, new TypingData(timestamp, timestamp, tooLate(channel, user)));
          client.emit(Constants.Events.TYPING_START, channel, user);
        }
      }
    }
  }
  
  class TypingData {
    constructor(since, lastTimestamp, _timeout) {
      this.since = since;
      this.lastTimestamp = lastTimestamp;
      this._timeout = _timeout;
    }
  
    resetTimeout(_timeout) {
      clearTimeout(this._timeout);
      this._timeout = _timeout;
    }
  
    get elapsedTime() {
      return Date.now() - this.since;
    }
  }
  
  function tooLate(channel, user) {
    return channel.client.setTimeout(() => {
      channel.client.emit(Constants.Events.TYPING_STOP, channel, user, channel._typing.get(user.id));
      channel._typing.delete(user.id);
    }, 6000);
  }
  
  /**
   * Emitted whenever a user starts typing in a channel
   * @event Client#typingStart
   * @param {Channel} channel The channel the user started typing in
   * @param {User} user The user that started typing
   */
  
  /**
   * Emitted whenever a user stops typing in a channel
   * @event Client#typingStop
   * @param {Channel} channel The channel the user stopped typing in
   * @param {User} user The user that stopped typing
   */
  
  module.exports = TypingStartHandler;
  
subject: Fix Hydra's ESLint failure