-
-
Notifications
You must be signed in to change notification settings - Fork 482
feat: Guild Builder #2662
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: Guild Builder #2662
Conversation
As mentioned by @NeloBlivion too, the builder feature does not in my opinion too belong to the core
https://discord.com/channels/881207955029110855/881735314987708456/1311779043531558935 But I am happy to discuss on this. |
Yeah, it is mentioned on the PR message:
|
…into feat/create-guild-parameters
…344/pycord into feat/create-guild-parameters
def delete_guild(self, guild_id: Snowflake) -> Response[None]: | ||
return self.request(Route("DELETE", "/guilds/{guild_id}", guild_id=guild_id)) | ||
|
||
def create_guild(self, name: str, icon: str | None) -> Response[guild.Guild]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The icon parameter is removed, was it used anywhere in the library ? Just make sure this is changed everywhere it should be. Otherwise this is fine and not considered breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The icon parameter is a key for payload
so it is not required as a parameter anymore, and no, this method is only used on Client.create_guild
.
failed_users: list[Snowflake] | ||
|
||
|
||
class GuildCreate(TypedDict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class GuildCreate(TypedDict): | |
class GuildCreatePayload(TypedDict): |
Attributes | ||
---------- | ||
code: Optional[:class:`str`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe smth more explicit than just code
? E.g. template_code
.
self.system_channel_id: int | None = None | ||
self.system_channel_flags: SystemChannelFlags | None = None | ||
|
||
async def _do_create(self) -> Guild: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be public, to allow devs to use it as an alternative to the __await__
approach, but maybe under another name than do_create
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on this, just calling await GuildBuilder()
seems too ambiguous
category_id: Optional[:class:`int`] | ||
The category placeholder ID this channel belongs to. | ||
bitrate: :class:`int` | ||
The channel bitrate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missindented
if afk_timeout is not MISSING: | ||
metadata["afk_timeout"] = afk_timeout | ||
|
||
# TODO: remove support of passing ``None`` to ``icon``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why you rewrote it like this, the old code for icon
was sufficient
if code is MISSING: | ||
code = None # type: ignore | ||
|
||
if code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't know if code
should use GuildBuilder
, considering all the new parameters would be ignored (if anything it should raise a ValueError for passing it with them), though regardless i suggest create_guild
be completely detached from GuildBuilder
so all of its logic can remain isolated in build_guild
(though i think you've said you're planning on this, either way there's no rush)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why type ignore ? If needed used an overload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this isn't in the scope for the core library. It would be a better fit as (community-)extension.
I generally agree, but the main motivation for this PR is adding support for That being said, this approach isn't ideal because we're effectively duplicating parts of the existing role and channel classes just for the sake of a relatively niche endpoint for bots (not by fault of OP, this just wasn't considered necessary in the original design). This might benefit from being held off until we have more widely applicable objects (e.g. Partial objects where users can assign any valid attributes beyond just ID for any valid model, or maybe in 3.0 we could let users arbitrarily instantiate Discord Models) |
Yeah. Since I only see it from discords side, the core is working as intended. Yeah is not friendly, but that's the api.
Agreed
Also agreed, I'm gonna be marking this PR on hold until further notice. It's not in the scope of 2.X releases. |
Summary
This PR adds a new guild builder to allow users to better customize a guild before creating it (see POST /guilds)
Current implementation changes the
create_guild
logic but it is going to be changed to a new method calledbuild_guild
.I will try to add all the available parameters to
create_guild
in a understandable way.Information
examples, ...).
Checklist
type: ignore
comments were used, a comment is also left explaining why.