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

Permissions v2 - Redo for merge conflicts #1328

Merged
merged 48 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f0748e6
Remove v1 from application commands
Dorukyum Jan 15, 2022
4488210
Remove permissions v1 from documentation
Dorukyum Jan 15, 2022
291203c
Add v2 attributes to commands
Dorukyum Jan 15, 2022
6410974
Fix permissions for groups
Dorukyum Jan 15, 2022
0cc48ac
Use v2 in as_dict methods
Dorukyum Jan 15, 2022
abb059a
Add new permission decorator
Dorukyum Jan 15, 2022
7ca7fbf
Add missing return
Dorukyum Jan 16, 2022
feed5fe
Allow both kwargs and decorators for permissions
Dorukyum Jan 16, 2022
c07242c
Add guild_only decorator
Dorukyum Jan 16, 2022
5844e94
Allow decorating a command
Dorukyum Jan 16, 2022
c0200a0
Merge branch 'master' of https://github.com/Pycord-Development/pycord…
Dorukyum Feb 5, 2022
3853bcc
Merge branch 'master' into permissions-v2
Dorukyum Mar 7, 2022
362a282
Remove permissions v1 from docs
Dorukyum Mar 7, 2022
71c67d3
Merge branch 'master' into permissions-v2
BobDotCom Mar 19, 2022
5a19868
Merge pull request #1129 from Dorukyum/permissions-v2
BobDotCom Mar 19, 2022
8fd19d9
Fix to_check in get_desynced_commands
BobDotCom Mar 19, 2022
ea7b3af
Merge branch 'master' into permissions-v2
BobDotCom Mar 22, 2022
4b319a8
Merge branch 'master' into permissions-v2
Dorukyum Mar 24, 2022
65ae1b4
Merge branch 'master' into permissions-v2
BobDotCom Apr 2, 2022
6ac81a1
Merge branch 'master' into permissions-v2
BobDotCom Apr 3, 2022
a836b62
Merge branch 'master' into permissions-v2
BobDotCom Apr 4, 2022
483a9aa
Merge branch 'master' into permissions-v2
BobDotCom Apr 5, 2022
4b58e83
Merge branch 'master' into permissions-v2
krittick Apr 27, 2022
258eeab
merge master into permissions-v2
krittick Apr 27, 2022
a6fbe73
Merge branch 'master' into permissions-v2
krittick Apr 28, 2022
e209f21
Merge branch 'master' into permissions-v2
BobDotCom Apr 28, 2022
5e11a6a
Rename has_permissions to default_permissions
BobDotCom Apr 28, 2022
b4879ee
Document command permissions
BobDotCom Apr 28, 2022
238ea15
Fix command permissions doc note
BobDotCom Apr 28, 2022
c40ed9d
Remove note
BobDotCom Apr 28, 2022
bf1c3f2
Rename dm_permission to guild_only for parity
BobDotCom Apr 28, 2022
16e9f6c
Fix imports
BobDotCom Apr 28, 2022
9847a42
Fix kwarg name
BobDotCom Apr 28, 2022
b085c6d
Merge branch 'master' into permissions-v2
BobDotCom Apr 28, 2022
70fe0fe
Move permission attributes to parent class
Dorukyum Apr 30, 2022
1eb9aab
Fix guild_only decorator
Dorukyum Apr 30, 2022
28fb2f6
Merge branch 'master' into permissions-v2
Lulalaby May 2, 2022
bcfd8ce
[Perms v2] Additional implementations (#1303)
plun1331 May 3, 2022
f8f0e6b
Merge branch 'master' into permissions-v2
Lulalaby May 5, 2022
81801b6
Update discord/commands/core.py
Lulalaby May 5, 2022
8ae253f
Merge branch 'master' into permissions-v2
Lulalaby May 5, 2022
e3f8203
Reduce need for Permissions TypeVar
TurnrDev May 5, 2022
5249f90
Update api.rst
plun1331 May 5, 2022
dfb9e2b
Merge branch 'master' into permissions-v2
krittick May 5, 2022
b9d9642
Merge branch 'permissions-v2' into permsv2-merge
krittick May 5, 2022
029bf7c
merge permissionsv2 into master branch copy
krittick May 5, 2022
934661e
apply code style fixes
krittick May 5, 2022
c1f93b9
apply code style fixes
krittick May 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge master into permissions-v2
  • Loading branch information
krittick committed Apr 27, 2022
commit 258eeabb9a3d3635e6819e902d7837def23c7a56
2 changes: 1 addition & 1 deletion discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def _check_command(cmd: ApplicationCommand, match: Dict) -> bool:
as_dict = cmd.to_dict()
to_check = {
"dm_permission": None,
"default_member_permissions": None,
"default_member_permissions": None,
"name": None,
"description": None,
"name_localizations": None,
Expand Down
24 changes: 12 additions & 12 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,42 +1624,42 @@ def validate_chat_input_name(name: Any, locale: Optional[str] = None):
# Must meet the regex ^[\w-]{1,32}$
if locale is not None and locale not in valid_locales:
raise ValidationError(
f"Locale '{locale}' is not a valid locale, "
f"see {docs}/reference#locales for list of supported locales."
f"Locale '{locale}' is not a valid locale, " f"see {docs}/reference#locales for list of supported locales."
)
error = None
if not isinstance(name, str):
error = TypeError(f"Command names and options must be of type str. Received \"{name}\"")
error = TypeError(f'Command names and options must be of type str. Received "{name}"')
elif not re.match(r"^[\w-]{1,32}$", name):
error = ValidationError(
r"Command names and options must follow the regex \"^[\w-]{1,32}$\". For more information, see "
f"{docs}/interactions/application-commands#application-command-object-application-command-naming. "
f"Received \"{name}\""
f'Received "{name}"'
)
elif not 1 <= len(name) <= 32:
error = ValidationError(f"Command names and options must be 1-32 characters long. Received \"{name}\"")
error = ValidationError(f'Command names and options must be 1-32 characters long. Received "{name}"')
elif not name.lower() == name: # Can't use islower() as it fails if none of the chars can be lower. See #512.
error = ValidationError(f"Command names and options must be lowercase. Received \"{name}\"")
error = ValidationError(f'Command names and options must be lowercase. Received "{name}"')

if error:
if locale:
error.args = (error.args[0]+f" in locale {locale}",)
error.args = (f"{error.args[0]} in locale {locale}",)
raise error


def validate_chat_input_description(description: Any, locale: Optional[str] = None):
if locale is not None and locale not in valid_locales:
raise ValidationError(
f"Locale '{locale}' is not a valid locale, "
f"see {docs}/reference#locales for list of supported locales."
f"Locale '{locale}' is not a valid locale, " f"see {docs}/reference#locales for list of supported locales."
)
error = None
if not isinstance(description, str):
error = TypeError(f"Command and option description must be of type str. Received \"{description}\"")
error = TypeError(f'Command and option description must be of type str. Received "{description}"')
elif not 1 <= len(description) <= 100:
error = ValidationError(f"Command and option description must be 1-100 characters long. Received \"{description}\"")
error = ValidationError(
f'Command and option description must be 1-100 characters long. Received "{description}"'
)

if error:
if locale:
error.args = (error.args[0]+f" in locale {locale}",)
error.args = (f"{error.args[0]} in locale {locale}",)
raise error