-
-
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.
* feat: guild onboarding * feat: types and /core method * fix: route * fix: make emoji name non-nullable --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a48d0ef
commit dc73c93
Showing
9 changed files
with
393 additions
and
92 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict'; | ||
|
||
const { Collection } = require('@discordjs/collection'); | ||
const Base = require('./Base'); | ||
const { GuildOnboardingPrompt } = require('./GuildOnboardingPrompt'); | ||
|
||
/** | ||
* Represents the onboarding data of a guild. | ||
* @extends {Base} | ||
*/ | ||
class GuildOnboarding extends Base { | ||
constructor(client, data) { | ||
super(client); | ||
|
||
/** | ||
* The id of the guild this onboarding data is for | ||
* @type {Snowflake} | ||
*/ | ||
this.guildId = data.guild_id; | ||
|
||
const guild = this.guild; | ||
|
||
/** | ||
* The prompts shown during onboarding and in customize community | ||
* @type {Collection<Snowflake, GuildOnboardingPrompt>} | ||
*/ | ||
this.prompts = data.prompts.reduce( | ||
(prompts, prompt) => prompts.set(prompt.id, new GuildOnboardingPrompt(client, prompt, this.guildId)), | ||
new Collection(), | ||
); | ||
|
||
/** | ||
* The ids of the channels that new members get opted into automatically | ||
* @type {Collection<Snowflake, GuildChannel>} | ||
*/ | ||
this.defaultChannels = data.default_channel_ids.reduce( | ||
(channels, channelId) => channels.set(channelId, guild.channels.cache.get(channelId)), | ||
new Collection(), | ||
); | ||
|
||
/** | ||
* Whether onboarding is enabled | ||
* @type {boolean} | ||
*/ | ||
this.enabled = data.enabled; | ||
} | ||
|
||
/** | ||
* The guild this onboarding is from | ||
* @type {Guild} | ||
* @readonly | ||
*/ | ||
get guild() { | ||
return this.client.guilds.cache.get(this.guildId); | ||
} | ||
} | ||
|
||
exports.GuildOnboarding = GuildOnboarding; |
78 changes: 78 additions & 0 deletions
78
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,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; |
Oops, something went wrong.