summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions/TypingStart.js
blob: 4e79920f2453296ec2e36e349923f7fba2a8e76e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';

const Action = require('./Action');
const Typing = require('../../structures/Typing');
const Events = require('../../util/Events');

class TypingStart extends Action {
  handle(data) {
    const channel = this.getChannel(data);
    if (!channel) return;

    if (!channel.isTextBased()) {
      this.client.emit(Events.Warn, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
      return;
    }

    const user = this.getUserFromMember(data);
    if (user) {
      /**
       * Emitted whenever a user starts typing in a channel.
       * @event Client#typingStart
       * @param {Typing} typing The typing state
       */
      this.client.emit(Events.TypingStart, new Typing(channel, user, data));
    }
  }
}

module.exports = TypingStart;