@@ -237,8 +237,6 @@ class BaseInteractionContext(BaseContext):
237237 id : Snowflake
238238 """The interaction ID."""
239239
240- app_permissions : Permissions
241- """The permissions available to this interaction"""
242240 locale : str
243241 """The selected locale of the invoking user (https://discord.com/developers/docs/reference#locales)"""
244242 guild_locale : str
@@ -261,6 +259,8 @@ class BaseInteractionContext(BaseContext):
261259 _command_name : str
262260 """The command name of the interaction."""
263261
262+ permission_map : dict [Snowflake , Permissions ]
263+
264264 args : list [typing .Any ]
265265 """The arguments passed to the interaction."""
266266 kwargs : dict [str , typing .Any ]
@@ -277,7 +277,7 @@ def from_dict(cls, client: "interactions.Client", payload: dict) -> Self:
277277 instance = cls (client = client )
278278 instance .token = payload ["token" ]
279279 instance .id = Snowflake (payload ["id" ])
280- instance .app_permissions = Permissions (payload .get ("app_permissions" , 0 ))
280+ instance .permission_map = { client . app . id : Permissions (payload .get ("app_permissions" , 0 ))}
281281 instance .locale = payload ["locale" ]
282282 instance .guild_locale = payload .get ("guild_locale" , instance .locale )
283283 instance ._context_type = payload .get ("type" , 0 )
@@ -304,8 +304,23 @@ def from_dict(cls, client: "interactions.Client", payload: dict) -> Self:
304304
305305 instance .process_options (payload )
306306
307+ if member := payload .get ("member" ):
308+ instance .permission_map [Snowflake (member ["id" ])] = Permissions (member ["permissions" ])
309+
307310 return instance
308311
312+ @property
313+ def app_permissions (self ) -> Permissions :
314+ """The permissions available to this interaction"""
315+ return self .permission_map .get (self .client .app .id , Permissions (0 ))
316+
317+ @property
318+ def author_permissions (self ) -> Permissions :
319+ """The permissions available to the author of this interaction"""
320+ if self .guild_id :
321+ return self .permission_map .get (self .author_id , Permissions (0 ))
322+ return Permissions (0 )
323+
309324 @property
310325 def command (self ) -> InteractionCommand :
311326 return self .client ._interaction_lookup [self ._command_name ]
0 commit comments