|
10 | 10 | import disnake.utils |
11 | 11 | from disnake import ApplicationCommandInteraction |
12 | 12 | from disnake.message import Message |
| 13 | +from disnake.permissions import Permissions |
13 | 14 |
|
14 | 15 | if TYPE_CHECKING: |
15 | 16 | from typing_extensions import ParamSpec |
@@ -284,6 +285,25 @@ def me(self) -> Union[Member, ClientUser]: |
284 | 285 | # bot.user will never be None at this point. |
285 | 286 | return self.guild.me if self.guild is not None else self.bot.user |
286 | 287 |
|
| 288 | + @disnake.utils.cached_property |
| 289 | + def app_permissions(self) -> Permissions: |
| 290 | + """:class:`.Permissions`: Returns the permissions the bot has in the context's channel. |
| 291 | +
|
| 292 | + .. versionadded: |vnext| |
| 293 | + """ |
| 294 | + # This probably won't ever error. |
| 295 | + # `permissions_for` exists on all except PartialMessageable, which we shouldn't get here |
| 296 | + # For other channel types, permissions_for exists on all of them. |
| 297 | + return self.channel.permissions_for(self.me) # pyright: ignore[reportArgumentType] |
| 298 | + |
| 299 | + @disnake.utils.cached_property |
| 300 | + def permissions(self) -> Permissions: |
| 301 | + """:class:`.Permissions`: Returns the permissions the author has in the context's channel. |
| 302 | +
|
| 303 | + .. versionadded: |vnext| |
| 304 | + """ |
| 305 | + return self.channel.permissions_for(self.author) # pyright: ignore[reportArgumentType] |
| 306 | + |
287 | 307 | @property |
288 | 308 | def voice_client(self) -> Optional[VoiceProtocol]: |
289 | 309 | r""":class:`.VoiceProtocol` | :data:`None`: A shortcut to :attr:`.Guild.voice_client`\, if applicable.""" |
|
0 commit comments