Skip to content

Commit

Permalink
Revert "Implements a new get_or_fetch feature (#42)" (#43)
Browse files Browse the repository at this point in the history
This reverts commit ea4b656.
  • Loading branch information
CodeWithSwastik authored Aug 31, 2021
1 parent ea4b656 commit cea77e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion discord/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@


class DiscordException(Exception):
"""Base exception class for Pycord
"""Base exception class for pycord
Ideally speaking, this could be caught to handle any exceptions raised from this library.
"""
Expand Down
12 changes: 1 addition & 11 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
import types
import warnings

from .errors import InvalidArgument, NotFound
from .guild import Guild
from .errors import InvalidArgument

try:
import orjson
Expand Down Expand Up @@ -449,15 +448,6 @@ def get(iterable: Iterable[T], **attrs: Any) -> Optional[T]:
return elem
return None

async def get_or_fetch(guild: Guild, type: str, id: int):
getter = getattr(guild, f'get_{type}')(id)
if getter is None:
try:
getter = await getattr(guild, f'fetch_{type}')(id)
except NotFound:
raise NotFound(404, 'HTTP request operation failed.')
return getter


def _unique(iterable: Iterable[T]) -> List[T]:
return [x for x in dict.fromkeys(iterable)]
Expand Down

0 comments on commit cea77e2

Please sign in to comment.