allow searching for a version of a card with a specific set
This commit is contained in:
parent
173060d2d3
commit
7273f71132
|
@ -106,16 +106,26 @@ async def get_cards(card_names):
|
||||||
|
|
||||||
for name in card_names:
|
for name in card_names:
|
||||||
name = re.sub(r'<.*?>', '', name).strip()
|
name = re.sub(r'<.*?>', '', name).strip()
|
||||||
|
|
||||||
|
# Handle set codes
|
||||||
|
if '|' in name:
|
||||||
|
name, set_code, *_ = name.split('|')
|
||||||
|
else:
|
||||||
|
set_code = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if len(name) > 141:
|
if len(name) > 141:
|
||||||
c = scrython.cards.Named(fuzzy='Our Market Research Shows That Players Like Really Long Card Names So We Made this Card to Have the Absolute Longest Card Name Ever Elemental')
|
c = scrython.cards.Named(fuzzy='Our Market Research Shows That Players Like Really Long Card Names So We Made this Card to Have the Absolute Longest Card Name Ever Elemental')
|
||||||
elif len(name) == 0:
|
elif len(name) == 0:
|
||||||
c = scrython.cards.Named(fuzzy='_____')
|
c = scrython.cards.Named(fuzzy='_____')
|
||||||
else:
|
else:
|
||||||
c = scrython.cards.Named(fuzzy=name)
|
c = scrython.cards.Named(fuzzy=name, set=set_code)
|
||||||
cards.append(c)
|
cards.append(c)
|
||||||
responses.append(f'{c.name()} - {c.scryfall_uri()}')
|
responses.append(f'{c.name()} - {c.scryfall_uri()}')
|
||||||
except scrython.foundation.ScryfallError:
|
except scrython.foundation.ScryfallError:
|
||||||
|
if set_code:
|
||||||
|
responses.append(f'No card named "{name}" from set with code {set_code.upper()} was found.')
|
||||||
|
else:
|
||||||
responses.append(f'No card named "{name}" was found.')
|
responses.append(f'No card named "{name}" was found.')
|
||||||
|
|
||||||
# Download card images.
|
# Download card images.
|
||||||
|
|
Loading…
Reference in New Issue