Skip to content

Commit

Permalink
feat: Implement app_permissions attribute to Context. (#897)
Browse files Browse the repository at this point in the history
* feat: Implement app_permissions attribute to Context.

* fix: Add to headers.
  • Loading branch information
FayeDel authored Jun 30, 2022
1 parent 40162de commit f3005a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion interactions/client/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from ..api.error import LibraryException
from ..api.http.client import HTTPClient
from ..api.models.attrs_utils import MISSING, ClientSerializerMixin, define, field
from ..api.models.attrs_utils import MISSING, ClientSerializerMixin, convert_int, define, field
from ..api.models.channel import Channel
from ..api.models.flags import Permissions
from ..api.models.guild import Guild
from ..api.models.member import Member
from ..api.models.message import Attachment, Embed, Message, MessageInteraction, MessageReference
Expand Down Expand Up @@ -61,6 +62,7 @@ class _Context(ClientSerializerMixin):
channel_id: Snowflake = field(converter=Snowflake)
responded: bool = field(default=False)
deferred: bool = field(default=False)
app_permissions: Permissions = field(converter=convert_int(Permissions), default=None)

def __attrs_post_init__(self) -> None:
# backwards compatibility
Expand Down Expand Up @@ -322,6 +324,7 @@ class CommandContext(_Context):
:ivar bool deferred: Whether the response was deferred or not.
:ivar str locale?: The selected language of the user invoking the interaction.
:ivar str guild_locale?: The guild's preferred language, if invoked in a guild.
:ivar str app_permissions?: Bitwise set of permissions the bot has within the channel the interaction was sent from.
"""

target: Optional[Union[Message, Member, User]] = field(default=None)
Expand Down
2 changes: 2 additions & 0 deletions interactions/client/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from ..api.http.client import HTTPClient
from ..api.models.attrs_utils import ClientSerializerMixin, define
from ..api.models.channel import Channel as Channel
from ..api.models.guild import Guild as Guild
from ..api.models.flags import Permissions
from ..api.models.member import Member as Member
from ..api.models.message import Embed as Embed
from ..api.models.message import Message as Message
Expand Down Expand Up @@ -43,6 +44,7 @@ class _Context(ClientSerializerMixin):
channel_id: Snowflake
responded: bool
deferred: bool
app_permissions: Permissions
def __attrs_post_init__(self) -> None: ...
async def get_channel(self) -> Channel: ...
async def get_guild(self) -> Guild: ...
Expand Down

0 comments on commit f3005a6

Please sign in to comment.