summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions/ThreadCreate.js
blob: a8ff6c6ff146f7276196666acb36754746cc04d3 (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
'use strict';

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

class ThreadCreateAction extends Action {
  handle(data) {
    const client = this.client;
    const existing = client.channels.cache.has(data.id);
    const thread = client.channels._add(data);
    if (!existing && thread) {
      /**
       * Emitted whenever a thread is created or when the client user is added to a thread.
       * @event Client#threadCreate
       * @param {ThreadChannel} thread The thread that was created
       * @param {boolean} newlyCreated Whether the thread was newly created
       */
      client.emit(Events.ThreadCreate, thread, data.newly_created ?? false);
    }
    return { thread };
  }
}

module.exports = ThreadCreateAction;