Skip to content

feat: Add guild onboarding settings #1646

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 1 commit into from
Apr 23, 2024

Conversation

david-why
Copy link
Contributor

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

Add fetch_onboarding method to Guild objects to allow viewing and modifying guild onboarding settings. Usage example:

onboarding = await guild.fetch_onboarding()
await onboarding.edit(prompts=[], default_channel_ids=[], enabled=False, mode=0)
assert not (onboarding.prompts or onboarding.default_channel_ids or onboarding.enabled)
emoji = PartialEmoji(name=CUSTOM_EMOJI_NAME, id=CUSTOM_EMOJI_ID)
options = [
    OnboardingPromptOption.create('Option 1', role_ids=[ROLE_ID_1], emoji=emoji),
    OnboardingPromptOption.create('Option 2', role_ids=[ROLE_ID_2], emoji='⭐'),
]
prompt = OnboardingPrompt.create(title='Question', options=options, required=True, single_select=True)
await onboarding.edit(prompts=[prompt], default_channel_ids=[CATEGORY_ID], enabled=True, mode=1)
assert (
    onboarding.enabled
    and len(onboarding.prompts) == 1
    and len(onboarding.prompts[0].options) == 2
    and onboarding.prompts[0].title == 'Question'
    and onboarding.prompts[0].required
    and onboarding.prompts[0].single_select
    and onboarding.prompts[0].options[0].title == 'Option 1'
)
await onboarding.edit(enabled=False)

Changes

  • Add get_guild_onboarding and modify_guild_onboarding methods to GuildRequests
  • Add Onboarding, OnboardingPrompt, and OnboardingPromptOption classes
  • Add OnboardingMode and OnboardingPromptType enums
  • Add fetch_onboarding method to Guild

Related Issues

#1645

Test Scenarios

Try to edit the onboarding settings for a guild and ensure they are changed (similar to the example given above)

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@eightween eightween added documentation Improvements or additions to documentation enhancement New feature or request pending Pending approve labels Mar 30, 2024
@david-why
Copy link
Contributor Author

david-why commented Apr 13, 2024

I just rebased from the current interactions-py:unstable branch to keep this PR up-to-date.

@eightween
Copy link
Member

Waiting for more approvals before a merge can be done

@silasary silasary merged commit be8df66 into interactions-py:unstable Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request pending Pending approve
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants