Skip to content

Conversation

AstreaTSS
Copy link
Member

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

In the Discord API docs for channels, I noticed an attribute called permissions, which gives the calculated permissions for the current bot user if the channel was gotten as an option from a slash command. This PR adds that attribute into interactions.py itself.

Note: technically, Discord doesn't specify that it'll not exist in DMs, but... yeah, it doesn't exist in DMs. I've decided to keep it in BaseChannel regardless to be consistent with Discord though.

Changes

  • Add permissions to BaseChannel.

Related Issues

Test Scenarios

@interactions.slash_command(name="cmd", description="My command")
@interactions.slash_option(
    name="chan",
    description="My channel option",
    opt_type=interactions.OptionType.CHANNEL,
    required=True,
)
async def cmd(ctx: interactions.SlashContext, chan: interactions.BaseChannel):
    await ctx.send(str(chan.permissions))

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@AstreaTSS AstreaTSS changed the title feat: add permissions attr to BaseChannel feat: add permissions attr to channels Jun 9, 2023
@LordOfPolls LordOfPolls merged commit 09d1bec into interactions-py:unstable Jun 13, 2023
@AstreaTSS AstreaTSS deleted the channel-permissions branch June 20, 2023 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants