-
Notifications
You must be signed in to change notification settings - Fork 2
feat: enhanced onboarding MVP (rules accept, role menu, intro prompts) #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
97f2366
feat(onboarding): add rules acceptance and role menu flows
BillChirico 97c84f2
feat(dashboard): expose enhanced welcome onboarding settings
BillChirico 9452ba9
fix(dashboard): add nullish fallbacks when spreading partial welcome …
BillChirico 03a9c8a
fix(onboarding): normalize string config fields to null if empty or n…
BillChirico da41799
fix(onboarding): defer interactions early to prevent Discord 3s timeout
BillChirico 0188bf6
fix(onboarding): address PR review issues — adminOnly, enabled gate, …
BillChirico b90d216
fix(dashboard): use raw string state for role menu and DM sequence te…
BillChirico 5a933bd
fix(events): use !interaction.replied check in onboarding error fallb…
631d96c
test(welcomeOnboarding): add editReply mock to interaction fixtures
7214b5c
fix(welcome): add explicit warning when roleMenu built but channelId …
169fd08
fix(welcomeOnboarding): fix double-reply and Discord label 100-char l…
4624c4a
fix(configValidation): special-case null in array item type error mes…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| import { PermissionFlagsBits, SlashCommandBuilder } from 'discord.js'; | ||
| import { info } from '../logger.js'; | ||
| import { getConfig } from '../modules/config.js'; | ||
| import { | ||
| buildRoleMenuMessage, | ||
| buildRulesAgreementMessage, | ||
| normalizeWelcomeOnboardingConfig, | ||
| } from '../modules/welcomeOnboarding.js'; | ||
| import { isModerator } from '../utils/permissions.js'; | ||
| import { safeEditReply, safeSend } from '../utils/safeSend.js'; | ||
|
|
||
| export const adminOnly = true; | ||
|
|
||
| export const data = new SlashCommandBuilder() | ||
| .setName('welcome') | ||
| .setDescription('Welcome/onboarding admin helpers') | ||
| .addSubcommand((sub) => | ||
| sub.setName('setup').setDescription('Post rules agreement and role menu onboarding panels'), | ||
| ); | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export async function execute(interaction) { | ||
| await interaction.deferReply({ ephemeral: true }); | ||
|
|
||
| const guildConfig = getConfig(interaction.guildId); | ||
| if ( | ||
| !interaction.member.permissions.has(PermissionFlagsBits.Administrator) && | ||
| !isModerator(interaction.member, guildConfig) | ||
| ) { | ||
| await safeEditReply(interaction, { | ||
| content: '❌ You need moderator or administrator permissions to run this command.', | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| const onboarding = normalizeWelcomeOnboardingConfig(guildConfig?.welcome); | ||
| const resultLines = []; | ||
|
|
||
| if (onboarding.rulesChannel) { | ||
| const rulesChannel = | ||
| interaction.guild.channels.cache.get(onboarding.rulesChannel) || | ||
| (await interaction.guild.channels.fetch(onboarding.rulesChannel).catch(() => null)); | ||
|
|
||
| if (rulesChannel?.isTextBased?.()) { | ||
| const rulesMsg = buildRulesAgreementMessage(); | ||
| await safeSend(rulesChannel, rulesMsg); | ||
| resultLines.push(`✅ Posted rules agreement panel in <#${rulesChannel.id}>.`); | ||
| } else { | ||
| resultLines.push('⚠️ Could not find `welcome.rulesChannel`; rules panel not posted.'); | ||
| } | ||
| } else { | ||
| resultLines.push('⚠️ `welcome.rulesChannel` is not configured.'); | ||
| } | ||
|
|
||
| const roleMenuMsg = buildRoleMenuMessage(guildConfig?.welcome); | ||
| if (roleMenuMsg && guildConfig?.welcome?.channelId) { | ||
| const welcomeChannel = | ||
| interaction.guild.channels.cache.get(guildConfig.welcome.channelId) || | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (await interaction.guild.channels.fetch(guildConfig.welcome.channelId).catch(() => null)); | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (welcomeChannel?.isTextBased?.()) { | ||
| await safeSend(welcomeChannel, roleMenuMsg); | ||
| resultLines.push(`✅ Posted role menu in <#${welcomeChannel.id}>.`); | ||
| } else { | ||
| resultLines.push('⚠️ Could not find `welcome.channelId`; role menu not posted.'); | ||
| } | ||
| } else if (!roleMenuMsg) { | ||
| resultLines.push('⚠️ `welcome.roleMenu` is disabled or has no valid options.'); | ||
| } | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
BillChirico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| await safeEditReply(interaction, { | ||
| content: resultLines.join('\n'), | ||
| }); | ||
|
|
||
| info('Welcome setup command executed', { | ||
| guildId: interaction.guildId, | ||
| userId: interaction.user.id, | ||
| }); | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.