summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/structures/GuildOnboardingPrompt.js
blob: 4de3f5dd795815362aec66a55259c825e1cc684e (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';

const { Collection } = require('@discordjs/collection');
const Base = require('./Base');
const { GuildOnboardingPromptOption } = require('./GuildOnboardingPromptOption');

/**
 * Represents the data of a prompt of a guilds onboarding.
 * @extends {Base}
 */
class GuildOnboardingPrompt extends Base {
  constructor(client, data, guildId) {
    super(client);

    /**
     * The id of the guild this onboarding prompt is from
     * @type {Snowflake}
     */
    this.guildId = guildId;

    /**
     * The id of the prompt
     * @type {Snowflake}
     */
    this.id = data.id;

    /**
     * The options available within the prompt
     * @type {Collection<Snowflake, GuildOnboardingPromptOption>}
     */
    this.options = data.options.reduce(
      (options, option) => options.set(option.id, new GuildOnboardingPromptOption(client, option, guildId)),
      new Collection(),
    );

    /**
     * The title of the prompt
     * @type {string}
     */
    this.title = data.title;

    /**
     * Whether users are limited to selecting one option for the prompt
     * @type {boolean}
     */
    this.singleSelect = data.single_select;

    /**
     * Whether the prompt is required before a user completes the onboarding flow
     * @type {boolean}
     */
    this.required = data.required;

    /**
     * Whether the prompt is present in the onboarding flow.
     * If `false`, the prompt will only appear in the Channels & Roles tab
     * @type {boolean}
     */
    this.inOnboarding = data.in_onboarding;

    /**
     * The type of the prompt
     * @type {GuildOnboardingPromptType}
     */
    this.type = data.type;
  }

  /**
   * The guild this onboarding prompt is from
   * @type {Guild}
   * @readonly
   */
  get guild() {
    return this.client.guilds.cache.get(this.guildId);
  }
}

exports.GuildOnboardingPrompt = GuildOnboardingPrompt;