Skip to content

Commit

Permalink
swap to internal Ulid objects
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmTomahawkx committed Oct 28, 2024
1 parent c6a8162 commit 8feaadd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions revolt/ext/commands/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,17 @@ def member_converter(arg: str, context: Context[ClientT]) -> Member:
def int_converter(arg: str, context: Context[ClientT]) -> int:
return int(arg)

def id_converter(arg: str, context: Context[ClientT]) -> ulid.ULID:
def id_converter(arg: str, context: Context[ClientT]) -> utils.Ulid:
if len(arg) != 26:
raise ValueError("An ID was not provided.")

try:
return ulid.parse(arg)
ulid.parse(arg) # validate
except Exception as err:
raise ValueError("An invalid ID was provided.") from err

return utils.Object(arg)

IdConverter = Annotated[ulid.ULID, id_converter]
IntConverter = Annotated[int, int_converter]
BoolConverter = Annotated[bool, bool_converter]
Expand Down

0 comments on commit 8feaadd

Please sign in to comment.