lib/router/response.js   A
last analyzed

Size

Lines of Code 51

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
nc 1
dl 0
loc 51
rs 10
noi 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A response.js ➔ ??? 0 12 1
1
/**
2
 *
3
 * The FisheReponse used in a fisherCallback
4
 * @class FisherResponse
5
 */
6
class FisherResponse {
7
    /**
8
     * Creates an instance of FisherResponse.
9
     * @param {Fisherman} client
10
     * @param {FisherRouter} router
11
     */
12
  constructor (client, router) {
13
        /**
14
         * @private
15
         * @type {FisherRouter}
16
         */
17
    this.router = router
18
        /**
19
         * @private
20
         * @type {Fisherman}
21
         */
22
    this.client = client
23
  }
24
    /**
25
     *
26
     * Emit a "fisherCode" event
27
     * @param {(number|FisherCode)} code The code to send
28
     * @param {Error} [err = null] An error to pass
0 ignored issues
show
Documentation Bug introduced by
The parameter [err does not exist. Did you maybe mean err instead?
Loading history...
29
     * @fires Fisherman#fisherCode
30
     * @memberof FisherResponse
31
     */
32
  sendCode (code, err = null) {
33
    /**
34
     * Emitted when a fisherCode is by the router, or when something bad happenned
35
     * @event Fisherman#fisherCode
36
     * @param {FisherRouter} router the router
37
     * @param {FisherCode} code the fisherman code
38
     * @param {Error} err the error
39
     */
40
    this.client.emit('fisherCode', this.router, code, err)
41
  }
42
43
    /**
44
     *
45
     * Same as channel.send()
46
     * @see https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=send
47
     * @param {string} text
48
     * @param {Object} [data = {}]
0 ignored issues
show
Documentation Bug introduced by
The parameter [data does not exist. Did you maybe mean data instead?
Loading history...
49
     * @returns {Promise<Message|Message[]>}
50
     * @memberof FisherResponse
51
     */
52
  send (text, data = {}) {
53
    return this.router.request.channel.send(text, data)
54
  }
55
}
56
module.exports = FisherResponse
57