Skip to content

Conversation

@ShajeshJ
Copy link
Contributor

@ShajeshJ ShajeshJ commented May 24, 2023

Pull Request Type

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

Description

The interactions.Guild.create_role method does not work correctly if you pass in interactions.Permissions.NONE. Rather than creating the role in Discord with every permission disabled, it instead creates the role with discord's default permissions enabled.

Changes

  • Update interactions.Guild.create_role method
    • Updated the arg check for adding permissions to the payload to check equality tointeractions.Permissions.NONE in addition to truthy values

Related Issues

fixes #1420

Test Scenarios

  • Setup a bot like below:
    import interactions as ipy
    
    bot = ipy.Client(intents=ipy.Intents.DEFAULT, debug_scope=<your_guild_id>)
    
    @ipy.slash_command()
    async def create_role(ctx: ipy.SlashContext):
        role = await ctx.guild.create_role(name="test role", permissions=ipy.Permissions.NONE)
        await ctx.send(f"role's new permissions: {role.permissions}")
    
    if __name__ == "__main__":
        bot.start("<token>")
  • Prior to this change, you will see the bot respond with the permission set value being 137408993025601 (discord's default)
  • After this change, you should instead see the bot respond with the permission set value being 0

I didn't add any unit tests because it seemed like overkill for such a small edge case. But I can add one in if folks disagree.

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

Copy link
Member

@AstreaTSS AstreaTSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, just one suggestion.

@AstreaTSS AstreaTSS merged commit f476863 into interactions-py:unstable May 24, 2023
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.

2 participants