From 9bcbfca5df75e9c65313ca2f23e4b43567078329 Mon Sep 17 00:00:00 2001 From: w Date: Sun, 6 Jul 2025 16:46:17 -0300 Subject: [PATCH] Update insert_duel_request to return duel ID and modify duel_request response message --- bot/db_utils.py | 7 +++++-- bot/response.py | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bot/db_utils.py b/bot/db_utils.py index 5ba7ee0..5591577 100644 --- a/bot/db_utils.py +++ b/bot/db_utils.py @@ -101,7 +101,7 @@ def get_player(username: str) -> int: return int(player[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. Args: @@ -119,11 +119,14 @@ def insert_duel_request(username: str, target: str, duel_type: str) -> None: competitive = duel_type - # insert the duel request + # insert the duel request and get the duel ID CURSOR.execute( 'INSERT INTO duel_requests (player_1_id, player_2_id, competitive) VALUES (?, ?, ?)', (player_1_1d, player_2_id, competitive) ) + duel_id = CURSOR.lastrowid + + return duel_id def insert_player(username: str) -> int: '''Insert a new player with default has_rolled = False and return their diff --git a/bot/response.py b/bot/response.py index 64053b8..b2d10f0 100644 --- a/bot/response.py +++ b/bot/response.py @@ -208,11 +208,11 @@ def duel_request(author: str, args: list[str]) -> BotResponse: if len(args) == 1 and args[0] == "competitive": duel_type = 'competitive' - db.insert_duel_request(author, target, duel_type) + duel_id = db.insert_duel_request(author, target, duel_type) return { - 'message': f'{target} You have been challenged to a {duel_type} duel by \ - {author}! Reply with `accept_duel` to accept the challenge.', + 'message': f'{target} You have been challenged to a {duel_type} duel by {author}! \ + Reply with `accept_duel {duel_id}` to accept the challenge. Duel ID:{duel_id}.', 'attachment_urls': None }