Update insert_duel_request to return duel ID and modify duel_request response message

This commit is contained in:
w 2025-07-06 16:46:17 -03:00
parent 528e21db23
commit 9bcbfca5df
2 changed files with 8 additions and 5 deletions

View file

@ -101,7 +101,7 @@ def get_player(username: str) -> int:
return int(player[0]) return int(player[0])
return 0 return 0
def insert_duel_request(username: str, target: str, duel_type: str) -> None: def insert_duel_request(username: str, target: str, duel_type: str) -> int:
'''Inserts a duel request into the database. '''Inserts a duel request into the database.
Args: Args:
@ -119,11 +119,14 @@ def insert_duel_request(username: str, target: str, duel_type: str) -> None:
competitive = duel_type competitive = duel_type
# insert the duel request # insert the duel request and get the duel ID
CURSOR.execute( CURSOR.execute(
'INSERT INTO duel_requests (player_1_id, player_2_id, competitive) VALUES (?, ?, ?)', 'INSERT INTO duel_requests (player_1_id, player_2_id, competitive) VALUES (?, ?, ?)',
(player_1_1d, player_2_id, competitive) (player_1_1d, player_2_id, competitive)
) )
duel_id = CURSOR.lastrowid
return duel_id
def insert_player(username: str) -> int: def insert_player(username: str) -> int:
'''Insert a new player with default has_rolled = False and return their '''Insert a new player with default has_rolled = False and return their

View file

@ -208,11 +208,11 @@ def duel_request(author: str, args: list[str]) -> BotResponse:
if len(args) == 1 and args[0] == "competitive": if len(args) == 1 and args[0] == "competitive":
duel_type = 'competitive' duel_type = 'competitive'
db.insert_duel_request(author, target, duel_type) duel_id = db.insert_duel_request(author, target, duel_type)
return { return {
'message': f'{target} You have been challenged to a {duel_type} duel by \ 'message': f'{target} You have been challenged to a {duel_type} duel by {author}! \
{author}! Reply with `accept_duel` to accept the challenge.', Reply with `accept_duel {duel_id}` to accept the challenge. Duel ID:{duel_id}.',
'attachment_urls': None 'attachment_urls': None
} }