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: add BotIntegration.scopes #729

Merged
merged 4 commits into from Sep 3, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/729.feature.rst
@@ -0,0 +1 @@
Add :attr:`BotIntegration.scopes`.
19 changes: 16 additions & 3 deletions disnake/integrations.py
Expand Up @@ -26,7 +26,7 @@
from __future__ import annotations

import datetime
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Type
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type

from .enums import ExpireBehaviour, try_enum
from .user import User
Expand Down Expand Up @@ -409,13 +409,26 @@ class BotIntegration(Integration):
The integration account information.
application: :class:`IntegrationApplication`
The application tied to this integration.
scopes: List[:class:`str`]
onerandomusername marked this conversation as resolved.
Show resolved Hide resolved
The OAuth2 scopes the application has been authorized for.

.. versionadded:: 2.6
"""

__slots__ = ("application",)
__slots__ = ("application", "scopes")

def _from_data(self, data: BotIntegrationPayload) -> None:
super()._from_data(data)
self.application = IntegrationApplication(data=data["application"], state=self._state)
self.application: IntegrationApplication = IntegrationApplication(
data=data["application"], state=self._state
)
self.scopes: List[str] = data.get("scopes") or []

def __repr__(self):
return (
f"<{self.__class__.__name__} id={self.id}"
f" name={self.name!r} scopes={self.scopes!r}>"
)


def _integration_factory(value: str) -> Tuple[Type[Integration], str]:
Expand Down
3 changes: 2 additions & 1 deletion disnake/types/integration.py
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

from typing import Literal, Optional, TypedDict, Union
from typing import List, Literal, Optional, TypedDict, Union

from .snowflake import Snowflake
from .user import User
Expand Down Expand Up @@ -83,6 +83,7 @@ class StreamIntegration(BaseIntegration):

class BotIntegration(BaseIntegration):
application: IntegrationApplication
scopes: List[str]


Integration = Union[BaseIntegration, StreamIntegration, BotIntegration]