Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slash Command Permissions support. #280

Merged
merged 6 commits into from
Oct 21, 2021

Conversation

TheGamerX20
Copy link
Contributor

Summary

This pull request adds support for Slash Command Permissions by using:
"has_role", 'has_any_role", "is_user" and "is_owner" from discord.app.commands.
Also adds an example "slash_perms.py" in "examples/app_commands/".

Fixes Issues (#93) and (#247)

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, ...)

discord/app/commands.py Outdated Show resolved Hide resolved
discord/app/commands.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
examples/app_commands/slash_perms.py Outdated Show resolved Hide resolved
@BobDotCom
Copy link
Member

@TheGamerX20 could you take a look at these suggestions?

@TheGamerX20
Copy link
Contributor Author

@TheGamerX20 could you take a look at these suggestions?

Hey, I am sorry for the wait, I did look at them and will commit them soon but I have been working on some changes according to feedback as outlined in Pycord's Discord server here: https://discord.com/channels/881207955029110855/881735314987708456/899998877598494850

work is done, just wanna make sure there are no bugs/issues before committing :)

TheGamerX20 and others added 2 commits October 20, 2021 10:54
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
@BobDotCom
Copy link
Member

There are some merge conflicts here. They should be resolved by moving the file to discord/commands/commands.py.

@TheGamerX20
Copy link
Contributor Author

There are some merge conflicts here. They should be resolved by moving the file to discord/commands/commands.py.

Fixed the Merge Conflicts.

BobDotCom
BobDotCom previously approved these changes Oct 20, 2021
@BobDotCom BobDotCom changed the base branch from feature/slash to master October 20, 2021 21:22
@BobDotCom BobDotCom dismissed their stale review October 20, 2021 21:22

The base branch was changed.

@BobDotCom BobDotCom enabled auto-merge October 20, 2021 21:23
@BobDotCom BobDotCom requested a review from Dorukyum October 20, 2021 21:23
@BobDotCom BobDotCom merged commit 997d364 into Pycord-Development:master Oct 21, 2021
Copy link
Member

@Dorukyum Dorukyum left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

@Dorukyum
Copy link
Member

Slash command groups are missing permissions which causes AttributeError: 'SlashCommandGroup' object has no attribute 'permissions' on startup.

@FrostSTeeL
Copy link

Is there any way to use it like this?

@slash.slash(name="cool_command")
async def cool_command(ctx, option):
if not ctx.author.guild_permissions.ban_members: # replace this with your desired permission
return # tell them they dont have permissions or raise an exception

instead of the role i want to check if the user has a certain guildpermission

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.

4 participants