-
Notifications
You must be signed in to change notification settings - Fork 0
/
friend_tracker.py
573 lines (452 loc) · 24.3 KB
/
friend_tracker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
import json
import discord
from discord.ext import tasks
import requests
import datetime
import os
from dotenv import load_dotenv
import random
import roman
import functools
import traceback
import psycopg2
load_dotenv()
conn = psycopg2.connect(
host=os.environ.get("HOST"),
database=os.environ.get("DATABASE"),
user=os.environ.get("USER"),
password=os.environ.get("PASSWORD")
)
cur = conn.cursor()
NEEDS_UPDATE = {}
RANKING_DICT = {"CHALLENGER":0, "GRANDMASTER":1, "MASTER":2, "DIAMOND":3, "PLATINUM":4, "GOLD":5, "SILVER":6, "BRONZE":7, "IRON":8}
FLAME_MESSAGE_1 = "Hey what happened :slight_smile:"
FLAME_MESSAGE_2 = ":slight_smile:"
FLAME_MESSAGE_3 = "It clicked btw"
FLAME_MESSAGE_4 = ":clown:"
FLAME_MESSAGE_5 = "It's just a warmup game"
FLAME_MESSAGE_6 = "sine waving i see you"
FLAME_MESSAGE_7 = "heyyy hani are you lowering your mmr for easier lobbies?"
FLAME_MESSAGE_8 = "imagine being lapped by hani"
FLAME_MESSAGE_9 = "dude clean your room instead of playing"
FLAME_MESSAGE_10 = "spoken like a true goldie"
FLAME_MESSAGE_11 = "best mental na btw"
FLAME_MESSAGE_12 = "Must've been a glitch!"
FLAME_MESSAGE_13 = "cosine waving i see you"
FLAME_MESSAGE_14 = "new master duel video dropped"
FLAME_MESSAGE_15 = "at least he can finish a tft game quickly"
FLAME_MESSAGE_16 = "<:hanium:887502989500223498>"
FLAME_MESSAGE_LIST_HANI = [FLAME_MESSAGE_1, FLAME_MESSAGE_2, FLAME_MESSAGE_3, FLAME_MESSAGE_4, FLAME_MESSAGE_5, FLAME_MESSAGE_6, FLAME_MESSAGE_7, FLAME_MESSAGE_10, FLAME_MESSAGE_11, FLAME_MESSAGE_12, FLAME_MESSAGE_14, FLAME_MESSAGE_16]
FLAME_MESSAGE_LIST_SANDY = [FLAME_MESSAGE_1, FLAME_MESSAGE_2, FLAME_MESSAGE_3, FLAME_MESSAGE_4, FLAME_MESSAGE_5, FLAME_MESSAGE_8, FLAME_MESSAGE_9, FLAME_MESSAGE_12, FLAME_MESSAGE_13]
FLAME_MESSAGE_LIST_JREISS = [FLAME_MESSAGE_1, FLAME_MESSAGE_2, FLAME_MESSAGE_4, FLAME_MESSAGE_5, FLAME_MESSAGE_6, FLAME_MESSAGE_10, FLAME_MESSAGE_12, FLAME_MESSAGE_15]
headers = {"X-Riot-Token": os.environ.get("RIOT_API_TOKEN")}
items_file = open('items.json')
items_data = json.load(items_file)
client = discord.Client()
def check_user_riot(summoner_name):
response_ids = json.loads(requests.get("https://na1.api.riotgames.com/tft/summoner/v1/summoners/by-name/" + summoner_name, headers=headers).content.decode())
if 'status' in response_ids:
return response_ids['status']['message'] == "Data not found - summoner not found"
else:
return len(get_most_recent_match(summoner_name)) != 0
# gets all servers player is in
def get_servers_from_player(user):
query = '''SELECT server_id FROM player_server_relation WHERE player_name=\'''' + user + '''\''''
cur.execute(query)
server_list = cur.fetchall()
return [server[0] for server in server_list]
# gets list of players from db
def get_players_from_db():
query = '''SELECT name FROM player'''
cur.execute(query)
player_list = cur.fetchall()
return [player[0].rstrip() for player in player_list]
# gets last game played from db
def get_last_game(user):
query = '''SELECT match_id FROM player WHERE name=\'''' + user + '''\''''
cur.execute(query)
last_game = cur.fetchall()
print(last_game)
if last_game[0][0] is None:
return "None"
return last_game[0][0].rstrip()
# get default channel from server
def get_channel_from_server(server):
query = '''SELECT default_channel FROM server WHERE id=''' + str(server)
cur.execute(query)
channel_name = cur.fetchall()
return channel_name[0][0]
# gets list of servers from db
def get_servers_from_db():
query = '''SELECT id FROM server'''
cur.execute(query)
server_db = cur.fetchall()
server_list = []
for element in server_db:
server_list.append(element[0])
return server_list
# adds server if not in db
def add_server_to_db(message):
server = message.guild.id
channel = message.channel.id
query = '''SELECT * FROM server WHERE id=''' + str(server)
cur.execute(query)
server_db = cur.fetchall()
if len(server_db) == 0:
query = '''INSERT INTO server(id, prefix, default_channel) VALUES (''' + str(server) + ''', \'.\', ''' + str(channel) + ''')'''
cur.execute(query)
conn.commit()
# gets list of all players from server
def get_all_players_from_server(server):
query = '''SELECT player_name FROM player_server_relation WHERE server_id=''' + str(server)
cur.execute(query)
user_list = cur.fetchall()
users_in_server = []
for element in user_list:
users_in_server.append(element[0].rstrip())
return users_in_server
# adds user if not in db
def add_user_to_db(user):
query = '''SELECT * FROM player WHERE name=\'''' + user + '''\''''
cur.execute(query)
user_db = cur.fetchall()
if len(user_db) == 0:
query = '''INSERT INTO player(name) VALUES (\'''' + user + '''\')'''
cur.execute(query)
conn.commit()
# deletes user from relation table in db
def delete_user(message):
server = message.guild.id
user = " ".join(message.content.split(" ")[1:])
if user in list(NEEDS_UPDATE.keys()):
NEEDS_UPDATE.pop(user)
query = '''DELETE FROM player_server_relation WHERE player_name=\'''' + user + '''\' AND server_id=''' + str(server)
cur.execute(query)
conn.commit()
# adds user and checks relation in db
def add_user(message):
server = message.guild.id
user = " ".join(message.content.split(" ")[1:])
if not check_user_riot(user):
print("huh")
return False
NEEDS_UPDATE[user] = None
query = '''SELECT * FROM player_server_relation WHERE player_name=\'''' + user + '''\' AND server_id=''' + str(server)
cur.execute(query)
check_relation = cur.fetchall()
if len(check_relation) == 0:
add_server_to_db(message)
add_user_to_db(user)
query = '''INSERT INTO player_server_relation(player_name, server_id) VALUES (\'''' + user + '''\', ''' + str(server) + ''')'''
cur.execute(query)
conn.commit()
return True
# retrieves user data as list of strings from db
def get_data_from_db(user):
strings = []
query = '''SELECT COUNT(*) FROM player WHERE name=\'''' + user + '''\''''
cur.execute(query)
if cur.fetchall()[0][0] > 0:
query = '''SELECT * FROM player WHERE name=\'''' + user + '''\''''
cur.execute(query)
user_info = cur.fetchall()
strings.append(user_info[0][0].rstrip())
strings.append(user_info[0][1].rstrip())
strings.append(time_to_timedelta(user_info[0][2]))
strings.append(strings[0] + " went " + str(user_info[0][3]) + "/8.")
strings.append(user_info[0][4].rstrip())
strings.append(user_info[0][5].rstrip().replace("$", "\'").replace(";", "\n"))
strings.append(user_info[0][6].rstrip())
strings.append(user_info[0][7].rstrip())
return strings
# helper to update or add row
def add_data_check(user):
query = '''SELECT COUNT(*) FROM player WHERE name=\'''' + user + '''\''''
cur.execute(query)
if cur.fetchall()[0][0] != 1:
return "ADD"
else:
return "UPDATE"
# updates user data if not in database
def update_data(user_list):
for user in user_list:
query = '''SELECT * from player where name=\'''' + user + '''\''''
cur.execute(query)
arr = cur.fetchall()
if len(arr) == 0:
get_data_for_user(user)
# if no last game in db (new user) or needs update
# then update data and remove user from list of needed updates
elif arr[0][6] is None:
get_data_for_user(user)
elif user in list(NEEDS_UPDATE.keys()):
get_data_for_user(user)
NEEDS_UPDATE.pop(user)
# converts datetime to a timedelta string
def time_to_timedelta(timedelta_str):
datetime_str = str(datetime.datetime.fromtimestamp(float(timedelta_str)))
format = "%Y-%m-%d %H:%M:%S"
datetime_obj = datetime.datetime.strptime(datetime_str, format)
timedelta = (datetime.datetime.now() - datetime_obj)
hours = timedelta.seconds // 3600
minutes = timedelta.seconds // 60 - hours * 60
seconds = timedelta.seconds - hours * 3600 - minutes * 60
date_str = str(timedelta.days) + " days, " + str(hours) + " hours, " + str(minutes) + " minutes, and " + str(seconds) + " seconds ago, "
return date_str
# compares ranks of users given the list of strings from user output
def compare_ranks(list_of_strings_1, list_of_strings_2):
rank_str_1 = list_of_strings_1[1].rstrip()
rank_str_2 = list_of_strings_2[1].rstrip()
# check if unranked (different message content)
if rank_str_1.split(" ")[-1] == "unranked.":
if rank_str_2.split(" ")[-1] == "unranked.":
return 0
else:
return 1
elif rank_str_2.split(" ")[-1] == "unranked.":
return -1
rank_1 = RANKING_DICT.get(rank_str_1.split(" ")[-4])
rank_2 = RANKING_DICT.get(rank_str_2.split(" ")[-4])
div_1 = rank_str_1.split(" ")[-3][:-1]
div_2 = rank_str_2.split(" ")[-3][:-1]
lp_1 = int(rank_str_1.split(" ")[-2])
lp_2 = int(rank_str_2.split(" ")[-2])
# if rank (challenger, gm, etc.) greater
if rank_1 < rank_2:
return -1
elif rank_1 > rank_2:
return 1
else:
# if division (i, ii, iii) better
if roman.fromRoman(div_1) < roman.fromRoman(div_2):
return -1
elif roman.fromRoman(div_1) > roman.fromRoman(div_2):
return 1
else:
# if lp greater
if lp_1 > lp_2:
return -1
elif lp_2 < lp_1:
return 1
else:
return 0
# returns the item name for an item id
def get_item_name(item_id):
for item in items_data:
if item['id'] == item_id:
return item['name']
# placeholder while trying to figure out items
return ""
# returns the difference in time between now and the match selected
def get_timedelta(match_id):
response_recent_match = json.loads(requests.get("https://americas.api.riotgames.com/tft/match/v1/matches/" + match_id, headers=headers).content.decode())
timedelta = datetime.datetime.now() - datetime.datetime.fromtimestamp(response_recent_match['info']['game_datetime'] / 1e3)
return timedelta.seconds
# returns True if the player got bot 4 in their last game
def get_last_ranking(summoner_name):
response_ids = json.loads(requests.get("https://na1.api.riotgames.com/tft/summoner/v1/summoners/by-name/" + summoner_name, headers=headers).content.decode())
response_matches = json.loads(requests.get("https://americas.api.riotgames.com/tft/match/v1/matches/by-puuid/" + response_ids['puuid'] + "/ids?count=1", headers=headers).content.decode())
response_recent_match = json.loads(requests.get("https://americas.api.riotgames.com/tft/match/v1/matches/" + response_matches[0], headers=headers).content.decode())
rank = -1
for player in response_recent_match['info']['participants']:
if player['puuid'] == response_ids['puuid']:
rank = player['placement']
if rank > 4:
return True
return False
# returns the most recent match id for a player
def get_most_recent_match(summoner_name):
response_ids = json.loads(requests.get("https://na1.api.riotgames.com/tft/summoner/v1/summoners/by-name/" + summoner_name, headers=headers).content.decode())
response_matches = json.loads(requests.get("https://americas.api.riotgames.com/tft/match/v1/matches/by-puuid/" + response_ids['puuid'] + "/ids?count=1", headers=headers).content.decode())
return response_matches
# pushes data for last game played to player table
def get_data_for_user(summoner_name):
response_ids = json.loads(requests.get("https://na1.api.riotgames.com/tft/summoner/v1/summoners/by-name/" + summoner_name, headers=headers).content.decode())
response_rank = json.loads(requests.get("https://na1.api.riotgames.com/tft/league/v1/entries/by-summoner/" + response_ids["id"], headers=headers).content.decode())
# checks for ranked tft ranking only
for queue in response_rank:
if queue['queueType'] == 'RANKED_TFT':
response_rank = queue
# checks if user is unranked
if len(response_rank) == 0:
rank = summoner_name + " is currently unranked."
else:
rank = summoner_name + " is currently " + response_rank['tier'] + " " + response_rank['rank'] + ", " + str(response_rank['leaguePoints']) + " LP."
response_matches = [get_most_recent_match(summoner_name)[0]]
response_recent_match = json.loads(requests.get("https://americas.api.riotgames.com/tft/match/v1/matches/" + response_matches[0], headers=headers).content.decode())
timedelta = int(response_recent_match['info']['game_datetime'] / 1e3)
last_placement = -1
trait_str = ""
comp_str = ""
augment_str = ""
# gets last placement, items for queried player
for player in response_recent_match['info']['participants']:
if player['puuid'] == response_ids['puuid']:
if 'augments' in list(player.keys()):
augment_str = ", ".join([augment.split("_")[2] for augment in player['augments']])
for trait in player['traits']:
if trait['tier_current'] != 0:
trait_str += str(trait['num_units']) + " " + trait['name'][5:] + " "
# gets items and player units
for unit in player['units']:
comp_str += str(unit['tier']) + " star " + unit['character_id'][5:] + ": "
if len(unit['items']) == 0:
comp_str += " No items\n"
else:
comp_str += ", ".join(get_item_name(item_id) for item_id in unit['items']) + "\n"
last_placement = player['placement']
checker = add_data_check(summoner_name)
if checker == "ADD":
query = '''INSERT INTO player(name, rank, timedelta, last_placement, traits, comp, match_id, augments)
VALUES(\'''' + summoner_name + '''\', \'''' + str(rank) + '''\', ''' + str(timedelta) + ''', ''' + str(last_placement) + ''', \'''' + trait_str + '''\', \'''' + comp_str.replace("'", "$").replace("\n", ";") + '''\', \'''' + response_matches[0] + '''\', \'''' + augment_str + '''\')'''
cur.execute(query)
elif checker == "UPDATE":
query = '''UPDATE player
SET rank=\'''' + str(rank) + '''\', timedelta=''' + str(timedelta) + ''', last_placement=''' + str(last_placement) + ''', traits=\'''' + trait_str + '''\', comp=\'''' + comp_str.replace("'", "$").replace("\n", ";") + '''\', match_id=\'''' + response_matches[0] + '''\', augments=\'''' + augment_str + '''\' WHERE name=\'''' + summoner_name + '''\''''
cur.execute(query)
conn.commit()
# on message to discord channel
@client.event
async def on_message(message):
try:
# displays information for all players
if message.content == ".refreshverbose":
LIST_OF_FRIENDS = get_all_players_from_server(message.guild.id)
update_data(LIST_OF_FRIENDS)
FRIENDS_DATA = {}
for friend in LIST_OF_FRIENDS:
FRIENDS_DATA[friend] = get_data_from_db(friend)
friend_strings_list = [i for i in list(FRIENDS_DATA.values()) if i]
friend_strings_list.sort(key=functools.cmp_to_key(compare_ranks))
for friend_strings in friend_strings_list:
embed = discord.Embed(title=friend_strings[0], description=friend_strings[1] + "\n" + friend_strings[2] + friend_strings[3], color=discord.Colour.teal())
# displays last comp played
embed.add_field(name="Augments:", value="[1, 2, 3]: " + friend_strings[7], inline=False)
embed.add_field(name="Last Comp:", value=friend_strings[4] + "\n\n" + friend_strings[5], inline=False)
await message.channel.send(embed=embed)
# refreshes verbose specified user
elif message.content.split(" ")[0] == ".refreshverbose":
LIST_OF_FRIENDS = get_all_players_from_server(message.guild.id)
friend = " ".join(message.content.split(" ")[1:])
update_data(LIST_OF_FRIENDS)
get_data_from_db(friend)
FRIENDS_DATA = {}
for friend_loop in LIST_OF_FRIENDS:
FRIENDS_DATA[friend_loop] = get_data_from_db(friend_loop)
friend_strings_list = [friend_string for friend_string in list(FRIENDS_DATA.values()) if friend_string and friend_string[0] == friend]
for friend_strings in friend_strings_list:
embed = discord.Embed(title=friend_strings[0], description=friend_strings[1] + "\n" + friend_strings[2] + friend_strings[3], color=discord.Colour.teal())
# displays last comp played
embed.add_field(name="Augments:", value="[1, 2, 3]: " + friend_strings[7], inline=False)
embed.add_field(name="Last Comp:", value=friend_strings[4] + "\n\n" + friend_strings[5], inline=False)
await message.channel.send(embed=embed)
# refreshes all users
elif message.content == ".refresh":
LIST_OF_FRIENDS = get_all_players_from_server(message.guild.id)
update_data(LIST_OF_FRIENDS)
for friend in LIST_OF_FRIENDS:
get_data_from_db(friend)
FRIENDS_DATA = {}
for friend in LIST_OF_FRIENDS:
FRIENDS_DATA[friend] = get_data_from_db(friend)
friend_strings_list = [i for i in list(FRIENDS_DATA.values()) if i]
friend_strings_list.sort(key=functools.cmp_to_key(compare_ranks))
embed = discord.Embed(title="Refreshed Data", color=discord.Colour.teal())
for friend_strings in friend_strings_list:
embed.add_field(name=friend_strings[0], value=friend_strings[1], inline=False)
await message.channel.send(embed=embed)
# refreshes specified user
elif message.content.split(" ")[0] == ".refresh":
LIST_OF_FRIENDS = get_all_players_from_server(message.guild.id)
friend = " ".join(message.content.split(" ")[1:])
update_data(LIST_OF_FRIENDS)
get_data_from_db(friend)
FRIENDS_DATA = {}
for friend_loop in LIST_OF_FRIENDS:
FRIENDS_DATA[friend_loop] = get_data_from_db(friend_loop)
friend_strings_list = [friend_string for friend_string in list(FRIENDS_DATA.values()) if friend_string and friend_string[0] == friend]
for friend_strings in friend_strings_list:
embed = discord.Embed(title=friend_strings[0], description=friend_strings[1], color=discord.Colour.teal())
await message.channel.send(embed=embed)
# flames hani
elif message.content == ".flamehani":
if get_last_ranking("alostaz47"):
insult = random.choice(FLAME_MESSAGE_LIST_HANI)
await message.channel.send(insult)
else:
await message.channel.send("You can't flame Hani just yet...\n...but he does have a crippling addiction")
# flames sandy
elif message.content == ".flamesandy":
if get_last_ranking("SaltySandyHS"):
insult = random.choice(FLAME_MESSAGE_LIST_SANDY)
await message.channel.send(insult)
else:
await message.channel.send("I feel bad insulting Sandy now it's like kicking a dead deer")
# flames jreiss
elif message.content == ".flamejreiss":
if get_last_ranking("ExistToCease"):
insult = random.choice(FLAME_MESSAGE_LIST_JREISS)
await message.channel.send(insult)
else:
await message.channel.send("He actually got a top 4 :o")
elif message.content.split(" ")[0] == ".adduser":
if add_user(message):
await message.channel.send(" ".join(message.content.split(" ")[1:]) + " has been added to the list of updated users for " + message.guild.name + ".")
else:
await message.channel.send(" ".join(message.content.split(" ")[1:]) + " is not a valid Riot username.")
elif message.content.split(" ")[0] == ".deleteuser":
delete_user(message)
await message.channel.send(" ".join(message.content.split(" ")[1:]) + " has been deleted from the list of updated users for " + message.guild.name + ".")
# help command
elif message.content == ".help":
embed = discord.Embed(title="Command List and Information", description="This bot refreshes every minute to update members of peoples' TFT status.", color=discord.Colour.teal())
embed.add_field(name="Refresh", value=".refresh: Displays recent information about users and their current ranking.\n.refresh [player_name]: Displays information about a specific user.", inline=False)
embed.add_field(name="Refresh (Verbose)", value=".refreshverbose: Displays more information about users' last comps and game data.\n.refreshverbose [player_name]: Displays more information about a specific user.", inline=False)
embed.add_field(name="Add User", value=".adduser: Add a user to the list of users with information in this server.", inline=False)
embed.add_field(name="Flame a friend", value=".flamehani: Flames Hani if he bot 4ed the last game.\n.flamesandy: Flames Sandy if he bot 4ed the last game.\n.flamejreiss: Flames jreiss if he bot 4ed the last game.", inline=False)
embed.add_field(name="Help", value=".help: Displays this message.", inline=False)
await message.channel.send(embed=embed)
except Exception as e:
traceback_str = ''.join(traceback.format_exception(None, e, e.__traceback__))
await message.channel.send(traceback_str)
# sends message to channel if new game played, checks every 60 seconds
@tasks.loop(seconds=60)
async def game_played_tracker():
await client.wait_until_ready()
player_list = get_players_from_db()
# personal test server, see error messages
channel_test = client.get_channel(458644594905710595)
try:
for friend in player_list:
print(friend)
recent_match = get_most_recent_match(friend)
if len(recent_match) > 0:
recent_match = recent_match[0]
# if match not in history and match played within 5 minutes (avoids duplicate messages on startup)
if get_last_game(friend) != recent_match and get_timedelta(recent_match) < 300:
get_data_for_user(friend)
strings = get_data_from_db(friend)
if get_last_ranking(friend):
ranking_str = "bot 4"
else:
ranking_str = "top 4"
embed = discord.Embed(title=friend + " went " + ranking_str, description=strings[1] + "\n" + strings[3], color=discord.Colour.teal())
# displays last comp played
embed.add_field(name="Augments:", value="[1, 2, 3]: " + strings[7], inline=False)
embed.add_field(name="Last Comp:", value=strings[4] + "\n\n" + strings[5], inline=False)
user_servers = get_servers_from_player(friend)
for server in user_servers:
default_channel = client.get_channel(get_channel_from_server(server))
await default_channel.send(embed=embed)
NEEDS_UPDATE[friend] = recent_match
# just add older games to last game played
elif get_last_game(friend) != recent_match:
NEEDS_UPDATE[friend] = recent_match
else:
embed = discord.Embed(title=friend, description="has not played a game of TFT.")
# prints exceptions in personal test channel
except Exception as e:
traceback_str = ''.join(traceback.format_exception(None, e, e.__traceback__))
await channel_test.send(traceback_str)
game_played_tracker.start()
client.run(os.getenv("DISCORD_TOKEN"))