· 5 years ago · Feb 24, 2021, 03:10 PM
1# Importing the modules
2import requests
3import discord
4from discord.ext import commands
5import asyncio
6import time
7
8# Telling us what the bot prefix will be
9client = commands.Bot(command_prefix=".")
10
11
12# Telling us when the bot is running
13@client.event
14async def on_ready():
15 print("Bot is running")
16 await my_task()
17
18def getInfo(call):
19 r = requests.get(call)
20 return r.json()
21
22# Making a list of the players
23igns = ["a8a48a34-9890-419a-89d4-8f2bce765501", "794b88ca-e8c0-43b1-b075-7ca3a99328c7"]
24
25
26# Setting our api key
27api_key = "b5f2d5ac-a812-4981-8005-362fa37815cf"
28
29# Text channels
30channel = client.get_channel(813863906555985932)
31bypass = client.get_channel(813863922842599496)
32
33# Setting clear dictionaries
34data = {}
35previouswins = {}
36wins = {}
37realname = {}
38
39# Getting the data
40for name in igns:
41 data[name] = requests.get("https://api.hypixel.net/player?uuid=" + name + "&key=" + api_key).json()
42
43 realname[name] = {"displayname": data[name]["player"]["displayname"]}
44
45
46# Making the loop to track the wins
47async def my_task():
48 while True:
49 for name in igns:
50 statusUrl = f"https://api.hypixel.net/status?key={api_key}&uuid={name}"
51 status = getInfo(statusUrl)
52 apiUrl = f"https://api.hypixel.net/player?uuid={name}&key={api_key}"
53 apiInfo = getInfo(apiUrl)
54 channel = client.get_channel(813863906555985932)
55 try:
56 online = status['session']['online']
57 except:
58 online = False
59
60 if online:
61 print("bruh")
62 statusUrl = f"https://api.hypixel.net/status?key={api_key}&uuid={name}"
63 status = getInfo(statusUrl)
64 online = status['session']['online']
65
66 modes = ["BRIDGE_DUEL", "BRIDGE_DOUBLES", "BRIDGE_FOUR", "BRIDGE_2V2V2V2", "BRIDGE_3V3V3V3", "OP_DUEL",
67 "OP_DOUBLES", "UHC_DUEL", "UHC_DOUBLES", "UHC_FOUR", "UHC_MEETUP", "CLASSIC_DUEL", "SW_DUEL",
68 "SW_DOUBLES",
69 "MW_DUEL", "MW_DOUBLES", "SUMO_DUEL", "POTION_DUEL", "BLITZ_DUEL", "COMBO_DUEL",
70 "BOWSPLEEF_DUEL"]
71
72 try:
73 player_session_mode = status['session']['mode']
74 except:
75 player_session_mode = "Offline / api disabled"
76
77 for mode in modes:
78 if player_session_mode == mode:
79 wsmode = mode.lower()
80 try:
81 recentUrl = f"https://api.hypixel.net/recentGames?key={api_key}&uuid={name}"
82 recent = getInfo(recentUrl)
83 queue = 'ended' in recent['games'][0]
84 elapsed = time.time() - recent['games'][0]["date"] / 1000
85 m, s = divmod(elapsed, 60)
86 except:
87 queue = False
88 m, s = 0
89 try:
90 ws = apiInfo['player']['stats']['Duels'][f'current_winstreak_mode_{wsmode}']
91 except:
92 ws = 0
93 try:
94 player_session_mode = status['session']['mode']
95 player_session_map = status['session']['map']
96 except:
97 player_session_mode = f"Offline / api disabled"
98 player_session_map = f"Offline / api disabled"
99
100 embed2 = discord.Embed(title=realname[name], color=discord.Colour.green(),
101 url=f"https://plancke.io/hypixel/player/stats/{name}#Duels")
102 embed2.add_field(name="Mode:", value=f"`{player_session_mode}`", inline=False)
103 embed2.add_field(name="Map:", value=f"`{player_session_map}`", inline=False)
104 embed2.add_field(name="Winstreak:", value=f"`{ws}`", inline=False)
105 if not queue:
106 embed2.add_field(name="Elapsed Time:", value=f"`{int(m)}m {int(s)}s`", inline=False)
107
108 embed2.add_field(name="Queuing or in game?:", value='`In queue`' if queue else '`In game`',
109 inline=False)
110 embed2.set_thumbnail(url=f"https://crafatar.com/renders/body/{name}")
111 embed2.set_footer(text="• Made by Danqerr")
112 await channel.send(embed=embed2)
113 return None
114
115 if online:
116 try:
117 player_session_gameType = status['session']['gameType']
118 except:
119 player_session_gameType = f" {realname[name]} is offline/has API settings disabled."
120 embed2 = discord.Embed(title=realname[name], color=discord.Colour.green(),
121 url=f"https://plancke.io/hypixel/player/stats/{name}#Duels")
122 embed2.add_field(name="Game Type:", value=f"`{player_session_gameType}`", inline=False)
123 embed2.add_field(name="Mode:", value=f"`{player_session_mode}`", inline=False)
124 embed2.set_thumbnail(url=f"https://crafatar.com/renders/body/{name}")
125 embed2.set_footer(text="• Made by Danqerr")
126 await channel.send(embed=embed2)
127 else:
128 gamemodes = ["bridge_duel", "bridge_doubles", "bridge_four", "bridge_2v2v2v2", "bridge_3v3v3v3",
129 "op_duel",
130 "op_doubles", "uhc_duel", "uhc_doubles", "uhc_four", "uhc_meetup", "classic_duel",
131 "sw_duel", "sw_doubles",
132 "mw_duel", "mw_doubles", "sumo_duel", "potion_duel", "blitz_duel", "combo_duel",
133 "bowspleef_duel"]
134 for mode in gamemodes:
135 gamemode = mode.upper()
136 try:
137 previouswins[name] = {mode: data[name]["player"]["stats"]["Duels"][f"{mode}"]}
138 except:
139 previouswins[name] = {mode: 0}
140
141 previouswins[name]["lastlogin"] = data[name]["player"]["lastLogin"]
142
143 previouswins[name]["lastlogout"] = data[name]["player"]["lastLogout"]
144
145 data[name] = requests.get("https://api.hypixel.net/player?uuid=" + name + "&key=" + api_key).json()
146
147 try:
148 wins[name] = {mode: data[name]["player"]["stats"]["Duels"][f"{mode}"]}
149 except:
150 wins[name] = {mode: 0}
151
152 wins[name]["lastlogin"] = data[name]["player"]["lastLogin"]
153
154 wins[name]["lastlogout"] = data[name]["player"]["lastLogout"]
155
156 changedby = wins[name][mode] - previouswins[name][mode]
157
158 # Telling us if they have won a game
159 if changedby != 0:
160 embed2 = discord.Embed(title=realname[name], color=discord.Colour.green(),
161 url=f"https://plancke.io/hypixel/player/stats/{name}#Duels")
162 embed2.add_field(name="Mode:", value=f"`{gamemode}`", inline=False)
163 embed2.add_field(name="Winstreak Change:", value=f"`{changedby}`", inline=False)
164 embed2.add_field(name="Winstreak :", value=f"`{wins[name][mode]}`", inline=False)
165 embed2.set_thumbnail(url=f"https://crafatar.com/renders/body/{name}")
166 embed2.set_footer(text="• Made by Danqerr")
167 await bypass.send(embed=embed2)
168
169 if previouswins[name]["lastlogin"] < wins[name]["lastlogin"]:
170 embed2 = discord.Embed(title=f"{realname[name]}", color=discord.Colour.green(),
171 url=f"https://plancke.io/hypixel/player/stats/{name}#Duels")
172 embed2.add_field(name="Status:", value=f"`{realname[name]} logged in!`", inline=False)
173 embed2.set_thumbnail(url=f"https://crafatar.com/renders/body/{name}")
174 embed2.set_footer(text="• Made by Danqerr")
175 await channel.send(embed=embed2)
176
177 if previouswins[name]["lastlogout"]<wins[name]["lastlogout"]:
178 embed2 = discord.Embed(title=f"{realname[name]}", color=discord.Colour.red(),
179 url=f"https://plancke.io/hypixel/player/stats/{name}#Duels")
180 embed2.add_field(name="Status:", value=f"`{realname[name]} logged off!`", inline=False)
181 embed2.set_thumbnail(url=f"https://crafatar.com/renders/body/{name}")
182 embed2.set_footer(text="• Made by Danqerr")
183 await channel.send(embed=embed2)
184
185
186 await asyncio.sleep(10)
187
188# The key to access the bot
189token = "funny.exe"
190
191# Running the bot
192client.run(token)