Skip to content
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

feat: Implement Onboarding features #2127

Merged
merged 41 commits into from Jan 31, 2024

Conversation

NeloBlivion
Copy link
Member

@NeloBlivion NeloBlivion commented Jun 16, 2023

Summary

Construction hammered a hole through my ceiling and woke me up way too early so i implemented onboarding, probably.

  • All relevant types and enums
  • GET endpoint - await guild.onboarding()
  • PUT endpoint - await Onboarding.edit(...) or await guild.edit_onboarding(...) to avoid multiple requests
  • Updated some audit log events

References:

There is some jank due to this feature still being incomplete(?), but everything should be working. Probably needs more review due to inconsistent typing and lack of knowledge on the endpoint (emoji??).

  • You can edit onboarding even if you aren't in a community server
  • All OnboardingPrompts and PromptOptions require a (sometimes unique) snowflake to edit even if created by the user, but it can be any value; since it isn't relevant for the user to submit one, randint (lol) will be used when not supplied.

Example: Adding a prompt to an existing onboarding flow

flow = await guild.onboarding()
prompts = flow.prompts
new_prompt = OnboardingPrompt(
    title="Pick a colour!",
    required=True,
    single_select=True,  # Single vs. multiple choice
    in_onboarding=False,  # Don't show to user on join
    options=[
        PromptOption(title="Red", emoji="🍎", roles=[guild.get_role(RED_ROLE_ID)]),
        PromptOption(title="Blue", description="water", channels=[guild.get_channel(BLUE_CHANNEL_ID)])
    ]
)
prompts.append(new_prompt)
await flow.edit(prompts=prompts)

Perhaps it would be beneficial to add further functions out of the API scope like Onboarding.add_prompt etc. etc.

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Merging #2127 (cbcadf2) into master (297053d) will decrease coverage by 0.01%.
Report is 16 commits behind head on master.
The diff coverage is 32.62%.

❗ Current head cbcadf2 differs from pull request most recent head c7741ac. Consider uploading reports for the commit c7741ac to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2127      +/-   ##
==========================================
- Coverage   33.86%   33.85%   -0.01%     
==========================================
  Files         109      110       +1     
  Lines       22367    22508     +141     
==========================================
+ Hits         7575     7621      +46     
- Misses      14792    14887      +95     
Flag Coverage Δ
macos-latest-3.10 33.83% <32.62%> (-0.01%) ⬇️
macos-latest-3.11 33.83% <32.62%> (-0.01%) ⬇️
macos-latest-3.8 33.84% <32.62%> (-0.01%) ⬇️
macos-latest-3.9 33.84% <32.62%> (-0.01%) ⬇️
ubuntu-latest-3.10 33.83% <32.62%> (-0.01%) ⬇️
ubuntu-latest-3.11 33.83% <32.62%> (-0.01%) ⬇️
ubuntu-latest-3.8 33.84% <32.62%> (-0.01%) ⬇️
ubuntu-latest-3.9 33.84% <32.62%> (-0.01%) ⬇️
windows-latest-3.10 33.83% <32.62%> (-0.01%) ⬇️
windows-latest-3.11 33.83% <32.62%> (-0.01%) ⬇️
windows-latest-3.8 33.84% <32.62%> (-0.01%) ⬇️
windows-latest-3.9 33.84% <32.62%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
discord/guild.py 23.63% <18.75%> (-0.09%) ⬇️
discord/onboarding.py 27.61% <27.61%> (ø)
discord/http.py 24.35% <33.33%> (+0.06%) ⬆️
discord/enums.py 82.45% <84.61%> (+0.04%) ⬆️
discord/__init__.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0763261...c7741ac. Read the comment docs.

@Lulalaby Lulalaby added this to the v2.5 milestone Jun 16, 2023
@Lulalaby Lulalaby added priority: medium Medium Priority feature Implements a feature labels Jun 16, 2023
discord/enums.py Outdated Show resolved Hide resolved
discord/enums.py Show resolved Hide resolved
discord/types/onboarding.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
NeloBlivion and others added 9 commits January 31, 2024 15:43
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
@NeloBlivion
Copy link
Member Author

As far as I'm aware, this last push fully covers the onboarding features. It also includes the new convenience functions add/append_prompt, get_prompt and delete_prompt.

discord/guild.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
NeloBlivion and others added 4 commits January 31, 2024 18:45
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Dorukyum
Dorukyum previously approved these changes Jan 31, 2024
@Dorukyum Dorukyum enabled auto-merge (squash) January 31, 2024 19:23
Signed-off-by: Lala Sabathil <lala@pycord.dev>
@Dorukyum Dorukyum merged commit 6ba54b4 into Pycord-Development:master Jan 31, 2024
29 checks passed
OmLanke pushed a commit to OmLanke/pycord that referenced this pull request Feb 9, 2024
* initial onboarding impl.

* Implement main edit function

* implement shorthand edit

* typo

* better doc

* misc

* fix enums

* fix repr

* docs adjust

* fix edit args

* import fixes

* docs clarify

* final touches?

* randint...?

* style(pre-commit): auto fixes from pre-commit.com hooks

* typefix

* style(pre-commit): auto fixes from pre-commit.com hooks

* docs updates

* cleanup

* style(pre-commit): auto fixes from pre-commit.com hooks

* Update enum

Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>

* Update enums

Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>

* Replace _guild with guild

Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>

* Add new PromptOptions fields

Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>

* Update to_dict for emoji changes and exchange randint for generate_snowflake

* style(pre-commit): auto fixes from pre-commit.com hooks

* Final push

* style(pre-commit): auto fixes from pre-commit.com hooks

* remove debug lines

* thanku doruk

Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>

* chore: minimal changes

* chore: finalize

* chore: promise this is the last

---------

Signed-off-by: Lala Sabathil <lala@pycord.dev>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Lala Sabathil <lala@pycord.dev>
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog needed feature Implements a feature priority: medium Medium Priority
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants