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

[pull] master from Pycord-Development:master #54

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/todo-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Track TODO Action"
uses: ribtoks/[email protected].11-beta
uses: ribtoks/[email protected].12-beta
with:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
Expand Down
32 changes: 29 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ These changes are available on the `master` branch, but have not yet been releas

⚠️ **This Version Removes Support For Python 3.8** ⚠️

### Added

- Added `Guild.fetch_role` method.
([#2528](https://github.com/Pycord-Development/pycord/pull/2528))
- Added the following `AppInfo` attributes: `approximate_guild_count`,
`approximate_user_install_count`, `custom_install_url`, `install_params`,
`interactions_endpoint_url`, `redirect_uris`, `role_connections_verification_url`, and
`tags`. ([#2520](https://github.com/Pycord-Development/pycord/pull/2520))
- Added `Member.guild_banner` and `Member.display_banner` properties.
([#2556](https://github.com/Pycord-Development/pycord/pull/2556))

### Changed

- Renamed `cover` property of `ScheduledEvent` and `cover` argument of
Expand All @@ -20,10 +31,25 @@ These changes are available on the `master` branch, but have not yet been releas
- ⚠️ **This Version Removes Support For Python 3.8** ⚠️
([#2521](https://github.com/Pycord-Development/pycord/pull/2521))

### Added
### Deprecated

- Added `Guild.fetch_role` method.
([#2528](https://github.com/Pycord-Development/pycord/pull/2528))
- Deprecated `AppInfo.summary` in favor of `AppInfo.description`.
([#2520](https://github.com/Pycord-Development/pycord/pull/2520))

### Fixed

- Fixed `EntitlementIterator` behavior with `limit > 100`.
([#2555](https://github.com/Pycord-Development/pycord/pull/2555))
- Fixed missing `stacklevel` parameter in `warn_deprecated` function call inside
`@utils.deprecated`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500))
- Fixed the typehint in `ConnectionState._polls` to reflect actual behavior, changing it
from `Guild` to `Poll`.
([#2500](https://github.com/Pycord-Development/pycord/pull/2500))
- Fixed missing `__slots__` attributes in `RawReactionClearEmojiEvent` and
`RawMessagePollVoteEvent`.
([#2500](https://github.com/Pycord-Development/pycord/pull/2500))
- Fixed the type of `ForumChannel.default_sort_order`, changing it from `int` to
`SortOrder`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500))

## [2.6.0] - 2024-07-09

Expand Down
117 changes: 110 additions & 7 deletions discord/appinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@

from . import utils
from .asset import Asset
from .permissions import Permissions

if TYPE_CHECKING:
from .guild import Guild
from .state import ConnectionState
from .types.appinfo import AppInfo as AppInfoPayload
from .types.appinfo import AppInstallParams as AppInstallParamsPayload
from .types.appinfo import PartialAppInfo as PartialAppInfoPayload
from .types.appinfo import Team as TeamPayload
from .user import User

__all__ = (
"AppInfo",
"PartialAppInfo",
"AppInstallParams",
)


Expand Down Expand Up @@ -70,11 +73,6 @@ class AppInfo:
grant flow to join.
rpc_origins: Optional[List[:class:`str`]]
A list of RPC origin URLs, if RPC is enabled.
summary: :class:`str`
If this application is a game sold on Discord,
this field will be the summary field for the store page of its primary SKU.

.. versionadded:: 1.3

verify_key: :class:`str`
The hex encoded key for verification in interactions and the
Expand Down Expand Up @@ -110,6 +108,48 @@ class AppInfo:
The application's privacy policy URL, if set.

.. versionadded:: 2.0

approximate_guild_count: Optional[:class:`int`]
The approximate count of guilds to which the app has been added, if any.

.. versionadded:: 2.7

approximate_user_install_count: Optional[:class:`int`]
The approximate count of users who have installed the application, if any.

.. versionadded:: 2.7

redirect_uris: Optional[List[:class:`str`]]
The list of redirect URIs for the application, if set.

.. versionadded:: 2.7

interactions_endpoint_url: Optional[:class:`str`]
The interactions endpoint URL for the application, if set.

.. versionadded:: 2.7

role_connections_verification_url: Optional[:class:`str`]
The role connection verification URL for the application, if set.

.. versionadded:: 2.7

install_params: Optional[List[:class:`AppInstallParams`]]
The settings for the application's default in-app authorization link, if set.

.. versionadded:: 2.7

tags: Optional[List[:class:`str`]]
The list of tags describing the content and functionality of the app, if set.

Maximium of 5 tags.

.. versionadded:: 2.7

custom_install_url: Optional[:class:`str`]
The default custom authorization URL for the application, if set.

.. versionadded:: 2.7
"""

__slots__ = (
Expand All @@ -122,7 +162,7 @@ class AppInfo:
"bot_require_code_grant",
"owner",
"_icon",
"summary",
"_summary",
"verify_key",
"team",
"guild_id",
Expand All @@ -131,6 +171,14 @@ class AppInfo:
"_cover_image",
"terms_of_service_url",
"privacy_policy_url",
"approximate_guild_count",
"approximate_user_install_count",
"redirect_uris",
"interactions_endpoint_url",
"role_connections_verification_url",
"install_params",
"tags",
"custom_install_url",
)

def __init__(self, state: ConnectionState, data: AppInfoPayload):
Expand All @@ -149,7 +197,7 @@ def __init__(self, state: ConnectionState, data: AppInfoPayload):
team: TeamPayload | None = data.get("team")
self.team: Team | None = Team(state, team) if team else None

self.summary: str = data["summary"]
self._summary: str = data["summary"]
self.verify_key: str = data["verify_key"]

self.guild_id: int | None = utils._get_as_snowflake(data, "guild_id")
Expand All @@ -161,6 +209,24 @@ def __init__(self, state: ConnectionState, data: AppInfoPayload):
self._cover_image: str | None = data.get("cover_image")
self.terms_of_service_url: str | None = data.get("terms_of_service_url")
self.privacy_policy_url: str | None = data.get("privacy_policy_url")
self.approximate_guild_count: int | None = data.get("approximate_guild_count")
self.approximate_user_install_count: int | None = data.get(
"approximate_user_install_count"
)
self.redirect_uris: list[str] | None = data.get("redirect_uris", [])
self.interactions_endpoint_url: str | None = data.get(
"interactions_endpoint_url"
)
self.role_connections_verification_url: str | None = data.get(
"role_connections_verification_url"
)

install_params = data.get("install_params")
self.install_params: AppInstallParams | None = (
AppInstallParams(install_params) if install_params else None
)
self.tags: list[str] | None = data.get("tags", [])
self.custom_install_url: str | None = data.get("custom_install_url")

def __repr__(self) -> str:
return (
Expand Down Expand Up @@ -195,6 +261,23 @@ def guild(self) -> Guild | None:
"""
return self._state._get_guild(self.guild_id)

@property
def summary(self) -> str | None:
"""If this application is a game sold on Discord,
this field will be the summary field for the store page of its primary SKU.

It currently returns an empty string.

.. versionadded:: 1.3
.. deprecated:: 2.7
"""
utils.warn_deprecated(
"summary",
"description",
reference="https://discord.com/developers/docs/resources/application#application-object-application-structure",
)
return self._summary


class PartialAppInfo:
"""Represents a partial AppInfo given by :func:`~discord.abc.GuildChannel.create_invite`
Expand Down Expand Up @@ -257,3 +340,23 @@ def icon(self) -> Asset | None:
if self._icon is None:
return None
return Asset._from_icon(self._state, self.id, self._icon, path="app")


class AppInstallParams:
"""Represents the settings for the custom authorization URL of an application.

.. versionadded:: 2.7

Attributes
----------
scopes: List[:class:`str`]
The list of OAuth2 scopes for adding the application to a guild.
permissions: :class:`Permissions`
The permissions to request for the bot role in the guild.
"""

__slots__ = ("scopes", "permissions")

def __init__(self, data: AppInstallParamsPayload) -> None:
self.scopes: list[str] = data.get("scopes", [])
self.permissions: Permissions = Permissions(int(data["permissions"]))
13 changes: 13 additions & 0 deletions discord/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ def _from_guild_avatar(
animated=animated,
)

@classmethod
def _from_guild_banner(
cls, state, guild_id: int, member_id: int, banner: str
) -> Asset:
animated = banner.startswith("a_")
format = "gif" if animated else "png"
return cls(
state,
url=f"{cls.BASE}/guilds/{guild_id}/users/{member_id}/banners/{banner}.{format}?size=512",
key=banner,
animated=animated,
)

@classmethod
def _from_icon(cls, state, object_id: int, icon_hash: str, path: str) -> Asset:
return cls(
Expand Down
3 changes: 3 additions & 0 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,9 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None:
for tag in (data.get("available_tags") or [])
]
self.default_sort_order: SortOrder | None = data.get("default_sort_order", None)
if self.default_sort_order is not None:
self.default_sort_order = try_enum(SortOrder, self.default_sort_order)

reaction_emoji_ctx: dict = data.get("default_reaction_emoji")
if reaction_emoji_ctx is not None:
emoji_name = reaction_emoji_ctx.get("emoji_name")
Expand Down
31 changes: 2 additions & 29 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2592,35 +2592,6 @@ def bulk_upsert_guild_commands(
)
return self.request(r, json=payload)

# Application commands (permissions)

def get_command_permissions(
self,
application_id: Snowflake,
guild_id: Snowflake,
command_id: Snowflake,
) -> Response[interactions.GuildApplicationCommandPermissions]:
r = Route(
"GET",
"/applications/{application_id}/guilds/{guild_id}/commands/{command_id}/permissions",
application_id=application_id,
guild_id=guild_id,
)
return self.request(r)

def get_guild_command_permissions(
self,
application_id: Snowflake,
guild_id: Snowflake,
) -> Response[list[interactions.GuildApplicationCommandPermissions]]:
r = Route(
"GET",
"/applications/{application_id}/guilds/{guild_id}/commands/permissions",
application_id=application_id,
guild_id=guild_id,
)
return self.request(r)

# Guild Automod Rules

def get_auto_moderation_rules(
Expand Down Expand Up @@ -2858,6 +2829,8 @@ def delete_followup_message(
)
return self.request(r)

# Application commands (permissions)

def get_guild_application_command_permissions(
self,
application_id: Snowflake,
Expand Down
Loading
Loading