Update Main.py

This commit is contained in:
Sarasayed0118 2024-04-28 17:01:30 +05:30 committed by GitHub
parent 9598a3d1fa
commit 14a1a1629d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -221,27 +221,22 @@ def QuickAccess(msg, client_id):
return None return None
elif msg.startswith("/dm"): elif msg.startswith("/dm"):
name = "" a = msg.split()[1:]
a = msg.lower().split()[1:]
if len(a) < 2: # Check if there are enough arguments if len(a) < 2: # Check if there are enough arguments
send(f"Usage: /dm [clientid] [message]", client_id) send(f"Usage: /dm [clientid] [message]", client_id)
else: else:
clientid = int(a[0]) clientid = int(a[0])
message = ' '.join(a[1:]) # Join the message list into a single string message = ' '.join(a[1:]) # Join the message list into a single string
# Check if the specified client ID exists in the session players and lobby
player_found = False
for me in ba.internal.get_game_roster(): for me in ba.internal.get_game_roster():
if me["client_id"] == client_id: if me["client_id"] == client_id:
pname = me["display_string"] pname = me["display_string"]
player_found = True #=============================================================================================
for me in ba.internal.get_game_roster():
if me["client_id"] == clientid: if me["client_id"] == clientid:
name = me["display_string"] name = me["display_string"]
break break
if name:
if player_found:
try: try:
# Send DM message to the specified client ID
send(f"{pname}: {message}", clientid) send(f"{pname}: {message}", clientid)
send(f"DM sent successfully to {name}", client_id) send(f"DM sent successfully to {name}", client_id)
except Exception as e: except Exception as e: