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

fix: Improve Thread.members Reliability #2351

Merged
merged 25 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
91572a1
Fix `slash_autocomplete` to not error
Icebluewolf Mar 8, 2022
ae2e375
Add minmax length options to slash commands
Icebluewolf Jul 3, 2022
4b3bd6f
Merge remote-tracking branch 'origin/master'
Icebluewolf Jul 3, 2022
94e28f1
Merge branch 'master' into master
Lulalaby Jul 3, 2022
e17686c
Merge branch 'master' into master
Lulalaby Jul 3, 2022
62825ca
Merge branch 'master' into master
Lulalaby Jul 3, 2022
658e73e
Merge branch 'master' into master
Dorukyum Jul 4, 2022
5c73509
Add Checks to minmax functions
Icebluewolf Jul 4, 2022
9e519cb
Merge remote-tracking branch 'origin/master'
Icebluewolf Jul 4, 2022
236e299
Merge branch 'master' into master
Lulalaby Jul 4, 2022
a184aa6
Merge branch 'master' into master
Lulalaby Jul 4, 2022
5bb9b60
Apply suggestions from code review
Lulalaby Jul 4, 2022
8d10d1d
Merge branch 'master' into master
Lulalaby Jul 4, 2022
e74ecf7
Update discord/commands/options.py
Lulalaby Jul 4, 2022
a1b8218
Apply suggestions from code review
Lulalaby Jul 4, 2022
1068ab5
Update discord/commands/options.py
Lulalaby Jul 4, 2022
fb2dfa3
Update options.py
Lulalaby Jul 4, 2022
ccc4813
try fix
Lulalaby Jul 4, 2022
aeb8bea
Merge remote-tracking branch 'origin/master'
Icebluewolf Jan 15, 2024
06a2bd7
Merge branch 'master' of https://github.com/Icebluewolf/pycord
Icebluewolf Feb 2, 2024
f9384ea
fix: improve Thread.members reliability
Icebluewolf Feb 4, 2024
20586ae
refactor: remove print statements
Icebluewolf Feb 5, 2024
cf2a87f
Merge branch 'Pycord-Development:master' into thread_cache_improvment
Icebluewolf Feb 5, 2024
3492a6f
docs: add changelog entry and add docs clarificaiton
Icebluewolf Feb 5, 2024
383fcf5
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 5, 2024
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
Update options.py
  • Loading branch information
Lulalaby authored Jul 4, 2022
commit fb2dfa3099f0745fea549c06e58c9b3412579d88
25 changes: 11 additions & 14 deletions discord/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,31 +200,28 @@ def __init__(self, input_type: Any = str, /, description: Optional[str] = None,
minmax_types = (type(None),)
minmax_typehint = Optional[Union[minmax_types]] # type: ignore

if self.input_type == SlashCommandOptionType.string:
minmax_length_types = (int, type(None))
else:
minmax_length_types = (type(None),)
minmax_length_typehint = Optional[Union[minmax_length_types]] # type: ignore

self.min_value: minmax_typehint = kwargs.pop("min_value", None)
self.max_value: minmax_typehint = kwargs.pop("max_value", None)
self.min_length: minmax_length_typehint = kwargs.pop("min_length", None)
self.max_length: minmax_length_typehint = kwargs.pop("max_length", None)

if (input_type != SlashCommandOptionType.integer and input_type != SlashCommandOptionType.number
and (self.min_value or self.max_value)):
raise AttributeError("Option does not take min_value or max_value if not of type "
"SlashCommandOptionType.integer or SlashCommandOptionType.number")
if input_type != SlashCommandOptionType.string and (self.min_length or self.max_length):
raise AttributeError('Option does not take min_length or max_length if not of type str')

if not isinstance(self.min_value, minmax_types) and self.min_value is not None:
raise TypeError(f'Expected {minmax_typehint} for min_value, got "{type(self.min_value).__name__}"')
if not (isinstance(self.max_value, minmax_types) or self.min_value is None):
if not (isinstance(self.max_value, minmax_types) and self.max_value is not None):
raise TypeError(f'Expected {minmax_typehint} for max_value, got "{type(self.max_value).__name__}"')

if self.input_type == SlashCommandOptionType.string:
minmax_length_types = (int, type(None))
else:
minmax_length_types = (type(None))
minmax_length_typehint = Optional[Union[minmax_length_types]]

self.min_length: minmax_length_typehint = kwargs.pop("min_length", None)
self.max_length: minmax_length_typehint = kwargs.pop("max_length", None)

if input_type != SlashCommandOptionType.string and (self.min_length or self.max_length):
raise AttributeError('Option does not take min_length or max_length if not of type str')

if not isinstance(self.min_length, minmax_length_types) and self.min_length is not None:
raise TypeError(f'Expected {minmax_length_typehint} for min_length, got "{type(self.min_length).__name__}"')
if not (isinstance(self.max_length, minmax_length_types) and self.max_length is not None):
Expand Down