Update insert_duel_request to return duel ID and modify duel_request response message
This commit is contained in:
parent
528e21db23
commit
9bcbfca5df
2 changed files with 8 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue