-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
220 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/discord.js/src/structures/GuildOnboardingPrompt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'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 of the prompt | ||
* @type {Collection<Snowflake, GuildOnboardingPromptOption>} | ||
*/ | ||
this.options = data.options.reduce((options, option) => { | ||
options.set(option.id, new GuildOnboardingPromptOption(client, option, guildId)); | ||
return options; | ||
}, new Collection()); | ||
|
||
/** | ||
* The title of the prompt | ||
* @type {string} | ||
*/ | ||
this.title = data.title; | ||
|
||
/** | ||
* Whether only option of the prompt can be selected at a time | ||
* @type {boolean} | ||
*/ | ||
this.singleSelect = data.single_select; | ||
|
||
/** | ||
* Whether the prompt is required in the onboarding flow | ||
* @type {boolean} | ||
*/ | ||
this.required = data.required; | ||
|
||
/** | ||
* Whether the prompt is in the onboarding flow | ||
* @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; |
85 changes: 85 additions & 0 deletions
85
packages/discord.js/src/structures/GuildOnboardingPromptOption.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use strict'; | ||
|
||
const { Collection } = require('@discordjs/collection'); | ||
const Base = require('./Base'); | ||
|
||
/** | ||
* Represents the data of an option from a prompt of a guilds onboarding. | ||
* @extends {Base} | ||
*/ | ||
class GuildOnboardingPromptOption extends Base { | ||
constructor(client, data, guildId) { | ||
super(client); | ||
|
||
const guild = this.guild; | ||
|
||
/** | ||
* The id of the guild this onboarding prompt option is from | ||
* @type {Snowflake} | ||
*/ | ||
this.guildId = guildId; | ||
|
||
/** | ||
* The id of the option | ||
* @type {Snowflake} | ||
*/ | ||
this.id = data.id; | ||
|
||
/** | ||
* The channels opted in when this option is selected | ||
* @type {Collection<Snowflake, GuildChannel>} | ||
*/ | ||
this.channels = data.channel_ids.reduce((channels, channelId) => { | ||
channels.set(channelId, guild.channels.cache.get(channelId)); | ||
return channels; | ||
}, new Collection()); | ||
|
||
/** | ||
* The roles assigned when this option is selected | ||
* @type {Collection<Snowflake, Role>} | ||
*/ | ||
this.roles = data.role_ids.reduce((roles, roleId) => { | ||
roles.set(roleId, guild.roles.cache.get(roleId)); | ||
return roles; | ||
}, new Collection()); | ||
|
||
/** | ||
* The data for an emoji of a guilds onboarding prompt option | ||
* @typedef {Object} GuildOnboardingPromptOptionEmoji | ||
* @property {?Snowflake} id The id of the emoji | ||
* @property {?string} name The name of the emoji | ||
*/ | ||
|
||
/** | ||
* The emoji of the option | ||
* @type {GuildOnboardingPromptOptionEmoji} | ||
*/ | ||
this.emoji = { | ||
id: data.emoji_id, | ||
name: data.emoji_name, | ||
}; | ||
|
||
/** | ||
* The title of the option | ||
* @type {string} | ||
*/ | ||
this.title = data.title; | ||
|
||
/** | ||
* The description of the option | ||
* @type {?string} | ||
*/ | ||
this.description = data.description; | ||
} | ||
|
||
/** | ||
* The guild this onboarding prompt option is from | ||
* @type {Guild} | ||
* @readonly | ||
*/ | ||
get guild() { | ||
return this.client.guilds.cache.get(this.guildId); | ||
} | ||
} | ||
|
||
exports.GuildOnboardingPromptOption = GuildOnboardingPromptOption; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters