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: Clans #9899

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft

feat: Clans #9899

wants to merge 15 commits into from

Conversation

DA-344
Copy link
Contributor

@DA-344 DA-344 commented Aug 2, 2024

Summary

WIP
Adds support for clans and member verification (clans join forms).

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, ...)

discord/http.py Outdated
Comment on lines 2527 to 2562
def create_clan(self, guild_id: int, **params: Any) -> Response[None]:
valid_keys = (
'tag',
'game_application_ids',
'search_terms',
'play_style',
'description',
'wildcard_descriptors',
'badge',
'badge_color_primary',
'badge_color_secondary',
'banner',
'brand_color_primary',
'brand_color_secondary',
'verification_form',
)
payload = {k: v for k, v in params.items() if k in valid_keys}

return self.request(
Route(
'POST',
'/clan/{guild_id}',
guild_id=guild_id,
),
json=payload,
)

def get_clan_settings(self, guild_id: int) -> Response[clan.ClanSettings]:
return self.request(
Route(
'GET',
'/clan/{guild_id}/settings',
guild_id=guild_id,
),
)

Copy link
Contributor

Choose a reason for hiding this comment

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

These endpoints are not available for bots.

  • get_clan and get_clans are undocumented.

discord/guild.py Outdated
Comment on lines 4466 to 4520
async def create_clan(
self,
*,
tag: str,
games: Sequence[Snowflake],
search_terms: List[str],
play_style: ClanPlayStyle,
description: str,
wildcard_descriptors: List[str],
badge_type: ClanBadgeType,
badge_primary_colour: Colour = MISSING,
badge_primary_color: Colour = MISSING,
badge_secondary_colour: Colour = MISSING,
badge_secondary_color: Colour = MISSING,
banner_style: ClanBannerStyle,
banner_primary_colour: Colour = MISSING,
banner_primary_color: Colour = MISSING,
banner_secondary_colour: Colour = MISSING,
banner_secondary_color: Colour = MISSING,
verification_form: MemberVerification,
) -> None:
"""|coro|

Creates a new clan from this guild.

Raises
------
Forbidden
You donnot have enough permissions to create a clan for this
guild.
HTTPException
An error occurred while creating the guild clan.
"""

actual_badge_prim_col = badge_primary_colour or badge_primary_color
actual_badge_sec_col = badge_secondary_colour or badge_secondary_color
actual_banner_prim_col = banner_primary_colour or banner_primary_color
actual_banner_sec_col = banner_secondary_colour or banner_secondary_color

await self._state.http.create_clan(
self.id,
tag=tag,
game_application_ids=[str(g.id) for g in games],
search_terms=search_terms,
description=description,
play_style=play_style.value,
wildcard_descriptors=wildcard_descriptors,
badge=badge_type.value,
banner=banner_style.value,
badge_color_primary=actual_badge_prim_col,
badge_color_secondary=actual_badge_sec_col,
brand_color_primary=actual_banner_prim_col,
brand_color_secondary=actual_banner_sec_col,
verification_form=verification_form._to_dict()
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as HTTPClient.create_clan

discord/clan.py Outdated
Comment on lines 88 to 91
self.guild_id: int = int(data['identity_guild_id'])
self.enabled: bool = data['identity_enabled']
self.tag: str = data['tag']
self._badge_hash: str = data['badge']
Copy link
Contributor

Choose a reason for hiding this comment

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

identity_guild_id, tag, badge all might be null if identity_enabled is false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants