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

Support Guild Onboarding #9260

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Conversation

bijij
Copy link
Contributor

@bijij bijij commented Feb 25, 2023

Summary

This pull request implements support for the guild onboarding configuration.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • 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, ...)

@bijij bijij changed the title Begin implementaton of guild onboarding configuration support Support Guild Onboarding Feb 25, 2023
discord/onboarding.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
Co-authored-by: numbermaniac <5206120+numbermaniac@users.noreply.github.com>
discord/onboarding.py Outdated Show resolved Hide resolved
Co-authored-by: numbermaniac <5206120+numbermaniac@users.noreply.github.com>
@Puncher1
Copy link
Contributor

A few fields are missing, which I get:

"enable_default_channels": true,
"enable_onboarding_prompts": true,
"onboarding_prompts_seen": {},
"onboarding_responses_seen": {},
"responses": []

This would belong to Onboarding

@bijij bijij marked this pull request as ready for review April 1, 2023 12:12
@Puncher1
Copy link
Contributor

The guild features could be added to this PR too:

  • GUILD_ONBOARDING_EVER_ENABLED
  • GUILD_SERVER_GUIDE
  • GUILD_ONBOARDING
  • GUILD_ONBOARDING_HAS_PROMPTS

Also the audit log events: discord/discord-api-docs#6041

Copy link
Owner

@Rapptz Rapptz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably add support for the audit log stuff as well.

discord/guild.py Outdated Show resolved Hide resolved
discord/onboarding.py Outdated Show resolved Hide resolved
discord/guild.py Outdated Show resolved Hide resolved
@Rapptz Rapptz added the pending PR implements an in-progress or explicitly unreleased Discord feature label Apr 18, 2023
@bijij bijij requested a review from Rapptz July 1, 2023 15:41
@Puncher1
Copy link
Contributor

The fields of the prompt option have changed: discord/discord-api-docs#6479

Looks like the emoji isn't implemented at all for editing yet.

Copy link
Contributor

@Puncher1 Puncher1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency

discord/http.py Outdated Show resolved Hide resolved
discord/guild.py Outdated Show resolved Hide resolved
@bijij bijij requested a review from Puncher1 November 9, 2023 14:20
@Puncher1
Copy link
Contributor

The name of some audit log actions have changed and 2 new actions have been added, see discord/discord-api-docs#6041

I think it doesn't make sense to change the name of the server guide actions too, because the description kept the same and so the current names are more meaningful.

Copy link
Contributor

@DA-344 DA-344 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comments

class Onboarding(TypedDict):
guild_id: Snowflake
prompts: list[Prompt]
default_channel_ids: list[Snowflake]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default_channel_ids: list[Snowflake]
default_channel_ids: List[Snowflake]


class Onboarding(TypedDict):
guild_id: Snowflake
prompts: list[Prompt]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prompts: list[Prompt]
prompts: List[Prompt]


class Prompt(TypedDict):
id: Snowflake
options: list[PromptOption]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options: list[PromptOption]
options: List[PromptOption]

class PromptOption(TypedDict):
id: Snowflake
channel_ids: list[Snowflake]
role_ids: list[Snowflake]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
role_ids: list[Snowflake]
role_ids: List[Snowflake]


class PromptOption(TypedDict):
id: Snowflake
channel_ids: list[Snowflake]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
channel_ids: list[Snowflake]
channel_ids: List[Snowflake]


from __future__ import annotations

from typing import Literal, Optional, TypedDict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from typing import Literal, Optional, TypedDict
from typing import Literal, Optional, TypedDict, List

def __init__(
self,
title: str,
emoji: Union[Emoji, PartialEmoji, str],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring marks this as optional.

Suggested change
emoji: Union[Emoji, PartialEmoji, str],
emoji: Optional[Union[Emoji, PartialEmoji, str]],

) -> None:
self.title: str = title
self.description: Optional[str] = description
self.emoji: Union[PartialEmoji, Emoji, str] = emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be parsing strs into PartialEmojis.

Suggested change
self.emoji: Union[PartialEmoji, Emoji, str] = emoji
self.emoji: Optional[Union[PartialEmoji, Emoji]] = PartialEmoji.from_str(emoji) if isinstance(emoji, str) else emoji

self.channel_ids: Set[int] = set(channel_ids or [])
self.role_ids: Set[int] = set(role_ids or [])

def to_dict(self, *, id: int = MISSING) -> PromptOptionPayload:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be updated for the change, using self.emoji._to_partial then handling the rest

}

return {
'id': id or os.urandom(16).hex(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be always MISSING when no value is passed🤔? Shouldn't this be a id if id is not MISSING else os.urandom(16).hex()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending PR implements an in-progress or explicitly unreleased Discord feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants