diff --git a/bot/db_utils.py b/bot/db_utils.py index 933ec48..45cac82 100644 --- a/bot/db_utils.py +++ b/bot/db_utils.py @@ -185,7 +185,7 @@ def insert_card( if power is not None and charm is not None and wit is not None: CURSOR.execute( ''' - INSERT INTO card (name, rarity, file_id, power, charm, wit) + INSERT INTO cards (name, rarity, file_id, power, charm, wit) VALUES (?, ?, ?, ?, ?, ?) ''', (name, rarity, file_id, power, charm, wit) @@ -193,7 +193,7 @@ def insert_card( else: CURSOR.execute( ''' - INSERT INTO card (name, rarity, file_id) + INSERT INTO cards (name, rarity, file_id) VALUES (?, ?, ?) ''', (name, rarity, file_id) diff --git a/bot/response.py b/bot/response.py index 93cf614..63b5d0c 100644 --- a/bot/response.py +++ b/bot/response.py @@ -123,10 +123,10 @@ dumbass.', 'attachment_urls': None } - if len(arguments) != 2: + if not(len(arguments) in (2,5)): return { 'message': f'{author} Please specify the following attributes \ -in order: name, rarity', +in order: name, rarity. Optionally add [power, charm, wit].', 'attachment_urls': None } @@ -137,6 +137,27 @@ be a number between 1 and 5', 'attachment_urls': None } + if len(arguments) == 2: + pass + else: + if not all(is_float(arg) for arg in arguments[2:]): + return { + 'message': f'{author} Invalid attributes: power, charm and \ +wit must be numbers.', + 'attachment_urls': None + } + card_id, file_id = add_card( + name=arguments[0], + rarity=int(arguments[1]), + image_url=image_url, + power=int(arguments[2]), + charm=int(arguments[3]), + wit=int(arguments[4]) + ) + return { + 'message': f'{author} Added {arguments[0]}, ID {card_id}.', + 'attachment_urls': [file_id] + } card_id, file_id = add_card( name=arguments[0], rarity=int(arguments[1]),